Commit 16db7270 by 徐健

增加flutter公共channel模块

parent 2659147b
......@@ -178,6 +178,7 @@ dependencies {
if (true) {
//开发模式
implementation fileTree(dir: 'aars', include: ['*.aar'])
api project(':m-user')
implementation modularPublication('com.ydl:m-user-api')
api project(':m-tests')
......@@ -212,6 +213,7 @@ dependencies {
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
api rootProject.ext.dependencies["ydl-flutter"]
}
......
......@@ -5,6 +5,8 @@ import android.app.Application;
import android.content.Context;
import android.content.Intent;
import com.ydl.component.single.CustomBinaryMessagerImpl;
import com.ydl.component.single.YDLCommonPlugin;
import com.ydl.devicesidlib.DeviceIDHelper;
import com.ydl.media.audio.PlayService;
import com.ydl.ydlcommon.base.delegate.IAppLifecycles;
......@@ -13,6 +15,8 @@ import com.yidianling.course.lifeCallback.CoursePlayLifecycle;
import org.jetbrains.annotations.NotNull;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.view.FlutterMain;
/**
......@@ -35,6 +39,7 @@ public class DemoAppLifecycles implements IAppLifecycles {
//Flutter 初始化需要在主线程中执行
FlutterMain.startInitialization(application);
initFlutterChannel();
Intent intent = new Intent(application, PlayService.class);
application.startService(intent);
......@@ -42,6 +47,14 @@ public class DemoAppLifecycles implements IAppLifecycles {
application.registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
}
/**
* 初始化一个公共channel
*/
private void initFlutterChannel() {
YDLCommonPlugin commonPlugin = new YDLCommonPlugin();
new MethodChannel(CustomBinaryMessagerImpl.Companion.getINSTANCE(), commonPlugin.CHANNEL).setMethodCallHandler(commonPlugin);
}
@Override
public void onTerminate(@NotNull Application application) {
......
package com.ydl.component.single
import io.flutter.plugin.common.BinaryMessenger
import java.nio.ByteBuffer
/**
* Created by xj on 2019/11/20.
*/
class CustomBinaryMessagerImpl: BinaryMessenger {
override fun setMessageHandler(p0: String, p1: BinaryMessenger.BinaryMessageHandler?) {
}
override fun send(p0: String, p1: ByteBuffer?) {
}
override fun send(p0: String, p1: ByteBuffer?, p2: BinaryMessenger.BinaryReply?) {
}
companion object {
val INSTANCE by lazy { CustomBinaryMessagerImpl() }
}
}
\ No newline at end of file
package com.ydl.ydl_flutter.flutter.base.plugin
package com.ydl.component.single
import android.text.TextUtils
import com.ydl.ydl_flutter.BuildConfig
import com.ydl.ydl_flutter.flutter.base.BaseFlutterFragment
import com.ydl.component.BuildConfig
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.common.tools.RxDeviceTool
import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterView
/**
* Created by xj on 2019/11/19.
*/
class CommonPlugin : MethodChannel.MethodCallHandler {
private var mActivity: FlutterActivity? = null
private var mFragment: BaseFlutterFragment? = null
private constructor(activity: FlutterActivity) {
mActivity = activity
}
private constructor(fragment: BaseFlutterFragment) {
mFragment = fragment
}
class YDLCommonPlugin : MethodChannel.MethodCallHandler {
companion object {
const val CHANNEL: String = "lib/common/channel"
const val GETPUBLICPARAMAS: String = "getPublicParamas"
fun rigisterActivity(activity: FlutterActivity, flutterView: FlutterView) {
MethodChannel(flutterView, CHANNEL).setMethodCallHandler(CommonPlugin(activity))
}
fun rigisterFragment(fragment: BaseFlutterFragment, flutterView: FlutterView) {
MethodChannel(flutterView, CHANNEL).setMethodCallHandler(CommonPlugin(fragment))
}
}
override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......
......@@ -75,7 +75,6 @@ dependencies {
//开发时使用
api project(':ydl-webview')
api project(':ydl-platform')
api project(":ydl-flutter-base")
implementation modularPublication('com.ydl:m-test-api')
implementation modularPublication('com.ydl:m-user-api')
}else {
......@@ -83,9 +82,6 @@ dependencies {
compileOnly rootProject.ext.dependencies["ydl-m-tests-api"]
compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
api rootProject.ext.dependencies["ydl-webview"]
api (rootProject.ext.dependencies["ydl-flutter-base"]){
transitive = true
}
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment