mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
commit
42e004fed5
@ -91,6 +91,13 @@ class BookshelfFragment1() : BaseBookshelfFragment(R.layout.fragment_bookshelf1)
|
||||
if (data != bookGroups) {
|
||||
bookGroups.clear()
|
||||
bookGroups.addAll(data)
|
||||
/**
|
||||
* 在书架布局对话框修改排序后,会导致书架页面刷新。但是在分组标签未修改的情况下,此处的adapter.notifyDataSetChanged()调用不会引起
|
||||
* [io.legado.app.ui.main.bookshelf.style1.BookshelfFragment1.TabFragmentPageAdapter.getItemPosition]
|
||||
* 被调用。
|
||||
* 有关方法:
|
||||
* [androidx.viewpager.widget.ViewPager.dataSetChanged]
|
||||
*/
|
||||
adapter.notifyDataSetChanged()
|
||||
selectLastTab()
|
||||
for (i in 0 until adapter.count) {
|
||||
|
@ -41,8 +41,11 @@ import kotlin.math.max
|
||||
class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
BaseBooksAdapter.CallBack {
|
||||
|
||||
lateinit var group: BookGroup
|
||||
|
||||
constructor(position: Int, group: BookGroup) : this() {
|
||||
val bundle = Bundle()
|
||||
this.group = group
|
||||
bundle.putInt("position", position)
|
||||
bundle.putLong("groupId", group.groupId)
|
||||
bundle.putInt("bookSort", group.getRealBookSort())
|
||||
@ -80,6 +83,9 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
bookSort = it.getInt("bookSort", 0)
|
||||
binding.refreshLayout.isEnabled = it.getBoolean("enableRefresh", true)
|
||||
}
|
||||
appDb.bookGroupDao.getByID(groupId)?.apply {
|
||||
group = this
|
||||
}
|
||||
initRecyclerView()
|
||||
upRecyclerData()
|
||||
}
|
||||
@ -129,6 +135,9 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
binding.refreshLayout.isEnabled = enableRefresh
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新书籍列表信息
|
||||
*/
|
||||
private fun upRecyclerData() {
|
||||
booksFlowJob?.cancel()
|
||||
booksFlowJob = launch {
|
||||
@ -140,13 +149,22 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
||||
else -> appDb.bookDao.flowByGroup(groupId)
|
||||
// 书籍排序
|
||||
}.conflate().map { list ->
|
||||
when (bookSort) {
|
||||
1 -> list.sortedByDescending { it.latestChapterTime }
|
||||
2 -> list.sortedWith { o1, o2 ->
|
||||
o1.name.cnCompare(o2.name)
|
||||
}
|
||||
|
||||
3 -> list.sortedBy { it.order }
|
||||
|
||||
// 综合排序 issue #3192
|
||||
4 -> {
|
||||
list.sortedByDescending {
|
||||
if(it.latestChapterTime>it.durChapterTime) it.latestChapterTime else it.durChapterTime
|
||||
}
|
||||
}
|
||||
else -> list.sortedByDescending { it.durChapterTime }
|
||||
}
|
||||
}.flowOn(Dispatchers.Default).catch {
|
||||
@ -181,6 +199,9 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (::group.isInitialized) {
|
||||
bookSort = group.getRealBookSort()
|
||||
}
|
||||
startLastUpdateTimeJob()
|
||||
upRecyclerData()
|
||||
}
|
||||
@ -244,6 +265,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
startActivity<AudioPlayActivity> {
|
||||
putExtra("bookUrl", book.bookUrl)
|
||||
}
|
||||
|
||||
else -> startActivity<ReadBookActivity> {
|
||||
putExtra("bookUrl", book.bookUrl)
|
||||
}
|
||||
|
@ -159,6 +159,12 @@
|
||||
android:text="@string/bookshelf_px_3"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/bookshelf_px_4"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -1120,4 +1120,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
</resources>
|
||||
|
@ -1123,4 +1123,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
</resources>
|
||||
|
@ -1123,4 +1123,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
</resources>
|
||||
|
@ -1119,4 +1119,5 @@ Còn </string>
|
||||
<string name="add_all_to_bookshelf">Thêm tất cả vào giá sách</string>
|
||||
<string name="page_to">Trang tới</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
</resources>
|
@ -1120,4 +1120,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">解析示例</string>
|
||||
<string name="bookshelf_px_4" >綜合排序</string>
|
||||
</resources>
|
||||
|
@ -1122,4 +1122,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">解析示例</string>
|
||||
<string name="bookshelf_px_4" >綜合排序</string>
|
||||
</resources>
|
||||
|
@ -1122,4 +1122,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">解析示例</string>
|
||||
<string name="bookshelf_px_4" >综合排序</string>
|
||||
</resources>
|
||||
|
@ -1123,4 +1123,5 @@
|
||||
<string name="add_all_to_bookshelf">全部加入书架</string>
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user