|
|
@@ -4,6 +4,7 @@ import android.os.Handler
|
|
|
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 io.flutter.embedding.engine.FlutterEngine
|
|
|
import io.flutter.plugin.common.MethodChannel
|
|
|
|
|
|
@@ -51,15 +52,17 @@ class FlutterMethodCaller {
|
|
|
mMethodChannel.invokeMethod(methodName, args, object : MethodChannel.Result {
|
|
|
override fun success(result: Any?) {
|
|
|
if (isReturnJson) {
|
|
|
+ val resultJson = result.toString()
|
|
|
try {
|
|
|
- val resultJson = result.toString()
|
|
|
val resultObj = JsonUtil.parseJsonByClass<T>(resultJson, modelClazz)
|
|
|
runOnUIThread {
|
|
|
onSuccess?.invoke(resultObj)
|
|
|
}
|
|
|
} catch (e: Throwable) {
|
|
|
+ val errorMsg = e.message ?: "call error"
|
|
|
+ LogUtil.d("方法名:${methodName},调用成功,但解析json失败,原因:${errorMsg},json内容:${resultJson}")
|
|
|
runOnUIThread {
|
|
|
- onFail?.invoke(e.message ?: "call error")
|
|
|
+ onFail?.invoke(errorMsg)
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
@@ -71,12 +74,15 @@ class FlutterMethodCaller {
|
|
|
}
|
|
|
|
|
|
override fun error(errorCode: String, errorMessage: String?, errorDetails: Any?) {
|
|
|
+ val errorMsg = errorMessage ?: "call error"
|
|
|
+ LogUtil.d("方法名:${methodName},调用失败,原因:${errorMsg}")
|
|
|
runOnUIThread {
|
|
|
- onFail?.invoke(errorMessage ?: "call error")
|
|
|
+ onFail?.invoke(errorMsg)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun notImplemented() {
|
|
|
+ LogUtil.d("方法名:${methodName},调用失败,Flutter未实现该方法")
|
|
|
runOnUIThread {
|
|
|
onFail?.invoke("method not implemented")
|
|
|
}
|