소스 검색

添加初始化参数

ykrank 6 년 전
부모
커밋
e4e0668387
1개의 변경된 파일11개의 추가작업 그리고 9개의 파일을 삭제
  1. 11
    9
      android/src/main/kotlin/com/shuangyubang/mofun_flutter_plugin_video/MofunVideoView.kt

+ 11
- 9
android/src/main/kotlin/com/shuangyubang/mofun_flutter_plugin_video/MofunVideoView.kt 파일 보기

14
 
14
 
15
 const val Channel_Mofun_Video_Info = "plugins.shuangyunbang.mofun/mofunvideoview"
15
 const val Channel_Mofun_Video_Info = "plugins.shuangyunbang.mofun/mofunvideoview"
16
 
16
 
17
-class MofunVideoView(context: Context, messenger: BinaryMessenger, id: Int) : PlatformView, MethodChannel.MethodCallHandler {
17
+class MofunVideoView
18
+    : PlatformView, MethodChannel.MethodCallHandler {
18
 
19
 
19
-    private val textView: TextView = TextView(context).also {
20
-        it.setBackgroundColor(Color.BLUE)
21
-    }
22
-    private val methodChannel: MethodChannel = MethodChannel(messenger, Channel_Mofun_Video_Info + "_$id")
23
-            .also { it.setMethodCallHandler(this@MofunVideoView) }
20
+    private val textView: TextView
24
 
21
 
22
+    constructor(context: Context, messenger: BinaryMessenger, id: Int, creationParams: Any?) {
23
+        textView = TextView(context)
24
+        textView.setBackgroundColor(Color.BLUE)
25
+        MethodChannel(messenger, Channel_Mofun_Video_Info + "_$id").setMethodCallHandler(this)
26
+    }
25
 
27
 
26
     override fun getView(): View {
28
     override fun getView(): View {
27
         return textView
29
         return textView
38
         }
40
         }
39
     }
41
     }
40
 
42
 
41
-    private fun setText(methodCall: MethodCall, result:MethodChannel.Result) {
43
+    private fun setText(methodCall: MethodCall, result: MethodChannel.Result) {
42
         val text = methodCall.arguments as String
44
         val text = methodCall.arguments as String
43
         textView.text = text
45
         textView.text = text
44
         result.success(null)
46
         result.success(null)
48
 
50
 
49
 class MofunVideoViewFactory(val messenger: BinaryMessenger) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
51
 class MofunVideoViewFactory(val messenger: BinaryMessenger) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
50
 
52
 
51
-    override fun create(context: Context, id: Int, o: Any?): PlatformView {
52
-        return MofunVideoView(context, messenger, id)
53
+    override fun create(context: Context, id: Int, creationParams: Any?): PlatformView {
54
+        return MofunVideoView(context, messenger, id, creationParams)
53
     }
55
     }
54
 
56
 
55
 }
57
 }