From f82a31387445ce4e66c4c3efbcae49963773a044 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 20 Aug 2019 11:12:15 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/data/entities/SearchBook.kt | 6 +++++- .../io/legado/app/ui/changesource/ChangeSourceViewModel.kt | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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 8abef8eca..4423ff6f8 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 @@ -30,7 +30,7 @@ data class SearchBook( var variable: String? = null, var bookInfoHtml: String? = null, var originOrder: Int = 0 -) : Parcelable, BaseBook { +) : Parcelable, BaseBook, Comparable { override fun equals(other: Any?): Boolean { if (other is SearchBook) { @@ -45,6 +45,10 @@ data class SearchBook( return bookUrl.hashCode() } + override fun compareTo(other: SearchBook): Int { + return other.originOrder - this.originOrder + } + @IgnoredOnParcel @Ignore override var variableMap: HashMap? = null 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 b64d559f8..df3041c6c 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 @@ -34,6 +34,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio execute { callBack?.adapter()?.let { val books = searchBooks.toList() + books.sorted() val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) withContext(Main) { synchronized(this) {