优化
This commit is contained in:
@@ -249,7 +249,7 @@
|
|||||||
android:screenOrientation="behind" />
|
android:screenOrientation="behind" />
|
||||||
<!-- 书籍管理 -->
|
<!-- 书籍管理 -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.book.management.BookshelfManageActivity"
|
android:name=".ui.book.manage.BookshelfManageActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:screenOrientation="behind" />
|
android:screenOrientation="behind" />
|
||||||
<!-- 书源调试 -->
|
<!-- 书源调试 -->
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ object AppConst {
|
|||||||
SimpleDateFormat("yy-MM-dd-HH-mm-ss")
|
SimpleDateFormat("yy-MM-dd-HH-mm-ss")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const val rootGroupId = -100L
|
||||||
const val bookGroupAllId = -1L
|
const val bookGroupAllId = -1L
|
||||||
const val bookGroupLocalId = -2L
|
const val bookGroupLocalId = -2L
|
||||||
const val bookGroupAudioId = -3L
|
const val bookGroupAudioId = -3L
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package io.legado.app.ui.book.management
|
package io.legado.app.ui.book.manage
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
+11
-4
@@ -1,4 +1,4 @@
|
|||||||
package io.legado.app.ui.book.management
|
package io.legado.app.ui.book.manage
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -140,6 +140,7 @@ class BookshelfManageActivity :
|
|||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
when (groupId) {
|
when (groupId) {
|
||||||
|
AppConst.rootGroupId -> appDb.bookDao.flowNoGroup()
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||||
@@ -147,12 +148,18 @@ class BookshelfManageActivity :
|
|||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
else -> appDb.bookDao.flowByGroup(groupId)
|
||||||
}.conflate().map { books ->
|
}.conflate().map { books ->
|
||||||
when (getPrefInt(PreferKey.bookshelfSort)) {
|
when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||||
1 -> books.sortedByDescending { it.latestChapterTime }
|
1 -> books.sortedByDescending {
|
||||||
|
it.latestChapterTime
|
||||||
|
}
|
||||||
2 -> books.sortedWith { o1, o2 ->
|
2 -> books.sortedWith { o1, o2 ->
|
||||||
o1.name.cnCompare(o2.name)
|
o1.name.cnCompare(o2.name)
|
||||||
}
|
}
|
||||||
3 -> books.sortedBy { it.order }
|
3 -> books.sortedBy {
|
||||||
else -> books.sortedByDescending { it.durChapterTime }
|
it.order
|
||||||
|
}
|
||||||
|
else -> books.sortedByDescending {
|
||||||
|
it.durChapterTime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.conflate().collect { books ->
|
}.conflate().collect { books ->
|
||||||
adapter.setItems(books)
|
adapter.setItems(books)
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package io.legado.app.ui.book.management
|
package io.legado.app.ui.book.manage
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
+1
-1
@@ -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.foundation.layout.Column
|
||||||
import androidx.compose.material.AlertDialog
|
import androidx.compose.material.AlertDialog
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package io.legado.app.ui.book.management
|
package io.legado.app.ui.book.manage
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -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.cache.CacheActivity
|
||||||
import io.legado.app.ui.book.group.GroupManageDialog
|
import io.legado.app.ui.book.group.GroupManageDialog
|
||||||
import io.legado.app.ui.book.local.ImportBookActivity
|
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.book.search.SearchActivity
|
||||||
import io.legado.app.ui.document.HandleFileContract
|
import io.legado.app.ui.document.HandleFileContract
|
||||||
import io.legado.app.ui.main.MainViewModel
|
import io.legado.app.ui.main.MainViewModel
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
BaseBooksAdapter.CallBack {
|
BaseBooksAdapter.CallBack {
|
||||||
|
|
||||||
private val binding by viewBinding(FragmentBookshelf1Binding::bind)
|
private val binding by viewBinding(FragmentBookshelf1Binding::bind)
|
||||||
private val rootGroupId = -100L
|
|
||||||
private val bookshelfLayout by lazy {
|
private val bookshelfLayout by lazy {
|
||||||
getPrefInt(PreferKey.bookshelfLayout)
|
getPrefInt(PreferKey.bookshelfLayout)
|
||||||
}
|
}
|
||||||
@@ -56,7 +55,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
}
|
}
|
||||||
private var bookGroups: List<BookGroup> = emptyList()
|
private var bookGroups: List<BookGroup> = emptyList()
|
||||||
private var booksFlowJob: Job? = null
|
private var booksFlowJob: Job? = null
|
||||||
override var groupId = rootGroupId
|
override var groupId = AppConst.rootGroupId
|
||||||
override var books: List<Book> = emptyList()
|
override var books: List<Book> = emptyList()
|
||||||
|
|
||||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@@ -121,7 +120,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
when (groupId) {
|
when (groupId) {
|
||||||
rootGroupId -> appDb.bookDao.flowRoot()
|
AppConst.rootGroupId -> appDb.bookDao.flowRoot()
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||||
@@ -212,7 +211,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return if (groupId == rootGroupId) {
|
return if (groupId == AppConst.rootGroupId) {
|
||||||
bookGroups.size + books.size
|
bookGroups.size + books.size
|
||||||
} else {
|
} else {
|
||||||
books.size
|
books.size
|
||||||
@@ -220,7 +219,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemType(position: Int): Int {
|
override fun getItemType(position: Int): Int {
|
||||||
if (groupId != rootGroupId) {
|
if (groupId != AppConst.rootGroupId) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (position < bookGroups.size) {
|
if (position < bookGroups.size) {
|
||||||
@@ -230,7 +229,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItem(position: Int): Any? {
|
override fun getItem(position: Int): Any? {
|
||||||
if (groupId != rootGroupId) {
|
if (groupId != AppConst.rootGroupId) {
|
||||||
return books.getOrNull(position)
|
return books.getOrNull(position)
|
||||||
}
|
}
|
||||||
if (position < bookGroups.size) {
|
if (position < bookGroups.size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user