2019-04-28 22:43:54 +02:00
|
|
|
package org.schabi.newpipe.local.subscription.item
|
|
|
|
|
2020-11-27 15:52:06 +01:00
|
|
|
import android.view.View
|
|
|
|
import com.xwray.groupie.viewbinding.BindableItem
|
2019-04-28 22:43:54 +02:00
|
|
|
import org.schabi.newpipe.R
|
|
|
|
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
2020-11-27 15:52:06 +01:00
|
|
|
import org.schabi.newpipe.databinding.FeedGroupCardItemBinding
|
2019-04-28 22:43:54 +02:00
|
|
|
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
|
|
|
|
|
|
|
data class FeedGroupCardItem(
|
2020-05-01 20:13:21 +02:00
|
|
|
val groupId: Long = FeedGroupEntity.GROUP_ALL_ID,
|
|
|
|
val name: String,
|
|
|
|
val icon: FeedGroupIcon
|
2020-11-27 15:52:06 +01:00
|
|
|
) : BindableItem<FeedGroupCardItemBinding>() {
|
2019-04-28 22:43:54 +02:00
|
|
|
constructor (feedGroupEntity: FeedGroupEntity) : this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon)
|
|
|
|
|
|
|
|
override fun getId(): Long {
|
2020-01-28 06:59:49 +01:00
|
|
|
return when (groupId) {
|
|
|
|
FeedGroupEntity.GROUP_ALL_ID -> super.getId()
|
|
|
|
else -> groupId
|
|
|
|
}
|
2019-04-28 22:43:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getLayout(): Int = R.layout.feed_group_card_item
|
|
|
|
|
2020-11-27 15:52:06 +01:00
|
|
|
override fun bind(viewBinding: FeedGroupCardItemBinding, position: Int) {
|
|
|
|
viewBinding.title.text = name
|
2021-03-27 15:45:49 +01:00
|
|
|
viewBinding.icon.setImageResource(icon.getDrawableRes())
|
2019-04-28 22:43:54 +02:00
|
|
|
}
|
2020-11-27 15:52:06 +01:00
|
|
|
|
|
|
|
override fun initializeViewBinding(view: View) = FeedGroupCardItemBinding.bind(view)
|
2020-05-01 20:13:01 +02:00
|
|
|
}
|