Merge pull request #5029 from Isira-Seneviratne/Use_Groupie_view_binding
Switch to Groupie's view binding module.
This commit is contained in:
commit
098c954ef1
15 changed files with 163 additions and 144 deletions
|
@ -217,7 +217,7 @@ dependencies {
|
||||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||||
|
|
||||||
implementation "com.xwray:groupie:${groupieVersion}"
|
implementation "com.xwray:groupie:${groupieVersion}"
|
||||||
implementation "com.xwray:groupie-kotlin-android-extensions:${groupieVersion}"
|
implementation "com.xwray:groupie-viewbinding:${groupieVersion}"
|
||||||
|
|
||||||
implementation "de.hdodenhof:circleimageview:3.1.0"
|
implementation "de.hdodenhof:circleimageview:3.1.0"
|
||||||
implementation "com.nostra13.universalimageloader:universal-image-loader:1.9.5"
|
implementation "com.nostra13.universalimageloader:universal-image-loader:1.9.5"
|
||||||
|
|
|
@ -17,7 +17,6 @@ import android.view.MenuInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.lifecycle.Observer
|
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
@ -27,12 +26,13 @@ import com.xwray.groupie.Group
|
||||||
import com.xwray.groupie.GroupAdapter
|
import com.xwray.groupie.GroupAdapter
|
||||||
import com.xwray.groupie.Item
|
import com.xwray.groupie.Item
|
||||||
import com.xwray.groupie.Section
|
import com.xwray.groupie.Section
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.GroupieViewHolder
|
||||||
import icepick.State
|
import icepick.State
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
||||||
import org.schabi.newpipe.databinding.DialogTitleBinding
|
import org.schabi.newpipe.databinding.DialogTitleBinding
|
||||||
|
import org.schabi.newpipe.databinding.FeedItemCarouselBinding
|
||||||
import org.schabi.newpipe.databinding.FragmentSubscriptionBinding
|
import org.schabi.newpipe.databinding.FragmentSubscriptionBinding
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem
|
||||||
import org.schabi.newpipe.fragments.BaseStateFragment
|
import org.schabi.newpipe.fragments.BaseStateFragment
|
||||||
|
@ -79,7 +79,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
|
|
||||||
private var subscriptionBroadcastReceiver: BroadcastReceiver? = null
|
private var subscriptionBroadcastReceiver: BroadcastReceiver? = null
|
||||||
|
|
||||||
private val groupAdapter = GroupAdapter<GroupieViewHolder>()
|
private val groupAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||||
private val feedGroupsSection = Section()
|
private val feedGroupsSection = Section()
|
||||||
private var feedGroupsCarousel: FeedGroupCarouselItem? = null
|
private var feedGroupsCarousel: FeedGroupCarouselItem? = null
|
||||||
private lateinit var importExportItem: FeedImportExportItem
|
private lateinit var importExportItem: FeedImportExportItem
|
||||||
|
@ -234,7 +234,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
|
|
||||||
private fun setupInitialLayout() {
|
private fun setupInitialLayout() {
|
||||||
Section().apply {
|
Section().apply {
|
||||||
val carouselAdapter = GroupAdapter<GroupieViewHolder>()
|
val carouselAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||||
|
|
||||||
carouselAdapter.add(FeedGroupCardItem(-1, getString(R.string.all), FeedGroupIcon.RSS))
|
carouselAdapter.add(FeedGroupCardItem(-1, getString(R.string.all), FeedGroupIcon.RSS))
|
||||||
carouselAdapter.add(feedGroupsSection)
|
carouselAdapter.add(feedGroupsSection)
|
||||||
|
@ -288,15 +288,12 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
binding.itemsList.adapter = groupAdapter
|
binding.itemsList.adapter = groupAdapter
|
||||||
|
|
||||||
viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java)
|
viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java)
|
||||||
viewModel.stateLiveData.observe(viewLifecycleOwner, Observer { it?.let(this::handleResult) })
|
viewModel.stateLiveData.observe(viewLifecycleOwner, { it?.let(this::handleResult) })
|
||||||
viewModel.feedGroupsLiveData.observe(viewLifecycleOwner, Observer { it?.let(this::handleFeedGroups) })
|
viewModel.feedGroupsLiveData.observe(viewLifecycleOwner, { it?.let(this::handleFeedGroups) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showLongTapDialog(selectedItem: ChannelInfoItem) {
|
private fun showLongTapDialog(selectedItem: ChannelInfoItem) {
|
||||||
val commands = arrayOf(
|
val commands = arrayOf(getString(R.string.share), getString(R.string.unsubscribe))
|
||||||
getString(R.string.share),
|
|
||||||
getString(R.string.unsubscribe)
|
|
||||||
)
|
|
||||||
|
|
||||||
val actions = DialogInterface.OnClickListener { _, i ->
|
val actions = DialogInterface.OnClickListener { _, i ->
|
||||||
when (i) {
|
when (i) {
|
||||||
|
@ -439,11 +436,8 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
return when (listMode) {
|
return when (listMode) {
|
||||||
getString(R.string.list_view_mode_auto_key) -> {
|
getString(R.string.list_view_mode_auto_key) -> {
|
||||||
val configuration = resources.configuration
|
val configuration = resources.configuration
|
||||||
|
configuration.orientation == Configuration.ORIENTATION_LANDSCAPE &&
|
||||||
(
|
configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)
|
||||||
configuration.orientation == Configuration.ORIENTATION_LANDSCAPE &&
|
|
||||||
configuration.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
getString(R.string.list_view_mode_grid_key) -> true
|
getString(R.string.list_view_mode_grid_key) -> true
|
||||||
else -> false
|
else -> false
|
||||||
|
|
|
@ -19,9 +19,9 @@ import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.xwray.groupie.GroupAdapter
|
import com.xwray.groupie.GroupAdapter
|
||||||
|
import com.xwray.groupie.GroupieViewHolder
|
||||||
import com.xwray.groupie.OnItemClickListener
|
import com.xwray.groupie.OnItemClickListener
|
||||||
import com.xwray.groupie.Section
|
import com.xwray.groupie.Section
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
|
||||||
import icepick.Icepick
|
import icepick.Icepick
|
||||||
import icepick.State
|
import icepick.State
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
|
|
@ -12,8 +12,8 @@ import androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.xwray.groupie.GroupAdapter
|
import com.xwray.groupie.GroupAdapter
|
||||||
|
import com.xwray.groupie.GroupieViewHolder
|
||||||
import com.xwray.groupie.TouchCallback
|
import com.xwray.groupie.TouchCallback
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
|
||||||
import icepick.Icepick
|
import icepick.Icepick
|
||||||
import icepick.State
|
import icepick.State
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader
|
import com.nostra13.universalimageloader.core.ImageLoader
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.GroupieViewHolder
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.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 org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem
|
||||||
import org.schabi.newpipe.util.ImageDisplayConstants
|
import org.schabi.newpipe.util.ImageDisplayConstants
|
||||||
|
@ -19,8 +17,7 @@ class ChannelItem(
|
||||||
private val subscriptionId: Long = -1L,
|
private val subscriptionId: Long = -1L,
|
||||||
var itemVersion: ItemVersion = ItemVersion.NORMAL,
|
var itemVersion: ItemVersion = ItemVersion.NORMAL,
|
||||||
var gesturesListener: OnClickGesture<ChannelInfoItem>? = null
|
var gesturesListener: OnClickGesture<ChannelInfoItem>? = null
|
||||||
) : Item() {
|
) : Item<GroupieViewHolder>() {
|
||||||
|
|
||||||
override fun getId(): Long = if (subscriptionId == -1L) super.getId() else subscriptionId
|
override fun getId(): Long = if (subscriptionId == -1L) super.getId() else subscriptionId
|
||||||
|
|
||||||
enum class ItemVersion { NORMAL, MINI, GRID }
|
enum class ItemVersion { NORMAL, MINI, GRID }
|
||||||
|
@ -32,18 +29,25 @@ class ChannelItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
||||||
viewHolder.itemTitleView.text = infoItem.name
|
val itemTitleView = viewHolder.root.findViewById<TextView>(R.id.itemTitleView)
|
||||||
viewHolder.itemAdditionalDetails.text = getDetailLine(viewHolder.root.context)
|
val itemAdditionalDetails = viewHolder.root.findViewById<TextView>(R.id.itemAdditionalDetails)
|
||||||
if (itemVersion == ItemVersion.NORMAL) viewHolder.itemChannelDescriptionView.text = infoItem.description
|
val itemChannelDescriptionView = viewHolder.root.findViewById<TextView>(R.id.itemChannelDescriptionView)
|
||||||
|
val itemThumbnailView = viewHolder.root.findViewById<ImageView>(R.id.itemThumbnailView)
|
||||||
|
|
||||||
|
itemTitleView.text = infoItem.name
|
||||||
|
itemAdditionalDetails.text = getDetailLine(viewHolder.root.context)
|
||||||
|
if (itemVersion == ItemVersion.NORMAL) {
|
||||||
|
itemChannelDescriptionView.text = infoItem.description
|
||||||
|
}
|
||||||
|
|
||||||
ImageLoader.getInstance().displayImage(
|
ImageLoader.getInstance().displayImage(
|
||||||
infoItem.thumbnailUrl, viewHolder.itemThumbnailView,
|
infoItem.thumbnailUrl, itemThumbnailView,
|
||||||
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS
|
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS
|
||||||
)
|
)
|
||||||
|
|
||||||
gesturesListener?.run {
|
gesturesListener?.run {
|
||||||
viewHolder.containerView.setOnClickListener { selected(infoItem) }
|
viewHolder.root.setOnClickListener { selected(infoItem) }
|
||||||
viewHolder.containerView.setOnLongClickListener { held(infoItem); true }
|
viewHolder.root.setOnLongClickListener { held(infoItem); true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import android.view.View
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.databinding.ListEmptyViewBinding
|
||||||
|
|
||||||
class EmptyPlaceholderItem : Item() {
|
class EmptyPlaceholderItem : BindableItem<ListEmptyViewBinding>() {
|
||||||
override fun getLayout(): Int = R.layout.list_empty_view
|
override fun getLayout(): Int = R.layout.list_empty_view
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {}
|
override fun bind(viewBinding: ListEmptyViewBinding, position: Int) {}
|
||||||
override fun getSpanSize(spanCount: Int, position: Int): Int = spanCount
|
override fun getSpanSize(spanCount: Int, position: Int): Int = spanCount
|
||||||
|
override fun initializeViewBinding(view: View) = ListEmptyViewBinding.bind(view)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import android.view.View
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.databinding.FeedGroupAddNewItemBinding
|
||||||
|
|
||||||
class FeedGroupAddItem : Item() {
|
class FeedGroupAddItem : BindableItem<FeedGroupAddNewItemBinding>() {
|
||||||
override fun getLayout(): Int = R.layout.feed_group_add_new_item
|
override fun getLayout(): Int = R.layout.feed_group_add_new_item
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {}
|
override fun bind(viewBinding: FeedGroupAddNewItemBinding, position: Int) {}
|
||||||
|
override fun initializeViewBinding(view: View) = FeedGroupAddNewItemBinding.bind(view)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import android.view.View
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import kotlinx.android.synthetic.main.feed_group_card_item.icon
|
|
||||||
import kotlinx.android.synthetic.main.feed_group_card_item.title
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
||||||
|
import org.schabi.newpipe.databinding.FeedGroupCardItemBinding
|
||||||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
||||||
|
|
||||||
data class FeedGroupCardItem(
|
data class FeedGroupCardItem(
|
||||||
val groupId: Long = FeedGroupEntity.GROUP_ALL_ID,
|
val groupId: Long = FeedGroupEntity.GROUP_ALL_ID,
|
||||||
val name: String,
|
val name: String,
|
||||||
val icon: FeedGroupIcon
|
val icon: FeedGroupIcon
|
||||||
) : Item() {
|
) : BindableItem<FeedGroupCardItemBinding>() {
|
||||||
constructor (feedGroupEntity: FeedGroupEntity) : this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon)
|
constructor (feedGroupEntity: FeedGroupEntity) : this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon)
|
||||||
|
|
||||||
override fun getId(): Long {
|
override fun getId(): Long {
|
||||||
|
@ -24,8 +23,10 @@ data class FeedGroupCardItem(
|
||||||
|
|
||||||
override fun getLayout(): Int = R.layout.feed_group_card_item
|
override fun getLayout(): Int = R.layout.feed_group_card_item
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: FeedGroupCardItemBinding, position: Int) {
|
||||||
viewHolder.title.text = name
|
viewBinding.title.text = name
|
||||||
viewHolder.icon.setImageResource(icon.getDrawableRes(viewHolder.containerView.context))
|
viewBinding.icon.setImageResource(icon.getDrawableRes(viewBinding.root.context))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initializeViewBinding(view: View) = FeedGroupCardItemBinding.bind(view)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,16 @@ import android.view.View
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.xwray.groupie.GroupAdapter
|
import com.xwray.groupie.GroupAdapter
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.GroupieViewHolder
|
||||||
import kotlinx.android.synthetic.main.feed_item_carousel.recycler_view
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.databinding.FeedItemCarouselBinding
|
||||||
import org.schabi.newpipe.local.subscription.decoration.FeedGroupCarouselDecoration
|
import org.schabi.newpipe.local.subscription.decoration.FeedGroupCarouselDecoration
|
||||||
|
|
||||||
class FeedGroupCarouselItem(context: Context, private val carouselAdapter: GroupAdapter<GroupieViewHolder>) : Item() {
|
class FeedGroupCarouselItem(
|
||||||
|
context: Context,
|
||||||
|
private val carouselAdapter: GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>
|
||||||
|
) : BindableItem<FeedItemCarouselBinding>() {
|
||||||
private val feedGroupCarouselDecoration = FeedGroupCarouselDecoration(context)
|
private val feedGroupCarouselDecoration = FeedGroupCarouselDecoration(context)
|
||||||
|
|
||||||
private var linearLayoutManager: LinearLayoutManager? = null
|
private var linearLayoutManager: LinearLayoutManager? = null
|
||||||
|
@ -30,12 +33,12 @@ class FeedGroupCarouselItem(context: Context, private val carouselAdapter: Group
|
||||||
listState = state
|
listState = state
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createViewHolder(itemView: View): GroupieViewHolder {
|
override fun initializeViewBinding(view: View): FeedItemCarouselBinding {
|
||||||
val viewHolder = super.createViewHolder(itemView)
|
val viewHolder = FeedItemCarouselBinding.bind(view)
|
||||||
|
|
||||||
linearLayoutManager = LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false)
|
linearLayoutManager = LinearLayoutManager(view.context, RecyclerView.HORIZONTAL, false)
|
||||||
|
|
||||||
viewHolder.recycler_view.apply {
|
viewHolder.recyclerView.apply {
|
||||||
layoutManager = linearLayoutManager
|
layoutManager = linearLayoutManager
|
||||||
adapter = carouselAdapter
|
adapter = carouselAdapter
|
||||||
addItemDecoration(feedGroupCarouselDecoration)
|
addItemDecoration(feedGroupCarouselDecoration)
|
||||||
|
@ -44,12 +47,12 @@ class FeedGroupCarouselItem(context: Context, private val carouselAdapter: Group
|
||||||
return viewHolder
|
return viewHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: FeedItemCarouselBinding, position: Int) {
|
||||||
viewHolder.recycler_view.apply { adapter = carouselAdapter }
|
viewBinding.recyclerView.apply { adapter = carouselAdapter }
|
||||||
linearLayoutManager?.onRestoreInstanceState(listState)
|
linearLayoutManager?.onRestoreInstanceState(listState)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(viewHolder: GroupieViewHolder) {
|
override fun unbind(viewHolder: GroupieViewHolder<FeedItemCarouselBinding>) {
|
||||||
super.unbind(viewHolder)
|
super.unbind(viewHolder)
|
||||||
|
|
||||||
listState = linearLayoutManager?.onSaveInstanceState()
|
listState = linearLayoutManager?.onSaveInstanceState()
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper.DOWN
|
import androidx.recyclerview.widget.ItemTouchHelper.DOWN
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper.UP
|
import androidx.recyclerview.widget.ItemTouchHelper.UP
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.GroupieViewHolder
|
||||||
import kotlinx.android.synthetic.main.feed_group_reorder_item.group_icon
|
|
||||||
import kotlinx.android.synthetic.main.feed_group_reorder_item.group_name
|
|
||||||
import kotlinx.android.synthetic.main.feed_group_reorder_item.handle
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
||||||
|
import org.schabi.newpipe.databinding.FeedGroupReorderItemBinding
|
||||||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
||||||
|
|
||||||
data class FeedGroupReorderItem(
|
data class FeedGroupReorderItem(
|
||||||
|
@ -18,7 +17,7 @@ data class FeedGroupReorderItem(
|
||||||
val name: String,
|
val name: String,
|
||||||
val icon: FeedGroupIcon,
|
val icon: FeedGroupIcon,
|
||||||
val dragCallback: ItemTouchHelper
|
val dragCallback: ItemTouchHelper
|
||||||
) : Item() {
|
) : BindableItem<FeedGroupReorderItemBinding>() {
|
||||||
constructor (feedGroupEntity: FeedGroupEntity, dragCallback: ItemTouchHelper) :
|
constructor (feedGroupEntity: FeedGroupEntity, dragCallback: ItemTouchHelper) :
|
||||||
this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon, dragCallback)
|
this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon, dragCallback)
|
||||||
|
|
||||||
|
@ -31,12 +30,12 @@ data class FeedGroupReorderItem(
|
||||||
|
|
||||||
override fun getLayout(): Int = R.layout.feed_group_reorder_item
|
override fun getLayout(): Int = R.layout.feed_group_reorder_item
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: FeedGroupReorderItemBinding, position: Int) {
|
||||||
viewHolder.group_name.text = name
|
viewBinding.groupName.text = name
|
||||||
viewHolder.group_icon.setImageResource(icon.getDrawableRes(viewHolder.containerView.context))
|
viewBinding.groupIcon.setImageResource(icon.getDrawableRes(viewBinding.root.context))
|
||||||
viewHolder.handle.setOnTouchListener { _, event ->
|
viewBinding.handle.setOnTouchListener { _, event ->
|
||||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||||
dragCallback.startDrag(viewHolder)
|
dragCallback.startDrag(GroupieViewHolder(viewBinding))
|
||||||
return@setOnTouchListener true
|
return@setOnTouchListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,4 +46,6 @@ data class FeedGroupReorderItem(
|
||||||
override fun getDragDirs(): Int {
|
override fun getDragDirs(): Int {
|
||||||
return UP or DOWN
|
return UP or DOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initializeViewBinding(view: View) = FeedGroupReorderItemBinding.bind(view)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,10 @@ import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.GroupieViewHolder
|
||||||
import kotlinx.android.synthetic.main.feed_import_export_group.export_to_options
|
|
||||||
import kotlinx.android.synthetic.main.feed_import_export_group.import_export
|
|
||||||
import kotlinx.android.synthetic.main.feed_import_export_group.import_export_expand_icon
|
|
||||||
import kotlinx.android.synthetic.main.feed_import_export_group.import_export_options
|
|
||||||
import kotlinx.android.synthetic.main.feed_import_export_group.import_from_options
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.databinding.FeedImportExportGroupBinding
|
||||||
import org.schabi.newpipe.extractor.NewPipe
|
import org.schabi.newpipe.extractor.NewPipe
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException
|
||||||
import org.schabi.newpipe.ktx.animateRotation
|
import org.schabi.newpipe.ktx.animateRotation
|
||||||
|
@ -27,50 +23,52 @@ class FeedImportExportItem(
|
||||||
val onImportFromServiceSelected: (Int) -> Unit,
|
val onImportFromServiceSelected: (Int) -> Unit,
|
||||||
val onExportSelected: () -> Unit,
|
val onExportSelected: () -> Unit,
|
||||||
var isExpanded: Boolean = false
|
var isExpanded: Boolean = false
|
||||||
) : Item() {
|
) : BindableItem<FeedImportExportGroupBinding>() {
|
||||||
companion object {
|
companion object {
|
||||||
const val REFRESH_EXPANDED_STATUS = 123
|
const val REFRESH_EXPANDED_STATUS = 123
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int, payloads: MutableList<Any>) {
|
override fun bind(viewBinding: FeedImportExportGroupBinding, position: Int, payloads: MutableList<Any>) {
|
||||||
if (payloads.contains(REFRESH_EXPANDED_STATUS)) {
|
if (payloads.contains(REFRESH_EXPANDED_STATUS)) {
|
||||||
viewHolder.import_export_options.apply { if (isExpanded) expand() else collapse() }
|
viewBinding.importExportOptions.apply { if (isExpanded) expand() else collapse() }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
super.bind(viewHolder, position, payloads)
|
super.bind(viewBinding, position, payloads)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLayout(): Int = R.layout.feed_import_export_group
|
override fun getLayout(): Int = R.layout.feed_import_export_group
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: FeedImportExportGroupBinding, position: Int) {
|
||||||
if (viewHolder.import_from_options.childCount == 0) setupImportFromItems(viewHolder.import_from_options)
|
if (viewBinding.importFromOptions.childCount == 0) setupImportFromItems(viewBinding.importFromOptions)
|
||||||
if (viewHolder.export_to_options.childCount == 0) setupExportToItems(viewHolder.export_to_options)
|
if (viewBinding.exportToOptions.childCount == 0) setupExportToItems(viewBinding.exportToOptions)
|
||||||
|
|
||||||
expandIconListener?.let { viewHolder.import_export_options.removeListener(it) }
|
expandIconListener?.let { viewBinding.importExportOptions.removeListener(it) }
|
||||||
expandIconListener = CollapsibleView.StateListener { newState ->
|
expandIconListener = CollapsibleView.StateListener { newState ->
|
||||||
viewHolder.import_export_expand_icon.animateRotation(
|
viewBinding.importExportExpandIcon.animateRotation(
|
||||||
250, if (newState == CollapsibleView.COLLAPSED) 0 else 180
|
250, if (newState == CollapsibleView.COLLAPSED) 0 else 180
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewHolder.import_export_options.currentState = if (isExpanded) CollapsibleView.EXPANDED else CollapsibleView.COLLAPSED
|
viewBinding.importExportOptions.currentState = if (isExpanded) CollapsibleView.EXPANDED else CollapsibleView.COLLAPSED
|
||||||
viewHolder.import_export_expand_icon.rotation = if (isExpanded) 180F else 0F
|
viewBinding.importExportExpandIcon.rotation = if (isExpanded) 180F else 0F
|
||||||
viewHolder.import_export_options.ready()
|
viewBinding.importExportOptions.ready()
|
||||||
|
|
||||||
viewHolder.import_export_options.addListener(expandIconListener)
|
viewBinding.importExportOptions.addListener(expandIconListener)
|
||||||
viewHolder.import_export.setOnClickListener {
|
viewBinding.importExport.setOnClickListener {
|
||||||
viewHolder.import_export_options.switchState()
|
viewBinding.importExportOptions.switchState()
|
||||||
isExpanded = viewHolder.import_export_options.currentState == CollapsibleView.EXPANDED
|
isExpanded = viewBinding.importExportOptions.currentState == CollapsibleView.EXPANDED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(viewHolder: GroupieViewHolder) {
|
override fun unbind(viewHolder: GroupieViewHolder<FeedImportExportGroupBinding>) {
|
||||||
super.unbind(viewHolder)
|
super.unbind(viewHolder)
|
||||||
expandIconListener?.let { viewHolder.import_export_options.removeListener(it) }
|
expandIconListener?.let { viewHolder.binding.importExportOptions.removeListener(it) }
|
||||||
expandIconListener = null
|
expandIconListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initializeViewBinding(view: View) = FeedImportExportGroupBinding.bind(view)
|
||||||
|
|
||||||
private var expandIconListener: CollapsibleView.StateListener? = null
|
private var expandIconListener: CollapsibleView.StateListener? = null
|
||||||
|
|
||||||
private fun addItemView(title: String, @DrawableRes icon: Int, container: ViewGroup): View {
|
private fun addItemView(title: String, @DrawableRes icon: Int, container: ViewGroup): View {
|
||||||
|
@ -117,7 +115,8 @@ class FeedImportExportItem(
|
||||||
private fun setupExportToItems(listHolder: ViewGroup) {
|
private fun setupExportToItems(listHolder: ViewGroup) {
|
||||||
val previousBackupItem = addItemView(
|
val previousBackupItem = addItemView(
|
||||||
listHolder.context.getString(R.string.file),
|
listHolder.context.getString(R.string.file),
|
||||||
ThemeHelper.resolveResourceIdFromAttr(listHolder.context, R.attr.ic_save), listHolder
|
ThemeHelper.resolveResourceIdFromAttr(listHolder.context, R.attr.ic_save),
|
||||||
|
listHolder
|
||||||
)
|
)
|
||||||
previousBackupItem.setOnClickListener { onExportSelected() }
|
previousBackupItem.setOnClickListener { onExportSelected() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
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 androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
|
||||||
import kotlinx.android.synthetic.main.header_with_menu_item.header_menu_item
|
|
||||||
import kotlinx.android.synthetic.main.header_with_menu_item.header_title
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.databinding.HeaderWithMenuItemBinding
|
||||||
|
|
||||||
class HeaderWithMenuItem(
|
class HeaderWithMenuItem(
|
||||||
val title: String,
|
val title: String,
|
||||||
|
@ -15,37 +14,37 @@ class HeaderWithMenuItem(
|
||||||
var showMenuItem: Boolean = true,
|
var showMenuItem: Boolean = true,
|
||||||
private val onClickListener: (() -> Unit)? = null,
|
private val onClickListener: (() -> Unit)? = null,
|
||||||
private val menuItemOnClickListener: (() -> Unit)? = null
|
private val menuItemOnClickListener: (() -> Unit)? = null
|
||||||
) : Item() {
|
) : BindableItem<HeaderWithMenuItemBinding>() {
|
||||||
companion object {
|
companion object {
|
||||||
const val PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM = 1
|
const val PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLayout(): Int = R.layout.header_with_menu_item
|
override fun getLayout(): Int = R.layout.header_with_menu_item
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int, payloads: MutableList<Any>) {
|
override fun bind(viewBinding: HeaderWithMenuItemBinding, position: Int, payloads: MutableList<Any>) {
|
||||||
if (payloads.contains(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM)) {
|
if (payloads.contains(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM)) {
|
||||||
updateMenuItemVisibility(viewHolder)
|
updateMenuItemVisibility(viewBinding)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
super.bind(viewHolder, position, payloads)
|
super.bind(viewBinding, position, payloads)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: HeaderWithMenuItemBinding, position: Int) {
|
||||||
viewHolder.header_title.text = title
|
viewBinding.headerTitle.text = title
|
||||||
viewHolder.header_menu_item.setImageResource(itemIcon)
|
viewBinding.headerMenuItem.setImageResource(itemIcon)
|
||||||
|
|
||||||
val listener: OnClickListener? =
|
val listener = onClickListener?.let { OnClickListener { onClickListener.invoke() } }
|
||||||
onClickListener?.let { OnClickListener { onClickListener.invoke() } }
|
viewBinding.root.setOnClickListener(listener)
|
||||||
viewHolder.root.setOnClickListener(listener)
|
|
||||||
|
|
||||||
val menuItemListener: OnClickListener? =
|
val menuItemListener = menuItemOnClickListener?.let { OnClickListener { menuItemOnClickListener.invoke() } }
|
||||||
menuItemOnClickListener?.let { OnClickListener { menuItemOnClickListener.invoke() } }
|
viewBinding.headerMenuItem.setOnClickListener(menuItemListener)
|
||||||
viewHolder.header_menu_item.setOnClickListener(menuItemListener)
|
updateMenuItemVisibility(viewBinding)
|
||||||
updateMenuItemVisibility(viewHolder)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMenuItemVisibility(viewHolder: GroupieViewHolder) {
|
override fun initializeViewBinding(view: View) = HeaderWithMenuItemBinding.bind(view)
|
||||||
viewHolder.header_menu_item.isVisible = showMenuItem
|
|
||||||
|
private fun updateMenuItemVisibility(viewBinding: HeaderWithMenuItemBinding) {
|
||||||
|
viewBinding.headerMenuItem.isVisible = showMenuItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
|
||||||
import kotlinx.android.synthetic.main.picker_icon_item.icon_view
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.databinding.PickerIconItemBinding
|
||||||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
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
|
@DrawableRes
|
||||||
val iconRes: Int = icon.getDrawableRes(context)
|
val iconRes: Int = icon.getDrawableRes(context)
|
||||||
|
|
||||||
override fun getLayout(): Int = R.layout.picker_icon_item
|
override fun getLayout(): Int = R.layout.picker_icon_item
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: PickerIconItemBinding, position: Int) {
|
||||||
viewHolder.icon_view.setImageResource(iconRes)
|
viewBinding.iconView.setImageResource(iconRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initializeViewBinding(view: View) = PickerIconItemBinding.bind(view)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader
|
import com.nostra13.universalimageloader.core.ImageLoader
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.viewbinding.GroupieViewHolder
|
||||||
import kotlinx.android.synthetic.main.picker_subscription_item.*
|
|
||||||
import kotlinx.android.synthetic.main.picker_subscription_item.view.*
|
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
||||||
|
import org.schabi.newpipe.databinding.PickerSubscriptionItemBinding
|
||||||
import org.schabi.newpipe.ktx.AnimationType
|
import org.schabi.newpipe.ktx.AnimationType
|
||||||
import org.schabi.newpipe.ktx.animate
|
import org.schabi.newpipe.ktx.animate
|
||||||
import org.schabi.newpipe.util.ImageDisplayConstants
|
import org.schabi.newpipe.util.ImageDisplayConstants
|
||||||
|
@ -16,31 +16,36 @@ import org.schabi.newpipe.util.ImageDisplayConstants
|
||||||
data class PickerSubscriptionItem(
|
data class PickerSubscriptionItem(
|
||||||
val subscriptionEntity: SubscriptionEntity,
|
val subscriptionEntity: SubscriptionEntity,
|
||||||
var isSelected: Boolean = false
|
var isSelected: Boolean = false
|
||||||
) : Item() {
|
) : BindableItem<PickerSubscriptionItemBinding>() {
|
||||||
override fun getId(): Long = subscriptionEntity.uid
|
override fun getId(): Long = subscriptionEntity.uid
|
||||||
override fun getLayout(): Int = R.layout.picker_subscription_item
|
override fun getLayout(): Int = R.layout.picker_subscription_item
|
||||||
override fun getSpanSize(spanCount: Int, position: Int): Int = 1
|
override fun getSpanSize(spanCount: Int, position: Int): Int = 1
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
override fun bind(viewBinding: PickerSubscriptionItemBinding, position: Int) {
|
||||||
ImageLoader.getInstance().displayImage(
|
ImageLoader.getInstance().displayImage(
|
||||||
subscriptionEntity.avatarUrl,
|
subscriptionEntity.avatarUrl,
|
||||||
viewHolder.thumbnail_view, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS
|
viewBinding.thumbnailView, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS
|
||||||
)
|
)
|
||||||
|
|
||||||
viewHolder.title_view.text = subscriptionEntity.name
|
viewBinding.titleView.text = subscriptionEntity.name
|
||||||
viewHolder.selected_highlight.isVisible = isSelected
|
viewBinding.selectedHighlight.isVisible = isSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(viewHolder: GroupieViewHolder) {
|
override fun unbind(viewHolder: GroupieViewHolder<PickerSubscriptionItemBinding>) {
|
||||||
super.unbind(viewHolder)
|
super.unbind(viewHolder)
|
||||||
|
|
||||||
viewHolder.selected_highlight.animate().setListener(null).cancel()
|
viewHolder.binding.selectedHighlight.apply {
|
||||||
viewHolder.selected_highlight.visibility = View.GONE
|
animate().setListener(null).cancel()
|
||||||
viewHolder.selected_highlight.alpha = 1F
|
isGone = true
|
||||||
|
alpha = 1F
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun initializeViewBinding(view: View) = PickerSubscriptionItemBinding.bind(view)
|
||||||
|
|
||||||
fun updateSelected(containerView: View, isSelected: Boolean) {
|
fun updateSelected(containerView: View, isSelected: Boolean) {
|
||||||
this.isSelected = isSelected
|
this.isSelected = isSelected
|
||||||
containerView.selected_highlight.animate(isSelected, 150, AnimationType.LIGHT_SCALE_AND_ALPHA)
|
PickerSubscriptionItemBinding.bind(containerView).selectedHighlight
|
||||||
|
.animate(isSelected, 150, AnimationType.LIGHT_SCALE_AND_ALPHA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue