|
|
@@ -5,6 +5,7 @@ import android.os.Looper
|
|
|
import com.atmob.keyboard_android.constant.PluginConfig
|
|
|
import com.atmob.keyboard_android.util.JsonUtil
|
|
|
import com.atmob.keyboard_android.util.LogUtil
|
|
|
+import com.atmob.keyboard_android.util.bridge.model.base.CallResult
|
|
|
import io.flutter.embedding.engine.FlutterEngine
|
|
|
import io.flutter.plugin.common.MethodChannel
|
|
|
|
|
|
@@ -54,6 +55,18 @@ class FlutterMethodCaller {
|
|
|
if (isReturnJson) {
|
|
|
val resultJson = result.toString()
|
|
|
try {
|
|
|
+ // 先尝试解析json,如果code不为0,就是失败
|
|
|
+ val result = JsonUtil.parseJsonByClass<CallResult>(
|
|
|
+ resultJson,
|
|
|
+ CallResult::class.java
|
|
|
+ )
|
|
|
+ if (result.code != 0) {
|
|
|
+ runOnUIThread {
|
|
|
+ onFail?.invoke(result.message)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 成功
|
|
|
val resultObj = JsonUtil.parseJsonByClass<T>(resultJson, modelClazz)
|
|
|
runOnUIThread {
|
|
|
onSuccess?.invoke(resultObj)
|