From b7023fd4f8c9c8042a25fe95f45e6433ca4847b0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 25 Jan 2020 19:48:07 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/main/bookshelf/BookshelfFragment.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 5b946d74d..54d7e71d4 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -37,6 +37,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b override val viewModel: BookshelfViewModel get() = getViewModel(BookshelfViewModel::class.java) + lateinit var bookshelfAdapter: BookshelfAdapter private var bookGroupLiveData: LiveData>? = null private val bookGroups = mutableListOf() @@ -79,7 +80,8 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b tab_layout.tabMode = TabLayout.MODE_SCROLLABLE tab_layout.setSelectedTabIndicatorColor(requireContext().accentColor) ATH.applyEdgeEffectColor(view_pager_bookshelf) - view_pager_bookshelf.adapter = BookshelfAdapter(this, this) + bookshelfAdapter = BookshelfAdapter(this, this) + view_pager_bookshelf.adapter = bookshelfAdapter TabLayoutMediator(tab_layout, view_pager_bookshelf) { tab, position -> tab.text = bookGroups[position].groupName }.attach() @@ -103,7 +105,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b bookGroups.add(AppConst.bookGroupAudio) } bookGroups.addAll(it) - view_pager_bookshelf.adapter?.notifyDataSetChanged() + bookshelfAdapter.notifyDataSetChanged() tab_layout.getTabAt(getPrefInt(PreferKey.saveTabPosition, 0))?.select() tab_layout.addOnTabSelectedListener(this) }