pull/1754/head^2
kunfei 3 years ago
parent d79e3d09b5
commit ba491d388c
  1. 2
      app/src/main/AndroidManifest.xml
  2. 1
      app/src/main/java/io/legado/app/constant/AppConst.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/manage/BookAdapter.kt
  4. 15
      app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt
  6. 2
      app/src/main/java/io/legado/app/ui/book/manage/ComposeView.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/manage/SourcePickerDialog.kt
  8. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
  9. 11
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt

@ -249,7 +249,7 @@
android:screenOrientation="behind" />
<!-- 书籍管理 -->
<activity
android:name=".ui.book.management.BookshelfManageActivity"
android:name=".ui.book.manage.BookshelfManageActivity"
android:launchMode="singleTop"
android:screenOrientation="behind" />
<!-- 书源调试 -->

@ -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

@ -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

@ -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)

@ -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

@ -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

@ -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

@ -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

@ -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<BookGroup> = emptyList()
private var booksFlowJob: Job? = null
override var groupId = rootGroupId
override var groupId = AppConst.rootGroupId
override var books: List<Book> = 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) {

Loading…
Cancel
Save