handle notification broadcast on a background thread
This commit is contained in:
parent
a7dd568793
commit
7ca9f6649e
|
@ -15,14 +15,20 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||||
val wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Simple Calendar")
|
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)
|
val id = intent.getIntExtra(EVENT_ID, -1)
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.updateListWidget()
|
||||||
val event = context.dbHelper.getEventWithId(id)
|
val event = context.dbHelper.getEventWithId(id)
|
||||||
if (event == null || event.getReminders().isEmpty()) {
|
if (event == null || event.getReminders().isEmpty()) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue