Revert "书架显示书籍数量"

This reverts commit 2ecd94ff
pull/457/head
口口吕 4 years ago
parent 70e9423ee8
commit f60b0890b1
  1. 2
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 15
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt

@ -45,7 +45,7 @@ interface BookDao {
@get:Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0") @get:Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0")
val noGroupSize: Int val noGroupSize: Int
@Query("select count(bookUrl) from books where `group` = :groupId") @Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = :groupId")
fun groupCount(groupId: Long): Int fun groupCount(groupId: Long): Int
@get:Query("SELECT count(*) FROM books where origin = '${BookType.local}'") @get:Query("SELECT count(*) FROM books where origin = '${BookType.local}'")

@ -8,7 +8,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.observe
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
@ -59,11 +58,6 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
initBookGroupData() initBookGroupData()
} }
override fun onResume() {
super.onResume()
adapter.notifyDataSetChanged()
}
override fun onCompatCreateOptionsMenu(menu: Menu) { override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.main_bookshelf, menu) menuInflater.inflate(R.menu.main_bookshelf, menu)
} }
@ -218,14 +212,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
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? {
val group = bookGroups[position] return bookGroups[position].groupName
return "${group.groupName}${when (group.groupId) {
AppConst.bookGroupAllId -> "${App.db.bookDao().allBookCount}"
AppConst.bookGroupLocalId -> "${App.db.bookDao().localBookCount}"
AppConst.bookGroupAudioId -> "${App.db.bookDao().audioBookCount}"
AppConst.bookGroupNoneId -> "${App.db.bookDao().noneBookCount}"
else -> "${App.db.bookDao().groupCount(group.groupId)}"
}}"
} }
override fun getItemPosition(`object`: Any): Int { override fun getItemPosition(`object`: Any): Int {

Loading…
Cancel
Save