|
|
|
@ -8,6 +8,7 @@ import androidx.fragment.app.Fragment |
|
|
|
|
import androidx.fragment.app.FragmentManager |
|
|
|
|
import androidx.fragment.app.FragmentStatePagerAdapter |
|
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
|
import androidx.lifecycle.observe |
|
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
|
import io.legado.app.App |
|
|
|
|
import io.legado.app.R |
|
|
|
@ -58,6 +59,11 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b |
|
|
|
|
initBookGroupData() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
|
super.onResume() |
|
|
|
|
adapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCompatCreateOptionsMenu(menu: Menu) { |
|
|
|
|
menuInflater.inflate(R.menu.main_bookshelf, menu) |
|
|
|
|
} |
|
|
|
@ -209,7 +215,14 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b |
|
|
|
|
FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { |
|
|
|
|
|
|
|
|
|
override fun getPageTitle(position: Int): CharSequence? { |
|
|
|
|
return bookGroups[position].groupName |
|
|
|
|
val group = bookGroups[position] |
|
|
|
|
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 { |
|
|
|
|