pull/2037/head
kunfei 2 years ago
parent d76013ed12
commit 98046a4313
  1. 16
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookViewModel.kt

@ -51,8 +51,20 @@ class RemoteBookViewModel(application: Application) : BaseViewModel(application)
Sort.Name -> list.sortedWith(compareBy({ !it.isDir }, { it.filename }))
else -> list.sortedWith(compareBy({ !it.isDir }, { it.lastModify }))
} else when (sortKey) {
Sort.Name -> list.sortedWith(compareBy({ it.isDir }, { it.filename })).reversed()
else -> list.sortedWith(compareBy({ it.isDir }, { it.lastModify })).reversed()
Sort.Name -> list.sortedWith { o1, o2 ->
val compare = -compareValues(o1.isDir, o2.isDir)
if (compare == 0) {
return@sortedWith -compareValues(o1.filename, o2.filename)
}
return@sortedWith compare
}
else -> list.sortedWith { o1, o2 ->
val compare = -compareValues(o1.isDir, o2.isDir)
if (compare == 0) {
return@sortedWith -compareValues(o1.lastModify, o2.lastModify)
}
return@sortedWith compare
}
}
}.flowOn(Dispatchers.IO)

Loading…
Cancel
Save