12
12
import android .os .Looper ;
13
13
import android .util .Log ;
14
14
15
+ import androidx .annotation .NonNull ;
16
+
15
17
import io .flutter .embedding .engine .plugins .FlutterPlugin ;
16
18
import io .flutter .plugin .common .MethodCall ;
17
19
import io .flutter .plugin .common .MethodChannel ;
18
20
import io .flutter .plugin .common .MethodChannel .MethodCallHandler ;
19
21
import io .flutter .plugin .common .MethodChannel .Result ;
20
- import io .flutter .plugin .common .PluginRegistry .Registrar ;
21
22
22
23
import com .adjust .test .ICommandJsonListener ;
23
24
import com .adjust .test .TestLibrary ;
@@ -30,50 +31,23 @@ public class TestLibPlugin implements FlutterPlugin, MethodCallHandler {
30
31
private static String TAG = "TestLibPlugin" ;
31
32
private TestLibrary testLibrary = null ;
32
33
private MethodChannel channel ;
33
- private boolean v2Plugin ;
34
- private boolean v2Attached = false ;
35
-
36
- private TestLibPlugin (MethodChannel channel ) {
37
- this .channel = channel ;
38
34
39
- v2Plugin = false ;
40
- }
35
+ public TestLibPlugin () {}
41
36
42
- public TestLibPlugin () {
43
- v2Plugin = true ;
44
- }
45
-
46
- // FlutterPlugin
47
37
@ Override
48
- public void onAttachedToEngine (FlutterPluginBinding binding ) {
49
- if (!v2Plugin ) {
50
- return ;
51
- }
52
- if (v2Attached ) {
53
- return ;
54
- }
55
-
56
- v2Attached = true ;
57
-
38
+ public void onAttachedToEngine (@ NonNull FlutterPluginBinding binding ) {
58
39
channel = new MethodChannel (binding .getBinaryMessenger (), "com.adjust.test.lib/api" );
59
40
channel .setMethodCallHandler (this );
60
41
}
61
42
62
43
@ Override
63
- public void onDetachedFromEngine (FlutterPluginBinding binding ) {
64
- v2Attached = false ;
44
+ public void onDetachedFromEngine (@ NonNull FlutterPluginBinding binding ) {
65
45
if (channel != null ) {
66
46
channel .setMethodCallHandler (null );
67
47
}
68
48
channel = null ;
69
49
}
70
50
71
- // Plugin registration.
72
- public static void registerWith (Registrar registrar ) {
73
- final MethodChannel channel = new MethodChannel (registrar .messenger (), "com.adjust.test.lib/api" );
74
- channel .setMethodCallHandler (new TestLibPlugin (channel ));
75
- }
76
-
77
51
@ Override
78
52
public void onMethodCall (MethodCall call , Result result ) {
79
53
switch (call .method ) {
0 commit comments