优化搜索

pull/737/head
gedoor 4 years ago
parent 4ddf6599aa
commit 883fa65263
  1. 14
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt

@ -40,15 +40,16 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
override fun getChangePayload(oldItem: SearchBook, newItem: SearchBook): Any? { override fun getChangePayload(oldItem: SearchBook, newItem: SearchBook): Any? {
val payload = Bundle() val payload = Bundle()
if (oldItem.name != newItem.name) payload.putString("name", newItem.name)
if (oldItem.author != newItem.author) payload.putString("author", newItem.author)
if (oldItem.origins.size != newItem.origins.size) if (oldItem.origins.size != newItem.origins.size)
payload.putInt("origins", newItem.origins.size) payload.putInt("origins", newItem.origins.size)
if (oldItem.coverUrl != newItem.coverUrl) payload.putString("cover", newItem.coverUrl) if (oldItem.coverUrl != newItem.coverUrl)
if (oldItem.kind != newItem.kind) payload.putString("kind", newItem.kind) payload.putString("cover", newItem.coverUrl)
if (oldItem.kind != newItem.kind)
payload.putString("kind", newItem.kind)
if (oldItem.latestChapterTitle != newItem.latestChapterTitle) if (oldItem.latestChapterTitle != newItem.latestChapterTitle)
payload.putString("last", newItem.latestChapterTitle) payload.putString("last", newItem.latestChapterTitle)
if (oldItem.intro != newItem.intro) payload.putString("intro", newItem.intro) if (oldItem.intro != newItem.intro)
payload.putString("intro", newItem.intro)
if (payload.isEmpty) return null if (payload.isEmpty) return null
return payload return payload
} }
@ -106,9 +107,6 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
with(binding) { with(binding) {
bundle.keySet().map { bundle.keySet().map {
when (it) { when (it) {
"name" -> tvName.text = searchBook.name
"author" -> tvAuthor.text =
context.getString(R.string.author_show, searchBook.author)
"origins" -> bvOriginCount.setBadgeCount(searchBook.origins.size) "origins" -> bvOriginCount.setBadgeCount(searchBook.origins.size)
"last" -> upLasted(binding, searchBook.latestChapterTitle) "last" -> upLasted(binding, searchBook.latestChapterTitle)
"intro" -> { "intro" -> {

Loading…
Cancel
Save