From 50d035d366759f087c9e13e1db2d962de1c4c6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Tue, 12 Jan 2021 10:17:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0android=20=E7=AB=AF?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=80=9A=E7=9F=A5=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhiying_comm/ZhiyingFlutterCommNativable.java | 2 ++ .../zhios/zhiying_comm/ZhiyingFlutterCommNative.java | 12 ++++++++++-- lib/models/base/base_setting_model.dart | 12 ++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNativable.java b/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNativable.java index fbe9d30..92ea98f 100644 --- a/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNativable.java +++ b/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNativable.java @@ -16,4 +16,6 @@ public interface ZhiyingFlutterCommNativable { /* 普通方法(交互) */ public void invokeMethod(String method, Map params, ZhiyingFlutterCommHandler handler); + + public void initSuccess(); } diff --git a/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNative.java b/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNative.java index a895905..74325a0 100644 --- a/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNative.java +++ b/android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNative.java @@ -91,6 +91,15 @@ public class ZhiyingFlutterCommNative implements MethodCallHandler { return; } + if(call.method.equals("notifyInitSuccess")){ + if(nat!=null){ + nat.initSuccess(); + } + result.success("success"); + return; + + } + /* 调用原生方法 */ if (call.method.equals("invokeMethod")) { if (nat != null) { @@ -106,8 +115,7 @@ public class ZhiyingFlutterCommNative implements MethodCallHandler { return; } - } else { - + } else{ result.notImplemented(); return; } diff --git a/lib/models/base/base_setting_model.dart b/lib/models/base/base_setting_model.dart index 481cc61..edb1a93 100644 --- a/lib/models/base/base_setting_model.dart +++ b/lib/models/base/base_setting_model.dart @@ -44,13 +44,11 @@ class BaseSettingModel { static Future init({bool isGetCache}) async { try { ///判断是否获取缓存 - if (isGetCache != null && isGetCache) { - String configData = await SharedPreferencesUtil.getStringValue(GlobalConfig.MAIN_CONFIG, defaultVal: '1'); - if (configData != "1") { - createBaseSet(json.decode(configData)); - Logger.debug('基础设置初始化'); - } + String configData = await SharedPreferencesUtil.getStringValue(GlobalConfig.MAIN_CONFIG, defaultVal: '1'); + if (isGetCache != null && isGetCache && configData != "1") { + createBaseSet(json.decode(configData)); + Logger.debug('基础设置初始化'); NetUtil.request('/api/v1/new/config.json',onSuccess: (data){ print(data); var cacheString=json.encode(data); @@ -62,6 +60,8 @@ class BaseSettingModel { Map result = await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET); var data = result['data']; + var cacheString=json.encode(data); + SharedPreferencesUtil.setNetCacheResult(GlobalConfig.MAIN_CONFIG, cacheString); createBaseSet(data); return _setting; }