pull/32/head
parent
0934ee4b4a
commit
8ccd7895e4
@ -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…
Reference in new issue