Use BindableItem in PickerIconItem.

This commit is contained in:
Isira Seneviratne 2020-11-28 14:03:26 +05:30
parent a188125982
commit e2dd058430
1 changed files with 11 additions and 6 deletions

View File

@ -1,20 +1,25 @@
package org.schabi.newpipe.local.subscription.item
import android.content.Context
import android.view.View
import androidx.annotation.DrawableRes
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
import com.xwray.groupie.kotlinandroidextensions.Item
import kotlinx.android.synthetic.main.picker_icon_item.icon_view
import com.xwray.groupie.viewbinding.BindableItem
import org.schabi.newpipe.R
import org.schabi.newpipe.databinding.PickerIconItemBinding
import org.schabi.newpipe.local.subscription.FeedGroupIcon
class PickerIconItem(context: Context, val icon: FeedGroupIcon) : Item() {
class PickerIconItem(
context: Context,
val icon: FeedGroupIcon
) : BindableItem<PickerIconItemBinding>() {
@DrawableRes
val iconRes: Int = icon.getDrawableRes(context)
override fun getLayout(): Int = R.layout.picker_icon_item
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
viewHolder.icon_view.setImageResource(iconRes)
override fun bind(viewBinding: PickerIconItemBinding, position: Int) {
viewBinding.iconView.setImageResource(iconRes)
}
override fun initializeViewBinding(view: View) = PickerIconItemBinding.bind(view)
}