Browse Source

1.添加android 端初始化通知原生方法

tags/0.0.3+6
“yanghuaxuan” 4 years ago
parent
commit
50d035d366
3 changed files with 18 additions and 8 deletions
  1. +2
    -0
      android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNativable.java
  2. +10
    -2
      android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNative.java
  3. +6
    -6
      lib/models/base/base_setting_model.dart

+ 2
- 0
android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNativable.java View File

@@ -16,4 +16,6 @@ public interface ZhiyingFlutterCommNativable {

/* 普通方法(交互) */
public void invokeMethod(String method, Map<String, Object> params, ZhiyingFlutterCommHandler handler);

public void initSuccess();
}

+ 10
- 2
android/src/main/java/cn/zhios/zhiying_comm/ZhiyingFlutterCommNative.java View File

@@ -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;
}


+ 6
- 6
lib/models/base/base_setting_model.dart View File

@@ -44,13 +44,11 @@ class BaseSettingModel {
static Future<BaseSettingModel> 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;
}


Loading…
Cancel
Save