Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Jan 22, 2024
1 parent 1068f56 commit 9de9ac4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/src/main/java/io/legado/app/constant/BookType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.annotation.IntDef
* 以二进制位来区分,可能一本书籍包含多个类型,每一位代表一个类型,数值为2的n次方
* 以二进制位来区分,数据库查询更高效, 数值>=8和老版本类型区分开
*/
@Suppress("ConstPropertyName")
object BookType {
/**
* 8 文本
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.BookType
import io.legado.app.constant.Theme
import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
Expand All @@ -26,6 +27,7 @@ import io.legado.app.help.book.isAudio
import io.legado.app.help.book.isLocal
import io.legado.app.help.book.isLocalTxt
import io.legado.app.help.book.isWebFile
import io.legado.app.help.book.removeType
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.LocalConfig
import io.legado.app.lib.dialogs.alert
Expand Down Expand Up @@ -224,6 +226,9 @@ class BookInfoActivity :
viewModel.getBook()?.let {
it.canUpdate = !it.canUpdate
if (viewModel.inBookshelf) {
if (!it.canUpdate) {
it.removeType(BookType.updateError)
}
viewModel.saveBook(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ class BookshelfManageViewModel(application: Application) : BaseViewModel(applica
fun upCanUpdate(books: List<Book>, canUpdate: Boolean) {
execute {
val array = Array(books.size) {
books[it].copy(canUpdate = canUpdate)
books[it].copy(canUpdate = canUpdate).apply {
if (!canUpdate) {
removeType(BookType.updateError)
}
}
}
appDb.bookDao.update(*array)
}
Expand Down

0 comments on commit 9de9ac4

Please sign in to comment.