pull/32/head
gedoor 6 years ago
parent 292fb1edd2
commit f8ef9b2a86
  1. 5
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 3
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  3. 3
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -0,0 +1,5 @@
package io.legado.app.constant
object Bus {
val recreate = "recreate"
}

@ -9,6 +9,7 @@ import androidx.preference.PreferenceFragmentCompat
import com.jeremyliao.liveeventbus.LiveEventBus
import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.Bus
import io.legado.app.lib.theme.ColorUtils
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.getPrefBoolean
@ -85,7 +86,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
private fun upTheme(isNightTheme: Boolean) {
if (App.INSTANCE.getPrefBoolean("isNightTheme", false) == isNightTheme) {
App.INSTANCE.upThemeStore()
LiveEventBus.get().with("recreate").post("")
LiveEventBus.get().with(Bus.recreate).post("")
Handler().postDelayed({activity?.recreate()}, 300)
}
}

@ -12,6 +12,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
import com.jeremyliao.liveeventbus.LiveEventBus
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.constant.Bus
import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.help.storage.Restore
@ -87,7 +88,7 @@ class MainActivity : BaseActivity<MainViewModel>(), BottomNavigationView.OnNavig
}
override fun observeLiveBus() {
LiveEventBus.get().with("recreate", String::class.java)
LiveEventBus.get().with(Bus.recreate, String::class.java)
.observe(this, Observer {
recreate()
})

Loading…
Cancel
Save