Commit d5f93445 authored by 林生雨's avatar 林生雨

w

parent e3d6dfc3
......@@ -5,6 +5,7 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart';
......@@ -21,6 +22,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
class PlanModel extends BaseModel {
final String PLAN_MODEL_BUFFER = "PLAN_MODEL_BUFFER";
final String PLAN_MODEL_LIST_BUFFER = "PLAN_MODEL_LIST_BUFFER";
LiveData<List> managerLive = new LiveData();
LiveData<List<double>> posLive = new LiveData();
LiveData<List<double>> backLive = new LiveData();
......@@ -66,7 +68,7 @@ class PlanModel extends BaseModel {
if (call != null) {
call();
}
refreshFeed(true);
refreshFeed(true, needCache: needCache);
return;
}
ClueApiImpl.getInstance()
......@@ -82,7 +84,7 @@ class PlanModel extends BaseModel {
if (call != null) {
call();
}
refreshFeed(true);
refreshFeed(true, needCache: needCache);
CacheManager.getInstance()
.get(MEMORY_CACHE)
.save(PLAN_MODEL_BUFFER, json.encode(event.toJson()));
......@@ -110,11 +112,31 @@ class PlanModel extends BaseModel {
refreshFeed(true);
}
void refreshFeed(bool clear, {RefreshController controller}) {
void refreshFeed(bool clear,
{RefreshController controller, bool needCache = false}) {
if (clear) {
page = 1;
feedDatas.clear();
}
if (needCache
&&CacheManager.getInstance().get(MEMORY_CACHE).get(PLAN_MODEL_LIST_BUFFER)!=null) {
var event = PlanFeedBean.fromJson(json.decode(
CacheManager.getInstance().get(MEMORY_CACHE).get(PLAN_MODEL_LIST_BUFFER)));
if (event.data.plans == null || event.data.plans.isEmpty) {
if (page == 1) {
feedsLive.notifyView(Pair(EMPTY, []));
} else {
feedsLive.notifyView(Pair(ENDLOADING, []));
}
} else {
feedDatas.addAll(event.data.plans);
feedsLive.notifyView(Pair(ENDLOADING, feedDatas));
}
WidgetsBinding.instance.addPostFrameCallback((_) {
SimpleEventBus.instance()
.notifyListener("BaseNestedScrollViewRefreshIndicator", "refresh");
});
}
ClueApiImpl.getInstance()
.getPlanFeed(DioUtil.getInstance().getDio(), tag_id, order_by,
current_city_id, min_price, max_price, rank_type, page)
......@@ -129,6 +151,10 @@ class PlanModel extends BaseModel {
} else {
feedDatas.addAll(event.data.plans);
feedsLive.notifyView(Pair(ENDLOADING, feedDatas));
event.data.plans=feedDatas;
CacheManager.getInstance()
.get(MEMORY_CACHE)
.save(PLAN_MODEL_LIST_BUFFER, json.encode(event.toJson()));
}
controller?.refreshCompleted();
} else {
......@@ -140,6 +166,7 @@ class PlanModel extends BaseModel {
.addToDispose(rxDispose)
.onError((err) {
PrintUtil.printBug(err);
print("PLANERROR ${err}");
feedsLive.notifyView(Pair(FAIL, null));
controller?.refreshFailed();
});
......
......@@ -242,7 +242,10 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
),
);
},
)
),
baseSliverBack((){
Navigator.pop(context);
}),
],
),
);
......
......@@ -79,6 +79,12 @@ class MainManager {
// } else {
innerSetData(map, COOKIE);
// }
if (map[USER_ID] == null || "${map[USER_ID]}".isEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(USER_ID, null);
}
if (map[COOKIE] == null || "${map[COOKIE]}".isEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(COOKIE, null);
}
print(
"LSY QQWWEERRTTYY ${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE)}"
" ${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE) is String}");
......@@ -89,8 +95,6 @@ class MainManager {
void innerSetData(Map<String, dynamic> map, String str) {
if (map[str] != null && "${map[str]}".isNotEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(str, "${map[str]}");
} else {
CacheManager.getInstance().get(MEMORY_CACHE).save(str, null);
}
}
......
......@@ -29,96 +29,96 @@ class DioInterceptorManager {
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE) != null) {
opt.headers[HttpHeaders.cookieHeader] =
CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE)}";
}
if (opt.queryParameters == null) {
opt.queryParameters = Map<String, dynamic>();
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME) != null) {
opt.queryParameters[APP_NAME] =
CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION) != null) {
opt.queryParameters[VERSION] =
CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM) != null) {
opt.queryParameters[PLATFORM] =
CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID) != null) {
opt.queryParameters[DEVICE_ID] =
CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION) !=
null) {
opt.queryParameters[OS_VERSION] =
CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL) != null) {
opt.queryParameters[MODEL] =
CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN) != null) {
opt.queryParameters[SCREEN] =
CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(LAT) != null) {
opt.queryParameters[LAT] =
CacheManager.getInstance().get(MEMORY_CACHE).get(LAT);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(LAT)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(LNG) != null) {
opt.queryParameters[LNG] =
CacheManager.getInstance().get(MEMORY_CACHE).get(LNG);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(LNG)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL) != null) {
opt.queryParameters[CHANNEL] =
CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER) !=
null) {
opt.queryParameters[MANUFACTURER] =
CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(UUID) != null) {
opt.queryParameters[UUID] =
CacheManager.getInstance().get(MEMORY_CACHE).get(UUID);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(UUID)}";
}
if (Platform.isAndroid) {
if (CacheManager.getInstance()
.get(MEMORY_CACHE)
.get(ANDROID_DEVICE_ID) !=
null) {
opt.queryParameters[ANDROID_DEVICE_ID] = CacheManager.getInstance()
opt.queryParameters[ANDROID_DEVICE_ID] = "${CacheManager.getInstance()
.get(MEMORY_CACHE)
.get(ANDROID_DEVICE_ID);
.get(ANDROID_DEVICE_ID)}";
}
} else {
if (CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE) != null) {
opt.queryParameters[RELEASE] =
CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA) != null) {
opt.queryParameters[IDFA] =
CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV) != null) {
opt.queryParameters[IDFV] =
CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI) != null) {
opt.queryParameters[IS_WIFI] =
CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL) !=
null) {
opt.queryParameters[HARDWARE_MODEL] =
CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL)}";
}
if (CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID) !=
null) {
opt.queryParameters[CURRENT_CITY_ID] =
CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID);
"${CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID)}";
}
}
......
......@@ -158,10 +158,11 @@ class NestedScrollViewRefreshIndicatorState
Animation<double> _value;
Animation<Color> _valueColor;
_RefreshIndicatorMode _mode;
Future<void> _pendingRefreshFuture;
bool _isIndicatorAtTop;
double _dragOffset;
bool _isIndicatorAtTop=false;
double _dragOffset=0.0;
_RefreshIndicatorMode _mode=_RefreshIndicatorMode.done;
static final Animatable<double> _threeQuarterTween =
Tween<double>(begin: 0.0, end: 0.75);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment