diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkAdapter.kt b/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkAdapter.kt index 8fe0ecbe6..ef07eb323 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/BookmarkAdapter.kt +++ b/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(DIFF_CALLBACK) { + + companion object { + + @JvmField + val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { + 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) { + + } + } +} \ No newline at end of file