diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 78915a534..3f6873a44 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -28,6 +28,7 @@ abstract class BaseActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(layoutID) onViewModelCreated(viewModel, savedInstanceState) + observeLiveBus() } abstract fun onViewModelCreated(viewModel: VM, savedInstanceState: Bundle?) @@ -59,7 +60,7 @@ abstract class BaseActivity : AppCompatActivity() { return super.onOptionsItemSelected(item) } - protected fun initTheme() { + private fun initTheme() { window.decorView.setBackgroundColor(ThemeStore.backgroundColor(this)) if (ColorUtils.isColorLight(ThemeStore.primaryColor(this))) { setTheme(R.style.AppTheme_Light) @@ -68,7 +69,7 @@ abstract class BaseActivity : AppCompatActivity() { } } - protected fun setupSystemBar() { + private fun setupSystemBar() { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) @@ -78,4 +79,8 @@ abstract class BaseActivity : AppCompatActivity() { window.statusBarColor = getCompatColor(R.color.status_bar_bag) } } + + open fun observeLiveBus() { + + } } \ No newline at end of file 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 775523d59..7bd796f12 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 @@ -36,7 +36,6 @@ class MainActivity : BaseActivity(), BottomNavigationView.OnNavig view_pager_main.adapter = TabFragmentPageAdapter(supportFragmentManager) view_pager_main.addOnPageChangeListener(this) bottom_navigation_view.setOnNavigationItemSelectedListener(this) - observeLiveBus() } override fun onNavigationItemSelected(item: MenuItem): Boolean { @@ -87,7 +86,7 @@ class MainActivity : BaseActivity(), BottomNavigationView.OnNavig } } - private fun observeLiveBus() { + override fun observeLiveBus() { LiveEventBus.get().with("recreate", String::class.java) .observe(this, Observer { recreate()