|
@@ -14,14 +14,16 @@ import io.flutter.plugin.platform.PlatformViewFactory
|
14
|
14
|
|
15
|
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
|
28
|
override fun getView(): View {
|
27
|
29
|
return textView
|
|
@@ -38,7 +40,7 @@ class MofunVideoView(context: Context, messenger: BinaryMessenger, id: Int) : Pl
|
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
|
44
|
val text = methodCall.arguments as String
|
43
|
45
|
textView.text = text
|
44
|
46
|
result.success(null)
|
|
@@ -48,8 +50,8 @@ class MofunVideoView(context: Context, messenger: BinaryMessenger, id: Int) : Pl
|
48
|
50
|
|
49
|
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
|
}
|