From 8ccd7895e44c3f249609e6e84564fbc0d7b65776 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 8 Aug 2019 22:44:48 +0800 Subject: [PATCH] up --- .../app/ui/chapterlist/BookmarkAdapter.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) 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