pull/2692/head
kunfei 2 years ago
parent baa1ebb140
commit ff11cbe780
  1. 6
      app/src/main/java/io/legado/app/help/config/AppConfig.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt
  4. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt

@ -6,6 +6,7 @@ import android.os.Build
import io.legado.app.BuildConfig import io.legado.app.BuildConfig
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.utils.* import io.legado.app.utils.*
import splitties.init.appCtx import splitties.init.appCtx
@ -388,6 +389,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefInt(PreferKey.bookshelfSort, value) appCtx.putPrefInt(PreferKey.bookshelfSort, value)
} }
fun getBookSortByGroupId(groupId: Long): Int {
return appDb.bookGroupDao.getByID(groupId)?.getRealBookSort()
?: bookshelfSort
}
private fun getPrefUserAgent(): String { private fun getPrefUserAgent(): String {
val ua = appCtx.getPrefString(PreferKey.userAgent) val ua = appCtx.getPrefString(PreferKey.userAgent)
if (ua.isNullOrBlank()) { if (ua.isNullOrBlank()) {

@ -165,7 +165,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
val booksDownload = books.filter { val booksDownload = books.filter {
!it.isAudio !it.isAudio
} }
when (AppConfig.bookshelfSort) { when (AppConfig.getBookSortByGroupId(groupId)) {
1 -> booksDownload.sortedByDescending { it.latestChapterTime } 1 -> booksDownload.sortedByDescending { it.latestChapterTime }
2 -> booksDownload.sortedWith { o1, o2 -> 2 -> booksDownload.sortedWith { o1, o2 ->
o1.name.cnCompare(o2.name) o1.name.cnCompare(o2.name)

@ -195,7 +195,7 @@ 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.bookshelfSort) { when (AppConfig.getBookSortByGroupId(viewModel.groupId)) {
1 -> list.sortedByDescending { 1 -> list.sortedByDescending {
it.latestChapterTime it.latestChapterTime
} }

@ -133,10 +133,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError() AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
else -> appDb.bookDao.flowByGroup(groupId) else -> appDb.bookDao.flowByGroup(groupId)
}.conflate().map { list -> }.conflate().map { list ->
when ( when (AppConfig.getBookSortByGroupId(groupId)) {
appDb.bookGroupDao.getByID(groupId)?.getRealBookSort()
?: AppConfig.bookshelfSort
) {
1 -> list.sortedByDescending { 1 -> list.sortedByDescending {
it.latestChapterTime it.latestChapterTime
} }

Loading…
Cancel
Save