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