mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
77ec679448
commit
021e6bf400
@ -45,6 +45,7 @@ import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.math.max
|
||||
|
||||
|
||||
class BookshelfManageActivity :
|
||||
@ -197,6 +198,7 @@ class BookshelfManageActivity :
|
||||
private fun upBookDataByGroupId() {
|
||||
booksFlowJob?.cancel()
|
||||
booksFlowJob = launch {
|
||||
val bookSort = AppConfig.getBookSortByGroupId(viewModel.groupId)
|
||||
when (viewModel.groupId) {
|
||||
AppConst.rootGroupId -> appDb.bookDao.flowNetNoGroup()
|
||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||
@ -207,16 +209,23 @@ class BookshelfManageActivity :
|
||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
||||
else -> appDb.bookDao.flowByGroup(viewModel.groupId)
|
||||
}.conflate().map { list ->
|
||||
when (AppConfig.getBookSortByGroupId(viewModel.groupId)) {
|
||||
when (bookSort) {
|
||||
1 -> list.sortedByDescending {
|
||||
it.latestChapterTime
|
||||
}
|
||||
|
||||
2 -> list.sortedWith { o1, o2 ->
|
||||
o1.name.cnCompare(o2.name)
|
||||
}
|
||||
|
||||
3 -> list.sortedBy {
|
||||
it.order
|
||||
}
|
||||
|
||||
4 -> list.sortedByDescending {
|
||||
max(it.latestChapterTime, it.durChapterTime)
|
||||
}
|
||||
|
||||
else -> list.sortedByDescending {
|
||||
it.durChapterTime
|
||||
}
|
||||
@ -225,6 +234,7 @@ class BookshelfManageActivity :
|
||||
.conflate().collect {
|
||||
books = it
|
||||
upBookData()
|
||||
itemTouchCallback.isCanDrag = bookSort == 3
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,8 +273,10 @@ class BookshelfManageActivity :
|
||||
R.id.menu_del_selection -> alertDelSelection()
|
||||
R.id.menu_update_enable ->
|
||||
viewModel.upCanUpdate(adapter.selection, true)
|
||||
|
||||
R.id.menu_update_disable ->
|
||||
viewModel.upCanUpdate(adapter.selection, false)
|
||||
|
||||
R.id.menu_add_to_group -> selectGroup(addToGroupRequestCode, 0)
|
||||
R.id.menu_change_source -> showDialogFragment<SourcePickerDialog>()
|
||||
R.id.menu_check_selected_interval -> adapter.checkSelectedInterval()
|
||||
@ -314,11 +326,13 @@ class BookshelfManageActivity :
|
||||
}
|
||||
viewModel.updateBook(*array)
|
||||
}
|
||||
|
||||
adapter.groupRequestCode -> {
|
||||
adapter.actionItem?.let {
|
||||
viewModel.updateBook(it.copy(group = groupId))
|
||||
}
|
||||
}
|
||||
|
||||
addToGroupRequestCode -> adapter.selection.let { books ->
|
||||
val array = Array(books.size) { index ->
|
||||
val book = books[index]
|
||||
|
@ -154,11 +154,10 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
3 -> list.sortedBy { it.order }
|
||||
|
||||
// 综合排序 issue #3192
|
||||
4 -> {
|
||||
list.sortedByDescending {
|
||||
if(it.latestChapterTime>it.durChapterTime) it.latestChapterTime else it.durChapterTime
|
||||
}
|
||||
4 -> list.sortedByDescending {
|
||||
max(it.latestChapterTime, it.durChapterTime)
|
||||
}
|
||||
|
||||
else -> list.sortedByDescending { it.durChapterTime }
|
||||
}
|
||||
}.flowOn(Dispatchers.Default).catch {
|
||||
|
@ -98,7 +98,9 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
|
||||
searchView.onActionViewExpanded()
|
||||
searchView.isSubmitButtonEnabled = true
|
||||
searchView.queryHint = getString(R.string.screen_find)
|
||||
searchView.clearFocus()
|
||||
searchView.post {
|
||||
searchView.clearFocus()
|
||||
}
|
||||
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
return false
|
||||
|
@ -108,7 +108,9 @@ class RssFragment() : VMBaseFragment<RssViewModel>(R.layout.fragment_rss),
|
||||
searchView.onActionViewExpanded()
|
||||
searchView.isSubmitButtonEnabled = true
|
||||
searchView.queryHint = getString(R.string.rss)
|
||||
searchView.clearFocus()
|
||||
searchView.post {
|
||||
searchView.clearFocus()
|
||||
}
|
||||
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
return false
|
||||
|
@ -23,6 +23,7 @@
|
||||
<item>@string/bookshelf_px_1</item>
|
||||
<item>@string/bookshelf_px_2</item>
|
||||
<item>@string/bookshelf_px_3</item>
|
||||
<item>@string/bookshelf_px_4</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="indent">
|
||||
|
Loading…
Reference in New Issue
Block a user