|
|
@@ -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() { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |