release: 1.0.13
This commit is contained in:
@ -23,40 +23,17 @@ public class AMapFlutterMapPlugin implements
|
||||
private static final String CLASS_NAME = "AMapFlutterMapPlugin";
|
||||
private static final String VIEW_TYPE = "com.amap.flutter.map";
|
||||
private Lifecycle lifecycle;
|
||||
private FlutterPluginBinding pluginBinding;
|
||||
|
||||
public AMapFlutterMapPlugin() {
|
||||
}
|
||||
|
||||
public static void registerWith(PluginRegistry.Registrar registrar) {
|
||||
LogUtil.i(CLASS_NAME, "registerWith=====>");
|
||||
|
||||
final Activity activity = registrar.activity();
|
||||
if (activity == null) {
|
||||
LogUtil.w(CLASS_NAME, "activity is null!!!");
|
||||
return;
|
||||
}
|
||||
if (activity instanceof LifecycleOwner) {
|
||||
registrar
|
||||
.platformViewRegistry()
|
||||
.registerViewFactory(
|
||||
VIEW_TYPE,
|
||||
new AMapPlatformViewFactory(
|
||||
registrar.messenger(),
|
||||
() -> ((LifecycleOwner) activity).getLifecycle()));
|
||||
} else {
|
||||
registrar
|
||||
.platformViewRegistry()
|
||||
.registerViewFactory(
|
||||
VIEW_TYPE,
|
||||
new AMapPlatformViewFactory(registrar.messenger(), new ProxyLifecycleProvider(activity)));
|
||||
}
|
||||
}
|
||||
|
||||
// FlutterPlugin
|
||||
|
||||
@Override
|
||||
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
|
||||
LogUtil.i(CLASS_NAME, "onAttachedToEngine==>");
|
||||
this.pluginBinding = binding;
|
||||
binding
|
||||
.getPlatformViewRegistry()
|
||||
.registerViewFactory(
|
||||
@ -78,6 +55,13 @@ public class AMapFlutterMapPlugin implements
|
||||
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
|
||||
LogUtil.i(CLASS_NAME, "onAttachedToActivity==>");
|
||||
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
|
||||
pluginBinding.getPlatformViewRegistry().registerViewFactory(
|
||||
VIEW_TYPE,
|
||||
new AMapPlatformViewFactory(
|
||||
pluginBinding.getBinaryMessenger(),
|
||||
() -> lifecycle
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.view.FlutterMain;
|
||||
import io.flutter.embedding.engine.FlutterEngine;
|
||||
import io.flutter.embedding.engine.loader.FlutterLoader;
|
||||
|
||||
/**
|
||||
* @author whm
|
||||
@ -44,6 +45,15 @@ public class ConvertUtil {
|
||||
private static final int[] LocationTypeMap = new int[]{MyLocationStyle.LOCATION_TYPE_SHOW, MyLocationStyle.LOCATION_TYPE_FOLLOW, MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE};
|
||||
public static float density;
|
||||
private static String apiKey;
|
||||
private static FlutterLoader flutterLoader; // For asset loading
|
||||
|
||||
public static void initialize(Context context) {
|
||||
flutterLoader = new FlutterLoader();
|
||||
if (!flutterLoader.initialized()) {
|
||||
flutterLoader.startInitialization(context);
|
||||
flutterLoader.ensureInitializationComplete(context, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPrivacyStatement(Context context, Object object) {
|
||||
if (null == object) {
|
||||
@ -396,15 +406,15 @@ public class ConvertUtil {
|
||||
case "fromAsset":
|
||||
if (data.size() == 2) {
|
||||
return BitmapDescriptorFactory.fromAsset(
|
||||
FlutterMain.getLookupKeyForAsset(toString(data.get(1))));
|
||||
flutterLoader.getLookupKeyForAsset(toString(data.get(1))));
|
||||
} else {
|
||||
return BitmapDescriptorFactory.fromAsset(
|
||||
FlutterMain.getLookupKeyForAsset(toString(data.get(1)), toString(data.get(2))));
|
||||
flutterLoader.getLookupKeyForAsset(toString(data.get(1)), toString(data.get(2))));
|
||||
}
|
||||
case "fromAssetImage":
|
||||
if (data.size() == 3) {
|
||||
return BitmapDescriptorFactory.fromAsset(
|
||||
FlutterMain.getLookupKeyForAsset(toString(data.get(1))));
|
||||
flutterLoader.getLookupKeyForAsset(toString(data.get(1))));
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"'fromAssetImage' Expected exactly 3 arguments, got: " + data.size());
|
||||
|
Reference in New Issue
Block a user