From 782286f3cfa9e8c9ee685c30f9c5f9bbe1b1c3e8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 19 Aug 2019 16:31:52 +0800 Subject: [PATCH] up --- .../java/io/legado/app/data/entities/Book.kt | 4 +++- .../io/legado/app/data/entities/SearchBook.kt | 3 ++- .../ui/changesource/ChangeSourceViewModel.kt | 17 ++++++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 08a7eb13c..0add9736b 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -45,6 +45,7 @@ data class Book( var wordCount: String? = null, var canUpdate: Boolean = true, // 刷新书架时更新书籍信息 var order: Int = 0, // 手动排序 + var originOrder: Int = 0, //书源排序 var useReplaceRule: Boolean = true, // 正文使用净化替换规则 var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息) ) : Parcelable, BaseBook { @@ -102,7 +103,8 @@ data class Book( latestChapterTitle = latestChapterTitle, coverUrl = coverUrl, intro = intro, - tocUrl = tocUrl + tocUrl = tocUrl, + originOrder = originOrder ) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index f679ff10e..e86fd12fc 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -81,7 +81,8 @@ data class SearchBook( latestChapterTitle = latestChapterTitle, coverUrl = coverUrl, intro = intro, - tocUrl = tocUrl + tocUrl = tocUrl, + originOrder = originOrder ) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index 9d161099b..ac58feae8 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt @@ -9,7 +9,8 @@ import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook import io.legado.app.model.WebBook import kotlinx.coroutines.Dispatchers.IO -import kotlinx.coroutines.launch +import kotlinx.coroutines.Dispatchers.Main +import kotlinx.coroutines.withContext import org.jetbrains.anko.debug class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { @@ -30,12 +31,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio } private fun upAdapter() { - callBack?.adapter()?.let { - val books = searchBooks.toList() - val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) - launch { - it.setItemsNoNotify(books) - diffResult.dispatchUpdatesTo(it) + execute { + callBack?.adapter()?.let { + val books = searchBooks.toList() + val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) + withContext(Main) { + it.setItemsNoNotify(books) + diffResult.dispatchUpdatesTo(it) + } } } }