pull/32/head
kunfei 5 years ago
parent d033b4e68d
commit f82a313874
  1. 6
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  2. 1
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -30,7 +30,7 @@ data class SearchBook(
var variable: String? = null, var variable: String? = null,
var bookInfoHtml: String? = null, var bookInfoHtml: String? = null,
var originOrder: Int = 0 var originOrder: Int = 0
) : Parcelable, BaseBook { ) : Parcelable, BaseBook, Comparable<SearchBook> {
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (other is SearchBook) { if (other is SearchBook) {
@ -45,6 +45,10 @@ data class SearchBook(
return bookUrl.hashCode() return bookUrl.hashCode()
} }
override fun compareTo(other: SearchBook): Int {
return other.originOrder - this.originOrder
}
@IgnoredOnParcel @IgnoredOnParcel
@Ignore @Ignore
override var variableMap: HashMap<String, String>? = null override var variableMap: HashMap<String, String>? = null

@ -34,6 +34,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
execute { execute {
callBack?.adapter()?.let { callBack?.adapter()?.let {
val books = searchBooks.toList() val books = searchBooks.toList()
books.sorted()
val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList()))
withContext(Main) { withContext(Main) {
synchronized(this) { synchronized(this) {

Loading…
Cancel
Save