Skip to content

Commit

Permalink
Fixing the crash on the locale change because of missing dagger bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
kevalpatel2106 committed Sep 8, 2019
1 parent 4bf1272 commit f80ea5e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 50 deletions.
8 changes: 2 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,10 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_progress_list" />
</receiver>
<receiver android:name=".utils.BootCompleteReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".utils.LocaleChangedReceiver">
<receiver android:name=".utils.SysEventsReceiver">
<intent-filter>
<action android:name="android.intent.action.LOCALE_CHANGED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".notifications.ProgressNotificationReceiver" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.kevalpatel2106.yip.di

import com.kevalpatel2106.yip.notifications.ProgressNotificationReceiver
import com.kevalpatel2106.yip.utils.BootCompleteReceiver
import com.kevalpatel2106.yip.utils.SysEventsReceiver
import com.kevalpatel2106.yip.widget.ProgressListWidgetProvider
import dagger.Module
import dagger.android.ContributesAndroidInjector
Expand All @@ -13,7 +13,7 @@ internal abstract class BroadcastReceiverBindings {
internal abstract fun contributesProgressListWidgetProvider(): ProgressListWidgetProvider

@ContributesAndroidInjector
internal abstract fun contributesBootCompleteReceiver(): BootCompleteReceiver
internal abstract fun contributesBootCompleteReceiver(): SysEventsReceiver

@ContributesAndroidInjector
internal abstract fun contributesProgressNotificationReciver(): ProgressNotificationReceiver
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.kevalpatel2106.yip.utils

import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.kevalpatel2106.yip.notifications.ProgressNotificationReceiver
import com.kevalpatel2106.yip.repo.providers.AlarmProvider
import dagger.android.AndroidInjection
import javax.inject.Inject

internal class SysEventsReceiver : BroadcastReceiver() {

@Inject
internal lateinit var alarmProvider: AlarmProvider

@SuppressLint("UnsafeProtectedBroadcastReceiver")
override fun onReceive(context: Context, intent: Intent) {
if (intent.isValidIntent()) {
AndroidInjection.inject(this, context)
alarmProvider.updateAlarms(ProgressNotificationReceiver::class.java)
}
}

private fun Intent.isValidIntent(): Boolean {
return action == Intent.ACTION_BOOT_COMPLETED && action == Intent.ACTION_LOCALE_CHANGED
}
}

0 comments on commit f80ea5e

Please sign in to comment.