From 9e5f079cf254d741b9e3357075f0c43cb81730ab Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 28 Nov 2020 13:58:34 +0530 Subject: [PATCH] Use BindableItem in HeaderItem. --- .../local/subscription/item/HeaderItem.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderItem.kt index 9798dac1b..e04164573 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/HeaderItem.kt @@ -1,19 +1,23 @@ package org.schabi.newpipe.local.subscription.item +import android.view.View import android.view.View.OnClickListener -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import com.xwray.groupie.kotlinandroidextensions.Item -import kotlinx.android.synthetic.main.header_item.header_title +import com.xwray.groupie.viewbinding.BindableItem import org.schabi.newpipe.R +import org.schabi.newpipe.databinding.HeaderItemBinding -class HeaderItem(val title: String, private val onClickListener: (() -> Unit)? = null) : Item() { - +class HeaderItem( + val title: String, + private val onClickListener: (() -> Unit)? = null +) : BindableItem() { override fun getLayout(): Int = R.layout.header_item - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.header_title.text = title + override fun bind(viewBinding: HeaderItemBinding, position: Int) { + viewBinding.headerTitle.text = title val listener: OnClickListener? = if (onClickListener != null) OnClickListener { onClickListener.invoke() } else null - viewHolder.root.setOnClickListener(listener) + viewBinding.root.setOnClickListener(listener) } + + override fun initializeViewBinding(view: View) = HeaderItemBinding.bind(view) }