From 01396923f112e965ead4a92f1c92f41ceec2ae24 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 29 Nov 2020 16:08:54 +0530 Subject: [PATCH] Use the base Groupie library in ChannelItem. --- .../subscription/dialog/FeedGroupDialog.kt | 2 +- .../dialog/FeedGroupReorderDialog.kt | 2 +- .../local/subscription/item/ChannelItem.kt | 32 +++++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt index 7c7ebdea9..6f821f432 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt @@ -19,9 +19,9 @@ import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.xwray.groupie.GroupAdapter +import com.xwray.groupie.GroupieViewHolder import com.xwray.groupie.OnItemClickListener import com.xwray.groupie.Section -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder import icepick.Icepick import icepick.State import org.schabi.newpipe.R diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt index 3b74ddc74..2b09a3b3b 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt @@ -12,8 +12,8 @@ import androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.xwray.groupie.GroupAdapter +import com.xwray.groupie.GroupieViewHolder import com.xwray.groupie.TouchCallback -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder import icepick.Icepick import icepick.State import org.schabi.newpipe.R diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt index 8089f6480..a87ffb695 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt @@ -1,13 +1,11 @@ package org.schabi.newpipe.local.subscription.item import android.content.Context +import android.widget.ImageView +import android.widget.TextView import com.nostra13.universalimageloader.core.ImageLoader -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import com.xwray.groupie.kotlinandroidextensions.Item -import kotlinx.android.synthetic.main.list_channel_item.itemAdditionalDetails -import kotlinx.android.synthetic.main.list_channel_item.itemChannelDescriptionView -import kotlinx.android.synthetic.main.list_channel_item.itemThumbnailView -import kotlinx.android.synthetic.main.list_channel_item.itemTitleView +import com.xwray.groupie.GroupieViewHolder +import com.xwray.groupie.Item import org.schabi.newpipe.R import org.schabi.newpipe.extractor.channel.ChannelInfoItem import org.schabi.newpipe.util.ImageDisplayConstants @@ -19,8 +17,7 @@ class ChannelItem( private val subscriptionId: Long = -1L, var itemVersion: ItemVersion = ItemVersion.NORMAL, var gesturesListener: OnClickGesture? = null -) : Item() { - +) : Item() { override fun getId(): Long = if (subscriptionId == -1L) super.getId() else subscriptionId enum class ItemVersion { NORMAL, MINI, GRID } @@ -32,18 +29,25 @@ class ChannelItem( } override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.itemTitleView.text = infoItem.name - viewHolder.itemAdditionalDetails.text = getDetailLine(viewHolder.root.context) - if (itemVersion == ItemVersion.NORMAL) viewHolder.itemChannelDescriptionView.text = infoItem.description + val itemTitleView = viewHolder.root.findViewById(R.id.itemTitleView) + val itemAdditionalDetails = viewHolder.root.findViewById(R.id.itemAdditionalDetails) + val itemChannelDescriptionView = viewHolder.root.findViewById(R.id.itemChannelDescriptionView) + val itemThumbnailView = viewHolder.root.findViewById(R.id.itemThumbnailView) + + itemTitleView.text = infoItem.name + itemAdditionalDetails.text = getDetailLine(viewHolder.root.context) + if (itemVersion == ItemVersion.NORMAL) { + itemChannelDescriptionView.text = infoItem.description + } ImageLoader.getInstance().displayImage( - infoItem.thumbnailUrl, viewHolder.itemThumbnailView, + infoItem.thumbnailUrl, itemThumbnailView, ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS ) gesturesListener?.run { - viewHolder.containerView.setOnClickListener { selected(infoItem) } - viewHolder.containerView.setOnLongClickListener { held(infoItem); true } + viewHolder.root.setOnClickListener { selected(infoItem) } + viewHolder.root.setOnLongClickListener { held(infoItem); true } } }