From 3f2f5a5e1c8470c7286fbd5238c1718aaf17a4cc Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 1 Dec 2019 18:53:50 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + .../java/io/legado/app/ui/config/ConfigFragment.kt | 6 ++---- .../main/java/io/legado/app/ui/main/MainActivity.kt | 11 ++++++++++- .../main/java/io/legado/app/ui/main/my/MyFragment.kt | 1 - 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index ba75dea1f..7715d6623 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -8,4 +8,5 @@ object PreferKey { const val precisionSearch = "precisionSearch" const val prevKey = "prevKeyCode" const val nextKey = "nextKeyCode" + const val showRss = "showRss" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt index b7aa68e76..cee764420 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt @@ -15,10 +15,7 @@ import io.legado.app.help.BookHelp import io.legado.app.lib.theme.ATH import io.legado.app.receiver.SharedReceiverActivity import io.legado.app.ui.filechooser.FileChooserDialog -import io.legado.app.utils.LogUtils -import io.legado.app.utils.getPrefString -import io.legado.app.utils.putPrefBoolean -import io.legado.app.utils.putPrefString +import io.legado.app.utils.* class ConfigFragment : PreferenceFragmentCompat(), @@ -76,6 +73,7 @@ class ConfigFragment : PreferenceFragmentCompat(), "process_text" -> sharedPreferences?.let { setProcessTextEnable(it.getBoolean("process_text", true)) } + PreferKey.showRss -> postEvent(PreferKey.showRss, PreferKey.showRss) } } 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 7c976ef55..3268f8244 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 @@ -13,6 +13,7 @@ import io.legado.app.BuildConfig import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.Bus +import io.legado.app.constant.PreferKey import io.legado.app.help.ActivityHelp import io.legado.app.help.storage.Backup import io.legado.app.lib.theme.ATH @@ -45,7 +46,7 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), view_pager_main.adapter = TabFragmentPageAdapter(supportFragmentManager) view_pager_main.addOnPageChangeListener(this) bottom_navigation_view.setOnNavigationItemSelectedListener(this) - bottom_navigation_view.menu.findItem(R.id.menu_rss).isVisible = showRss() + upShowRss() upVersion() } @@ -59,6 +60,11 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), return false } + private fun upShowRss() { + bottom_navigation_view.menu.findItem(R.id.menu_rss).isVisible = showRss() + view_pager_main.adapter?.notifyDataSetChanged() + } + private fun upVersion() { if (getPrefInt("versionCode") != App.INSTANCE.versionCode) { putPrefInt("versionCode", App.INSTANCE.versionCode) @@ -122,6 +128,9 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), observeEvent(Bus.UP_CONFIG) { content_view.upStyle() } + observeEvent(PreferKey.showRss) { + upShowRss() + } } private fun showRss(): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 7f15b44a6..b2747f97e 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -87,7 +87,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) { "isNightTheme" -> App.INSTANCE.applyDayNight() "recordLog" -> LogUtils.upLevel() "downloadPath" -> BookHelp.upDownloadPath() - "showRss" -> activity?.recreate() } }