diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index 064c158a0..000404970 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -2,13 +2,13 @@ package io.legado.app.ui.book.search import androidx.recyclerview.widget.DiffUtil -class DiffCallBack : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: SearchEntry, newItem: SearchEntry): Boolean { +class DiffCallBack : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: SearchEntity, newItem: SearchEntity): Boolean { return oldItem.name == newItem.name && oldItem.author == newItem.author } - override fun areContentsTheSame(oldItem: SearchEntry, newItem: SearchEntry): Boolean { + override fun areContentsTheSame(oldItem: SearchEntity, newItem: SearchEntity): Boolean { return oldItem.originCount == newItem.originCount && (oldItem.coverUrl == newItem.coverUrl || !oldItem.coverUrl.isNullOrEmpty()) && (oldItem.kind == newItem.kind || !oldItem.kind.isNullOrEmpty()) @@ -16,7 +16,7 @@ class DiffCallBack : DiffUtil.ItemCallback() { && oldItem.intro?.length ?: 0 > newItem.intro?.length ?: 0 } - override fun getChangePayload(oldItem: SearchEntry, newItem: SearchEntry): Any? { + override fun getChangePayload(oldItem: SearchEntity, newItem: SearchEntity): Any? { return when { oldItem.originCount != newItem.originCount -> 1 oldItem.coverUrl != newItem.coverUrl -> 2 diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index ce48fadb2..e967cd9ee 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -14,9 +14,9 @@ import kotlinx.android.synthetic.main.item_search.view.* import org.jetbrains.anko.sdk27.listeners.onClick class SearchAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context, R.layout.item_search) { + SimpleRecyclerAdapter(context, R.layout.item_search) { - override fun convert(holder: ItemViewHolder, item: SearchEntry, payloads: MutableList) { + override fun convert(holder: ItemViewHolder, item: SearchEntity, payloads: MutableList) { if (payloads.isEmpty()) { bind(holder.itemView, item) } else { @@ -24,7 +24,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : } } - private fun bind(itemView: View, searchBook: SearchEntry) { + private fun bind(itemView: View, searchBook: SearchEntity) { with(itemView) { tv_name.text = searchBook.name tv_author.text = context.getString(R.string.author_show, searchBook.author) @@ -79,7 +79,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : } } - private fun bindChange(itemView: View, searchBook: SearchEntry, payloads: MutableList) { + private fun bindChange(itemView: View, searchBook: SearchEntity, payloads: MutableList) { with(itemView) { when (payloads[0]) { 1 -> bv_originCount.setBadgeCount(searchBook.originCount) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchEntry.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchEntity.kt similarity index 96% rename from app/src/main/java/io/legado/app/ui/book/search/SearchEntry.kt rename to app/src/main/java/io/legado/app/ui/book/search/SearchEntity.kt index 4350c7830..14fe95f14 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchEntry.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchEntity.kt @@ -2,7 +2,7 @@ package io.legado.app.ui.book.search import io.legado.app.utils.splitNotBlank -data class SearchEntry( +data class SearchEntity( var name: String = "", var author: String = "", var kind: String? = null, diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index d6882f687..1b16c0c3d 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -22,7 +22,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { var startTime: Long = 0 var searchPage = 0 var isLoading = false - private val booksShow = arrayListOf() + private val booksShow = arrayListOf() fun search( key: String,