Skip to content

Commit

Permalink
trying to fix crash...
Browse files Browse the repository at this point in the history
  • Loading branch information
kelmer44 committed Nov 20, 2020
1 parent d47bb55 commit 5b5d713
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def versionMajor = 2
def versionMinor = 0
def versionPatch = 1
def versionBuild = 5
def versionPatch = 2
def versionBuild = 0

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ class MainActivity : BaseActivity(R.layout.activity_main) {
super.onCreate(savedInstanceState)
initWorker()
}
val themeObserver = Observer<Int> { t ->
if (t != null) {
AppCompatDelegate.setDefaultNightMode(t)
}
}

private fun initWorker() {
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
Expand All @@ -52,6 +48,16 @@ class MainActivity : BaseActivity(R.layout.activity_main) {
WorkManager.getInstance(this).enqueueUniquePeriodicWork(CorreosApp.PARCEL_CHECKER_WORKREQUEST, ExistingPeriodicWorkPolicy.REPLACE, uploadWorker)


sharedPrefsManager.themeModeLive.observe(this, themeObserver)
sharedPrefsManager.themeModeLive.observe(this, ThemeObserver())
}


inner class ThemeObserver : Observer<Int> {
override fun onChanged(t: Int?) {
if (t != null) {
AppCompatDelegate.setDefaultNightMode(t)
}
}
}
}

0 comments on commit 5b5d713

Please sign in to comment.