diff --git a/app/src/main/java/io/legado/app/constant/Bus.kt b/app/src/main/java/io/legado/app/constant/Bus.kt new file mode 100644 index 000000000..1dd73ab1a --- /dev/null +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -0,0 +1,5 @@ +package io.legado.app.constant + +object Bus { + val recreate = "recreate" +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index c48b510f4..8efcaca17 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -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) } } diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 7bd796f12..ae30e38c8 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -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(), BottomNavigationView.OnNavig } override fun observeLiveBus() { - LiveEventBus.get().with("recreate", String::class.java) + LiveEventBus.get().with(Bus.recreate, String::class.java) .observe(this, Observer { recreate() })