mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
1583f6c46c
commit
a74da4f968
@ -229,46 +229,46 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
||||
else -> {
|
||||
appDb.bookSourceDao.flowSearch("%$searchKey%")
|
||||
}
|
||||
}.collect { data ->
|
||||
val sourceList =
|
||||
if (sortAscending) when (sort) {
|
||||
Sort.Weight -> data.sortedBy { it.weight }
|
||||
Sort.Name -> data.sortedWith { o1, o2 ->
|
||||
o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||
}
|
||||
Sort.Url -> data.sortedBy { it.bookSourceUrl }
|
||||
Sort.Update -> data.sortedByDescending { it.lastUpdateTime }
|
||||
Sort.Respond -> data.sortedBy { it.respondTime }
|
||||
Sort.Enable -> data.sortedWith { o1, o2 ->
|
||||
var sort = -o1.enabled.compareTo(o2.enabled)
|
||||
if (sort == 0) {
|
||||
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||
}
|
||||
sort
|
||||
}
|
||||
else -> data
|
||||
}
|
||||
else when (sort) {
|
||||
Sort.Weight -> data.sortedByDescending { it.weight }
|
||||
Sort.Name -> data.sortedWith { o1, o2 ->
|
||||
o2.bookSourceName.cnCompare(o1.bookSourceName)
|
||||
}
|
||||
Sort.Url -> data.sortedByDescending { it.bookSourceUrl }
|
||||
Sort.Update -> data.sortedBy { it.lastUpdateTime }
|
||||
Sort.Respond -> data.sortedByDescending { it.respondTime }
|
||||
Sort.Enable -> data.sortedWith { o1, o2 ->
|
||||
var sort = o1.enabled.compareTo(o2.enabled)
|
||||
if (sort == 0) {
|
||||
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||
}
|
||||
sort
|
||||
}
|
||||
else -> data.reversed()
|
||||
}
|
||||
adapter.setItems(sourceList, adapter.diffItemCallback)
|
||||
}
|
||||
}.onFailure {
|
||||
AppLog.put("更新书源出错", it)
|
||||
}.getOrNull()?.collect { data ->
|
||||
val sourceList =
|
||||
if (sortAscending) when (sort) {
|
||||
Sort.Weight -> data.sortedBy { it.weight }
|
||||
Sort.Name -> data.sortedWith { o1, o2 ->
|
||||
o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||
}
|
||||
Sort.Url -> data.sortedBy { it.bookSourceUrl }
|
||||
Sort.Update -> data.sortedByDescending { it.lastUpdateTime }
|
||||
Sort.Respond -> data.sortedBy { it.respondTime }
|
||||
Sort.Enable -> data.sortedWith { o1, o2 ->
|
||||
var sort = -o1.enabled.compareTo(o2.enabled)
|
||||
if (sort == 0) {
|
||||
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||
}
|
||||
sort
|
||||
}
|
||||
else -> data
|
||||
}
|
||||
else when (sort) {
|
||||
Sort.Weight -> data.sortedByDescending { it.weight }
|
||||
Sort.Name -> data.sortedWith { o1, o2 ->
|
||||
o2.bookSourceName.cnCompare(o1.bookSourceName)
|
||||
}
|
||||
Sort.Url -> data.sortedByDescending { it.bookSourceUrl }
|
||||
Sort.Update -> data.sortedBy { it.lastUpdateTime }
|
||||
Sort.Respond -> data.sortedByDescending { it.respondTime }
|
||||
Sort.Enable -> data.sortedWith { o1, o2 ->
|
||||
var sort = o1.enabled.compareTo(o2.enabled)
|
||||
if (sort == 0) {
|
||||
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||
}
|
||||
sort
|
||||
}
|
||||
else -> data.reversed()
|
||||
}
|
||||
adapter.setItems(sourceList, adapter.diffItemCallback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user