1212import android .os .Looper ;
1313import android .util .Log ;
1414
15+ import androidx .annotation .NonNull ;
16+
1517import io .flutter .embedding .engine .plugins .FlutterPlugin ;
1618import io .flutter .plugin .common .MethodCall ;
1719import io .flutter .plugin .common .MethodChannel ;
1820import io .flutter .plugin .common .MethodChannel .MethodCallHandler ;
1921import io .flutter .plugin .common .MethodChannel .Result ;
20- import io .flutter .plugin .common .PluginRegistry .Registrar ;
2122
2223import com .adjust .test .ICommandJsonListener ;
2324import com .adjust .test .TestLibrary ;
@@ -30,50 +31,23 @@ public class TestLibPlugin implements FlutterPlugin, MethodCallHandler {
3031 private static String TAG = "TestLibPlugin" ;
3132 private TestLibrary testLibrary = null ;
3233 private MethodChannel channel ;
33- private boolean v2Plugin ;
34- private boolean v2Attached = false ;
35-
36- private TestLibPlugin (MethodChannel channel ) {
37- this .channel = channel ;
3834
39- v2Plugin = false ;
40- }
35+ public TestLibPlugin () {}
4136
42- public TestLibPlugin () {
43- v2Plugin = true ;
44- }
45-
46- // FlutterPlugin
4737 @ 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 ) {
5839 channel = new MethodChannel (binding .getBinaryMessenger (), "com.adjust.test.lib/api" );
5940 channel .setMethodCallHandler (this );
6041 }
6142
6243 @ Override
63- public void onDetachedFromEngine (FlutterPluginBinding binding ) {
64- v2Attached = false ;
44+ public void onDetachedFromEngine (@ NonNull FlutterPluginBinding binding ) {
6545 if (channel != null ) {
6646 channel .setMethodCallHandler (null );
6747 }
6848 channel = null ;
6949 }
7050
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-
7751 @ Override
7852 public void onMethodCall (MethodCall call , Result result ) {
7953 switch (call .method ) {
0 commit comments