From 7ca9f6649e0c9878d7eca06e532311d5d1301389 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 30 Mar 2018 18:22:50 +0200 Subject: [PATCH] handle notification broadcast on a background thread --- .../calendar/receivers/NotificationReceiver.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/NotificationReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/NotificationReceiver.kt index 80aa2c733..3fb716f84 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/NotificationReceiver.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/NotificationReceiver.kt @@ -15,14 +15,20 @@ class NotificationReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager val wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Simple Calendar") - wakelock.acquire(5000) + wakelock.acquire(3000) - context.updateListWidget() + Thread { + handleIntent(context, intent) + }.start() + } + + private fun handleIntent(context: Context, intent: Intent) { val id = intent.getIntExtra(EVENT_ID, -1) if (id == -1) { return } + context.updateListWidget() val event = context.dbHelper.getEventWithId(id) if (event == null || event.getReminders().isEmpty()) { return