amap_core_fluttify
This commit is contained in:
70
android/build.gradle
Normal file
70
android/build.gradle
Normal file
@ -0,0 +1,70 @@
|
||||
group 'me.yohom.amap_core_fluttify'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
if (project.android.hasProperty("namespace")) {
|
||||
namespace = "me.yohom.amap_core_fluttify"
|
||||
}
|
||||
compileSdkVersion 31
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
main.jniLibs.srcDir 'libs'
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
compileOptions {
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
packagingOptions {
|
||||
merge 'res/values/values.xml'
|
||||
merge 'AndroidManifest.xml'
|
||||
merge 'R.txt'
|
||||
merge 'classes.jar'
|
||||
merge 'proguard.txt'
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
consumerProguardFiles "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
compileOnly rootProject.findProject(":foundation_fluttify")
|
||||
// flutter plugin dependency
|
||||
|
||||
// sdk dependency
|
||||
|
||||
}
|
1
android/settings.gradle
Normal file
1
android/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = 'amap_core_fluttify'
|
3
android/src/main/AndroidManifest.xml
Normal file
3
android/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="me.yohom.amap_core_fluttify">
|
||||
</manifest>
|
@ -0,0 +1,150 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_core_fluttify;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.app.Activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import io.flutter.plugin.platform.PlatformViewRegistry;
|
||||
|
||||
import me.yohom.amap_core_fluttify.sub_handler.*;
|
||||
import me.yohom.amap_core_fluttify.sub_handler.custom.SubHandlerCustom;
|
||||
import me.yohom.foundation_fluttify.core.FluttifyMessageCodec;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class AmapCoreFluttifyPlugin implements FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
||||
|
||||
private static List<Map<String, Handler>> handlerMapList;
|
||||
|
||||
// v1 android embedding for compatible
|
||||
public static void registerWith(Registrar registrar) {
|
||||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "me.yohom/amap_core_fluttify", new StandardMethodCodec(new FluttifyMessageCodec()));
|
||||
|
||||
AmapCoreFluttifyPlugin plugin = new AmapCoreFluttifyPlugin();
|
||||
|
||||
BinaryMessenger messenger = registrar.messenger();
|
||||
PlatformViewRegistry platformViewRegistry = registrar.platformViewRegistry();
|
||||
Activity activity = registrar.activity();
|
||||
|
||||
plugin.messenger = messenger;
|
||||
plugin.platformViewRegistry = platformViewRegistry;
|
||||
|
||||
handlerMapList = new ArrayList<>();
|
||||
|
||||
handlerMapList.add(SubHandlerCustom.instance.getSubHandler(messenger, registrar.activity()));
|
||||
|
||||
channel.setMethodCallHandler(plugin);
|
||||
|
||||
// register platform view
|
||||
|
||||
}
|
||||
|
||||
private BinaryMessenger messenger;
|
||||
private PlatformViewRegistry platformViewRegistry;
|
||||
|
||||
// v2 android embedding
|
||||
@Override
|
||||
public void onAttachedToEngine(FlutterPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapCoreFluttifyPlugin::onAttachedToEngine@" + binding);
|
||||
}
|
||||
|
||||
final MethodChannel channel = new MethodChannel(binding.getBinaryMessenger(), "me.yohom/amap_core_fluttify", new StandardMethodCodec(new FluttifyMessageCodec()));
|
||||
|
||||
messenger = binding.getBinaryMessenger();
|
||||
platformViewRegistry = binding.getPlatformViewRegistry();
|
||||
|
||||
handlerMapList = new ArrayList<>();
|
||||
|
||||
|
||||
channel.setMethodCallHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromEngine(FlutterPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapCoreFluttifyPlugin::onDetachedFromEngine@" + binding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToActivity(ActivityPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapCoreFluttifyPlugin::onAttachedToActivity@" + binding);
|
||||
}
|
||||
Activity activity = binding.getActivity();
|
||||
|
||||
handlerMapList.add(SubHandlerCustom.instance.getSubHandler(messenger, activity));
|
||||
|
||||
// register platform view
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromActivity() {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapCoreFluttifyPlugin::onDetachedFromActivity");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapCoreFluttifyPlugin::onReattachedToActivityForConfigChanges@" + binding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromActivityForConfigChanges() {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapCoreFluttifyPlugin::onDetachedFromActivityForConfigChanges");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMethodCall(@NonNull MethodCall methodCall, @NonNull MethodChannel.Result methodResult) {
|
||||
Handler handler = null;
|
||||
for (Map<String, Handler> handlerMap : handlerMapList) {
|
||||
if (handlerMap.containsKey(methodCall.method)) {
|
||||
handler = handlerMap.get(methodCall.method);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (handler != null) {
|
||||
try {
|
||||
handler.call(methodCall.arguments, methodResult);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
methodResult.error(e.getMessage(), null, null);
|
||||
}
|
||||
} else {
|
||||
methodResult.notImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public static interface Handler {
|
||||
void call(Object args, MethodChannel.Result methodResult) throws Exception;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_core_fluttify.sub_handler.custom;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
import io.flutter.plugin.platform.PlatformViewRegistry;
|
||||
|
||||
import me.yohom.amap_core_fluttify.AmapCoreFluttifyPlugin.Handler;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class SubHandlerCustom {
|
||||
|
||||
public static final SubHandlerCustom instance = new SubHandlerCustom();
|
||||
|
||||
private SubHandlerCustom() { }
|
||||
|
||||
public Map<String, Handler> getSubHandler(BinaryMessenger messenger, android.app.Activity activity) {
|
||||
return new HashMap<String, Handler>() {{
|
||||
put("", (args, methodResult) -> {
|
||||
// args
|
||||
|
||||
// ref
|
||||
|
||||
// invoke native method
|
||||
try {
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
methodResult.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// convert result to jsonable result
|
||||
String jsonableResult = "success";
|
||||
|
||||
methodResult.success(jsonableResult);
|
||||
});
|
||||
}};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user