pull/32/head
kunfei 5 years ago
parent 0934ee4b4a
commit 8ccd7895e4
  1. 44
      app/src/main/java/io/legado/app/ui/chapterlist/BookmarkAdapter.kt

@ -1,2 +1,46 @@
package io.legado.app.ui.chapterlist
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.Bookmark
class BookmarkAdapter : PagedListAdapter<Bookmark, BookmarkAdapter.MyViewHolder>(DIFF_CALLBACK) {
companion object {
@JvmField
val DIFF_CALLBACK = object : DiffUtil.ItemCallback<Bookmark>() {
override fun areItemsTheSame(oldItem: Bookmark, newItem: Bookmark): Boolean =
oldItem.time == newItem.time
override fun areContentsTheSame(oldItem: Bookmark, newItem: Bookmark): Boolean =
oldItem.time == newItem.time
&& oldItem.bookUrl == newItem.bookUrl
&& oldItem.chapterName == newItem.chapterName
&& oldItem.content == newItem.content
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_bookmark, parent, false))
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
getItem(position)?.let {
holder.bind(it)
}
}
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bind(bookmark: Bookmark) {
}
}
}
Loading…
Cancel
Save