diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 473dba4f1..d33213e6e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -249,7 +249,7 @@
android:screenOrientation="behind" />
diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt
index d8c5b2d00..aed422165 100644
--- a/app/src/main/java/io/legado/app/constant/AppConst.kt
+++ b/app/src/main/java/io/legado/app/constant/AppConst.kt
@@ -39,6 +39,7 @@ object AppConst {
SimpleDateFormat("yy-MM-dd-HH-mm-ss")
}
+ const val rootGroupId = -100L
const val bookGroupAllId = -1L
const val bookGroupLocalId = -2L
const val bookGroupAudioId = -3L
diff --git a/app/src/main/java/io/legado/app/ui/book/management/BookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/manage/BookAdapter.kt
similarity index 99%
rename from app/src/main/java/io/legado/app/ui/book/management/BookAdapter.kt
rename to app/src/main/java/io/legado/app/ui/book/manage/BookAdapter.kt
index 2aa3f43b3..a7564cf5b 100644
--- a/app/src/main/java/io/legado/app/ui/book/management/BookAdapter.kt
+++ b/app/src/main/java/io/legado/app/ui/book/manage/BookAdapter.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.management
+package io.legado.app.ui.book.manage
import android.annotation.SuppressLint
import android.content.Context
diff --git a/app/src/main/java/io/legado/app/ui/book/management/BookshelfManageActivity.kt b/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt
similarity index 95%
rename from app/src/main/java/io/legado/app/ui/book/management/BookshelfManageActivity.kt
rename to app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt
index 4cd6bc476..e60b27d85 100644
--- a/app/src/main/java/io/legado/app/ui/book/management/BookshelfManageActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.management
+package io.legado.app.ui.book.manage
import android.annotation.SuppressLint
import android.os.Bundle
@@ -140,6 +140,7 @@ class BookshelfManageActivity :
booksFlowJob?.cancel()
booksFlowJob = launch {
when (groupId) {
+ AppConst.rootGroupId -> appDb.bookDao.flowNoGroup()
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
@@ -147,12 +148,18 @@ class BookshelfManageActivity :
else -> appDb.bookDao.flowByGroup(groupId)
}.conflate().map { books ->
when (getPrefInt(PreferKey.bookshelfSort)) {
- 1 -> books.sortedByDescending { it.latestChapterTime }
+ 1 -> books.sortedByDescending {
+ it.latestChapterTime
+ }
2 -> books.sortedWith { o1, o2 ->
o1.name.cnCompare(o2.name)
}
- 3 -> books.sortedBy { it.order }
- else -> books.sortedByDescending { it.durChapterTime }
+ 3 -> books.sortedBy {
+ it.order
+ }
+ else -> books.sortedByDescending {
+ it.durChapterTime
+ }
}
}.conflate().collect { books ->
adapter.setItems(books)
diff --git a/app/src/main/java/io/legado/app/ui/book/management/BookshelfManageViewModel.kt b/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt
similarity index 97%
rename from app/src/main/java/io/legado/app/ui/book/management/BookshelfManageViewModel.kt
rename to app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt
index 17c1cfbd2..c404851e3 100644
--- a/app/src/main/java/io/legado/app/ui/book/management/BookshelfManageViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.management
+package io.legado.app.ui.book.manage
import android.app.Application
import androidx.compose.runtime.mutableStateOf
diff --git a/app/src/main/java/io/legado/app/ui/book/management/ComposeView.kt b/app/src/main/java/io/legado/app/ui/book/manage/ComposeView.kt
similarity index 97%
rename from app/src/main/java/io/legado/app/ui/book/management/ComposeView.kt
rename to app/src/main/java/io/legado/app/ui/book/manage/ComposeView.kt
index 01b2d2bf9..ffa57baa2 100644
--- a/app/src/main/java/io/legado/app/ui/book/management/ComposeView.kt
+++ b/app/src/main/java/io/legado/app/ui/book/manage/ComposeView.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.management
+package io.legado.app.ui.book.manage
import androidx.compose.foundation.layout.Column
import androidx.compose.material.AlertDialog
diff --git a/app/src/main/java/io/legado/app/ui/book/management/SourcePickerDialog.kt b/app/src/main/java/io/legado/app/ui/book/manage/SourcePickerDialog.kt
similarity index 98%
rename from app/src/main/java/io/legado/app/ui/book/management/SourcePickerDialog.kt
rename to app/src/main/java/io/legado/app/ui/book/manage/SourcePickerDialog.kt
index 01c4c088b..1be0837dc 100644
--- a/app/src/main/java/io/legado/app/ui/book/management/SourcePickerDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/book/manage/SourcePickerDialog.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.management
+package io.legado.app.ui.book.manage
import android.content.Context
import android.os.Bundle
diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
index 739a2c111..78d16eb92 100644
--- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
@@ -22,7 +22,7 @@ import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.book.cache.CacheActivity
import io.legado.app.ui.book.group.GroupManageDialog
import io.legado.app.ui.book.local.ImportBookActivity
-import io.legado.app.ui.book.management.BookshelfManageActivity
+import io.legado.app.ui.book.manage.BookshelfManageActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.main.MainViewModel
diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
index 6cd545f29..cfa2c4304 100644
--- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
+++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
@@ -43,7 +43,6 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
BaseBooksAdapter.CallBack {
private val binding by viewBinding(FragmentBookshelf1Binding::bind)
- private val rootGroupId = -100L
private val bookshelfLayout by lazy {
getPrefInt(PreferKey.bookshelfLayout)
}
@@ -56,7 +55,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
}
private var bookGroups: List = emptyList()
private var booksFlowJob: Job? = null
- override var groupId = rootGroupId
+ override var groupId = AppConst.rootGroupId
override var books: List = emptyList()
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
@@ -121,7 +120,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
booksFlowJob?.cancel()
booksFlowJob = launch {
when (groupId) {
- rootGroupId -> appDb.bookDao.flowRoot()
+ AppConst.rootGroupId -> appDb.bookDao.flowRoot()
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
@@ -212,7 +211,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
}
override fun getItemCount(): Int {
- return if (groupId == rootGroupId) {
+ return if (groupId == AppConst.rootGroupId) {
bookGroups.size + books.size
} else {
books.size
@@ -220,7 +219,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
}
override fun getItemType(position: Int): Int {
- if (groupId != rootGroupId) {
+ if (groupId != AppConst.rootGroupId) {
return 0
}
if (position < bookGroups.size) {
@@ -230,7 +229,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
}
override fun getItem(position: Int): Any? {
- if (groupId != rootGroupId) {
+ if (groupId != AppConst.rootGroupId) {
return books.getOrNull(position)
}
if (position < bookGroups.size) {