pull/341/head
gedoor 4 years ago
parent 4246bcd27d
commit fdd625cd33
  1. 7
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt

@ -11,7 +11,6 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -114,7 +113,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
private fun initBookGroupData() { private fun initBookGroupData() {
bookGroupLiveData?.removeObservers(viewLifecycleOwner) bookGroupLiveData?.removeObservers(viewLifecycleOwner)
bookGroupLiveData = App.db.bookGroupDao().liveDataAll() bookGroupLiveData = App.db.bookGroupDao().liveDataAll()
bookGroupLiveData?.observe(viewLifecycleOwner, Observer { bookGroupLiveData?.observe(viewLifecycleOwner, {
viewModel.checkGroup(it) viewModel.checkGroup(it)
launch { launch {
synchronized(this) { synchronized(this) {
@ -152,7 +151,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
}) })
noGroupLiveData?.removeObservers(viewLifecycleOwner) noGroupLiveData?.removeObservers(viewLifecycleOwner)
noGroupLiveData = App.db.bookDao().observeNoGroupSize() noGroupLiveData = App.db.bookDao().observeNoGroupSize()
noGroupLiveData?.observe(viewLifecycleOwner, Observer { noGroupLiveData?.observe(viewLifecycleOwner, {
if (it > 0 && !showGroupNone && AppConfig.bookGroupNoneShow) { if (it > 0 && !showGroupNone && AppConfig.bookGroupNoneShow) {
showGroupNone = true showGroupNone = true
upGroup() upGroup()
@ -270,7 +269,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
fragmentMap[selectedGroup?.groupId]?.gotoTop() fragmentMap[selectedGroup?.groupId]?.gotoTop()
} }
private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : private inner class TabFragmentPageAdapter(fm: FragmentManager) :
FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getPageTitle(position: Int): CharSequence? { override fun getPageTitle(position: Int): CharSequence? {

Loading…
Cancel
Save