Fix chapters selection decoration

This commit is contained in:
Koitharu
2024-02-12 09:07:32 +02:00
parent 36a74f32df
commit 0cb7e71781
2 changed files with 9 additions and 1 deletions

View File

@@ -91,7 +91,7 @@ abstract class AbstractSelectionItemDecoration : RecyclerView.ItemDecoration() {
canvas.restoreToCount(checkpoint)
}
protected open fun getItemId(parent: RecyclerView, child: View) = parent.getChildItemId(child)
abstract fun getItemId(parent: RecyclerView, child: View): Long
protected open fun onDrawBackground(
canvas: Canvas,

View File

@@ -9,7 +9,9 @@ import android.view.View
import androidx.core.graphics.ColorUtils
import androidx.recyclerview.widget.RecyclerView
import org.koitharu.kotatsu.core.ui.list.decor.AbstractSelectionItemDecoration
import org.koitharu.kotatsu.core.util.ext.getItem
import org.koitharu.kotatsu.core.util.ext.getThemeColor
import org.koitharu.kotatsu.details.ui.model.ChapterListItem
import com.google.android.material.R as materialR
class ChaptersSelectionDecoration(context: Context) : AbstractSelectionItemDecoration() {
@@ -25,6 +27,12 @@ class ChaptersSelectionDecoration(context: Context) : AbstractSelectionItemDecor
paint.style = Paint.Style.FILL
}
override fun getItemId(parent: RecyclerView, child: View): Long {
val holder = parent.getChildViewHolder(child) ?: return RecyclerView.NO_ID
val item = holder.getItem(ChapterListItem::class.java) ?: return RecyclerView.NO_ID
return item.chapter.id
}
override fun onDrawBackground(
canvas: Canvas,
parent: RecyclerView,