|
2 | 2 |
|
3 | 3 | import android.content.Context; |
4 | 4 |
|
| 5 | +import androidx.annotation.NonNull; |
| 6 | + |
5 | 7 | import io.flutter.embedding.engine.plugins.FlutterPlugin; |
6 | 8 | import io.flutter.plugin.common.MethodChannel; |
7 | 9 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; |
@@ -30,23 +32,28 @@ public void onAttachedToEngine(FlutterPluginBinding flutterPluginBinding) { |
30 | 32 | } |
31 | 33 |
|
32 | 34 | @Override |
33 | | - public void onDetachedFromEngine(FlutterPluginBinding flutterPluginBinding) { |
| 35 | + public void onDetachedFromEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { |
34 | 36 | channel.setMethodCallHandler(null); |
35 | 37 | applicationContext = null; |
36 | 38 | } |
37 | 39 |
|
38 | 40 | @Override |
39 | | - public void onMethodCall(MethodCall call, Result result) { |
40 | | - if (call.method.equals("updateBadgeCount")) { |
41 | | - ShortcutBadger.applyCount(applicationContext, Integer.valueOf(call.argument("count").toString())); |
42 | | - result.success(null); |
43 | | - } else if (call.method.equals("removeBadge")) { |
44 | | - ShortcutBadger.removeCount(applicationContext); |
45 | | - result.success(null); |
46 | | - } else if (call.method.equals("isAppBadgeSupported")) { |
47 | | - result.success(ShortcutBadger.isBadgeCounterSupported(applicationContext)); |
48 | | - } else { |
49 | | - result.notImplemented(); |
| 41 | + public void onMethodCall(MethodCall call, @NonNull Result result) { |
| 42 | + switch (call.method) { |
| 43 | + case "updateBadgeCount": |
| 44 | + ShortcutBadger.applyCount(applicationContext, Integer.valueOf(call.argument("count").toString())); |
| 45 | + result.success(null); |
| 46 | + break; |
| 47 | + case "removeBadge": |
| 48 | + ShortcutBadger.removeCount(applicationContext); |
| 49 | + result.success(null); |
| 50 | + break; |
| 51 | + case "isAppBadgeSupported": |
| 52 | + result.success(ShortcutBadger.isBadgeCounterSupported(applicationContext)); |
| 53 | + break; |
| 54 | + default: |
| 55 | + result.notImplemented(); |
| 56 | + break; |
50 | 57 | } |
51 | 58 | } |
52 | 59 | } |
0 commit comments