mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
baa1ebb140
commit
ff11cbe780
@ -6,6 +6,7 @@ import android.os.Build
|
||||
import io.legado.app.BuildConfig
|
||||
import io.legado.app.constant.AppConst
|
||||
import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.utils.*
|
||||
import splitties.init.appCtx
|
||||
|
||||
@ -388,6 +389,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefInt(PreferKey.bookshelfSort, value)
|
||||
}
|
||||
|
||||
fun getBookSortByGroupId(groupId: Long): Int {
|
||||
return appDb.bookGroupDao.getByID(groupId)?.getRealBookSort()
|
||||
?: bookshelfSort
|
||||
}
|
||||
|
||||
private fun getPrefUserAgent(): String {
|
||||
val ua = appCtx.getPrefString(PreferKey.userAgent)
|
||||
if (ua.isNullOrBlank()) {
|
||||
|
@ -165,7 +165,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
val booksDownload = books.filter {
|
||||
!it.isAudio
|
||||
}
|
||||
when (AppConfig.bookshelfSort) {
|
||||
when (AppConfig.getBookSortByGroupId(groupId)) {
|
||||
1 -> booksDownload.sortedByDescending { it.latestChapterTime }
|
||||
2 -> booksDownload.sortedWith { o1, o2 ->
|
||||
o1.name.cnCompare(o2.name)
|
||||
|
@ -195,7 +195,7 @@ class BookshelfManageActivity :
|
||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
||||
else -> appDb.bookDao.flowByGroup(viewModel.groupId)
|
||||
}.conflate().map { list ->
|
||||
when (AppConfig.bookshelfSort) {
|
||||
when (AppConfig.getBookSortByGroupId(viewModel.groupId)) {
|
||||
1 -> list.sortedByDescending {
|
||||
it.latestChapterTime
|
||||
}
|
||||
|
@ -133,10 +133,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
||||
else -> appDb.bookDao.flowByGroup(groupId)
|
||||
}.conflate().map { list ->
|
||||
when (
|
||||
appDb.bookGroupDao.getByID(groupId)?.getRealBookSort()
|
||||
?: AppConfig.bookshelfSort
|
||||
) {
|
||||
when (AppConfig.getBookSortByGroupId(groupId)) {
|
||||
1 -> list.sortedByDescending {
|
||||
it.latestChapterTime
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user