Przeglądaj źródła

1.优化京东初始化SDK时报错的问题

tags/0.1.1
huaxuan 2 lat temu
rodzic
commit
19f31fe762
1 zmienionych plików z 50 dodań i 39 usunięć
  1. +50
    -39
      android/src/main/java/com/jd/jdsdk/JdsdkPlugin.java

+ 50
- 39
android/src/main/java/com/jd/jdsdk/JdsdkPlugin.java Wyświetl plik

@@ -11,55 +11,66 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;

/** JdsdkPlugin */
/**
* JdsdkPlugin
*/
public class JdsdkPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware {
public static JDHelper mJDHelper;
private MethodChannel channel;
@Override
public void onAttachedToEngine( FlutterPluginBinding flutterPluginBinding) {
public static JDHelper mJDHelper;
private MethodChannel channel;

@Override
public void onAttachedToEngine(FlutterPluginBinding flutterPluginBinding) {
// mJDHelper = JDHelper.getInstance(flutterPluginBinding.getApplicationContext());
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "jdsdk");
channel.setMethodCallHandler(this);
}
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "jdsdk");
channel.setMethodCallHandler(this);
}

@Override
public void onMethodCall( MethodCall call, Result result) {
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else if (call.method.equals("init")) {
mJDHelper.initKepler(call,result);
}else if (call.method.equals("openUrl")) {
Log.d("flutter-test","openUrl");
mJDHelper.openUrl(call,result);
}else {
result.notImplemented();
@Override
public void onMethodCall(MethodCall call, Result result) {
try {
if (mJDHelper == null) {
mJDHelper = JDHelper.getInstance(binding);
}
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else if (call.method.equals("init")) {
mJDHelper.initKepler(call, result);
} else if (call.method.equals("openUrl")) {
Log.d("flutter-test", "openUrl");
mJDHelper.openUrl(call, result);
} else {
result.notImplemented();
}
} catch (Exception e) {
Log.d("zhiying", "捕获出错");
e.printStackTrace();
}
}
}

@Override
public void onDetachedFromEngine( FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
mJDHelper = null;
}
@Override
public void onDetachedFromEngine(FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
mJDHelper = null;
}

@Override
public void onAttachedToActivity( ActivityPluginBinding binding) {
Log.d("flutter-taoke","onAttachedToActivity"+binding);
mJDHelper = JDHelper.getInstance(binding);
}
@Override
public void onAttachedToActivity(ActivityPluginBinding binding) {
Log.d("flutter-taoke", "onAttachedToActivity" + binding);
mJDHelper = JDHelper.getInstance(binding);
}

@Override
public void onDetachedFromActivityForConfigChanges() {
@Override
public void onDetachedFromActivityForConfigChanges() {

}
}

@Override
public void onReattachedToActivityForConfigChanges( ActivityPluginBinding binding) {
@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {

}
}

@Override
public void onDetachedFromActivity() {
@Override
public void onDetachedFromActivity() {

}
}
}

Ładowanie…
Anuluj
Zapisz