修复了同时更改书架布局的分组样式和视图后崩溃闪退的问题
This commit is contained in:
adhu2018
2023-09-01 11:02:08 +08:00
parent 01549e2e6d
commit d3681bedf6
3 changed files with 8 additions and 2 deletions
@@ -137,6 +137,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefInt(PreferKey.bookGroupStyle, value) appCtx.putPrefInt(PreferKey.bookGroupStyle, value)
} }
var bookshelfLayout: Int
get() = appCtx.getPrefInt(PreferKey.bookshelfLayout, 0)
set(value) {
appCtx.putPrefInt(PreferKey.bookshelfLayout, value)
}
var bookExportFileName: String? var bookExportFileName: String?
get() = appCtx.getPrefString(PreferKey.bookExportFileName) get() = appCtx.getPrefString(PreferKey.bookExportFileName)
set(value) { set(value) {
@@ -173,7 +173,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
upSort() upSort()
} }
if (bookshelfLayout != rgLayout.getCheckedIndex()) { if (bookshelfLayout != rgLayout.getCheckedIndex()) {
putPrefInt(PreferKey.bookshelfLayout, rgLayout.getCheckedIndex()) AppConfig.bookshelfLayout = rgLayout.getCheckedIndex()
postEvent(EventBus.RECREATE, "") postEvent(EventBus.RECREATE, "")
} }
} }
@@ -109,7 +109,7 @@ class BookshelfFragment1() : BaseBookshelfFragment(R.layout.fragment_bookshelf1)
private fun selectLastTab() { private fun selectLastTab() {
tabLayout.post { tabLayout.post {
tabLayout.removeOnTabSelectedListener(this) tabLayout.removeOnTabSelectedListener(this)
tabLayout.getTabAt(getPrefInt(PreferKey.saveTabPosition, 0))?.select() tabLayout.getTabAt(0)?.select()
tabLayout.addOnTabSelectedListener(this) tabLayout.addOnTabSelectedListener(this)
} }
} }