From 55d7152ba22731b59613bf55fc491c9104713ce5 Mon Sep 17 00:00:00 2001 From: Aljosa Koren Date: Tue, 20 Jul 2021 13:34:55 +0200 Subject: [PATCH 1/3] Fix failure to register background callback #27 --- .../main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt b/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt index f793e963..f8a92c7e 100644 --- a/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt +++ b/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt @@ -101,8 +101,8 @@ class HomeWidgetPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, } } "registerBackgroundCallback" -> { - val dispatcher = (call.arguments as Iterable<*>).toList()[0] as Long - val callback = (call.arguments as Iterable<*>).toList()[1] as Long + val dispatcher = (call.arguments as Iterable<*>).toList()[0].toString().toLong() + val callback = (call.arguments as Iterable<*>).toList()[1].toString().toLong() saveCallbackHandle(context, dispatcher, callback) return result.success(true) } From 35cab7444dd34e2af260533aa940cc27c0b2cf8d Mon Sep 17 00:00:00 2001 From: aljkor Date: Tue, 20 Jul 2021 14:28:32 +0200 Subject: [PATCH 2/3] Casting with Number --- .../kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt b/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt index f8a92c7e..915c8b1b 100644 --- a/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt +++ b/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt @@ -101,9 +101,9 @@ class HomeWidgetPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, } } "registerBackgroundCallback" -> { - val dispatcher = (call.arguments as Iterable<*>).toList()[0].toString().toLong() - val callback = (call.arguments as Iterable<*>).toList()[1].toString().toLong() - saveCallbackHandle(context, dispatcher, callback) + val dispatcher = (call.arguments as Iterable<*>).toList()[0] as Number + val callback = (call.arguments as Iterable<*>).toList()[1] as Number + saveCallbackHandle(context, dispatcher.toLong(), callback.toLong()) return result.success(true) } else -> { From 6d9ef348dd4401942a1417235234176e240bc924 Mon Sep 17 00:00:00 2001 From: aljkor Date: Tue, 20 Jul 2021 14:34:27 +0200 Subject: [PATCH 3/3] Update android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt Co-authored-by: Anton Borries --- .../kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt b/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt index 915c8b1b..25b6a655 100644 --- a/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt +++ b/android/src/main/kotlin/es/antonborri/home_widget/HomeWidgetPlugin.kt @@ -101,9 +101,9 @@ class HomeWidgetPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, } } "registerBackgroundCallback" -> { - val dispatcher = (call.arguments as Iterable<*>).toList()[0] as Number - val callback = (call.arguments as Iterable<*>).toList()[1] as Number - saveCallbackHandle(context, dispatcher.toLong(), callback.toLong()) + val dispatcher = ((call.arguments as Iterable<*>).toList()[0] as Number).toLong() + val callback = ((call.arguments as Iterable<*>).toList()[1] as Number).toLong() + saveCallbackHandle(context, dispatcher, callback) return result.success(true) } else -> {