Use BindableItem in HeaderItem.
This commit is contained in:
parent
51a948bfcf
commit
9e5f079cf2
|
@ -1,19 +1,23 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
|
||||||
import kotlinx.android.synthetic.main.header_item.header_title
|
|
||||||
import org.schabi.newpipe.R
|
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<HeaderItemBinding>() {
|
||||||
override fun getLayout(): Int = R.layout.header_item
|
override fun getLayout(): Int = R.layout.header_item
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: HeaderItemBinding, position: Int) {
|
||||||
viewHolder.header_title.text = title
|
viewBinding.headerTitle.text = title
|
||||||
|
|
||||||
val listener: OnClickListener? = if (onClickListener != null) OnClickListener { onClickListener.invoke() } else null
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue