pull/32/head
kunfei 5 years ago
parent dd551abf3a
commit 782286f3cf
  1. 4
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 3
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  3. 7
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -45,6 +45,7 @@ data class Book(
var wordCount: String? = null, var wordCount: String? = null,
var canUpdate: Boolean = true, // 刷新书架时更新书籍信息 var canUpdate: Boolean = true, // 刷新书架时更新书籍信息
var order: Int = 0, // 手动排序 var order: Int = 0, // 手动排序
var originOrder: Int = 0, //书源排序
var useReplaceRule: Boolean = true, // 正文使用净化替换规则 var useReplaceRule: Boolean = true, // 正文使用净化替换规则
var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息) var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息)
) : Parcelable, BaseBook { ) : Parcelable, BaseBook {
@ -102,7 +103,8 @@ data class Book(
latestChapterTitle = latestChapterTitle, latestChapterTitle = latestChapterTitle,
coverUrl = coverUrl, coverUrl = coverUrl,
intro = intro, intro = intro,
tocUrl = tocUrl tocUrl = tocUrl,
originOrder = originOrder
) )
} }
} }

@ -81,7 +81,8 @@ data class SearchBook(
latestChapterTitle = latestChapterTitle, latestChapterTitle = latestChapterTitle,
coverUrl = coverUrl, coverUrl = coverUrl,
intro = intro, intro = intro,
tocUrl = tocUrl tocUrl = tocUrl,
originOrder = originOrder
) )
} }
} }

@ -9,7 +9,8 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.SearchBook
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.withContext
import org.jetbrains.anko.debug import org.jetbrains.anko.debug
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { class ChangeSourceViewModel(application: Application) : BaseViewModel(application) {
@ -30,15 +31,17 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
} }
private fun upAdapter() { private fun upAdapter() {
execute {
callBack?.adapter()?.let { callBack?.adapter()?.let {
val books = searchBooks.toList() val books = searchBooks.toList()
val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList()))
launch { withContext(Main) {
it.setItemsNoNotify(books) it.setItemsNoNotify(books)
diffResult.dispatchUpdatesTo(it) diffResult.dispatchUpdatesTo(it)
} }
} }
} }
}
fun search() { fun search() {
execute { execute {

Loading…
Cancel
Save