recycler: fix viewholder inflation
This commit is contained in:
@@ -19,11 +19,11 @@
|
|||||||
package org.oxycblt.auxio.detail.decision
|
package org.oxycblt.auxio.detail.decision
|
||||||
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.music.resolve
|
import org.oxycblt.auxio.music.resolve
|
||||||
import org.oxycblt.auxio.util.context
|
import org.oxycblt.auxio.util.context
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
@@ -48,14 +48,14 @@ class ArtistShowChoice(private val listener: ClickableListListener<Artist>) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [DialogRecyclerView.ViewHolder] that displays a smaller variant of a typical [Artist] item, for
|
* A [RecyclerView.ViewHolder] that displays a smaller variant of a typical [Artist] item, for use
|
||||||
* use [ArtistShowChoice]. Use [from] to create an instance.
|
* [ArtistShowChoice]. Use [from] to create an instance.
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class ArtistNavigationChoiceViewHolder
|
class ArtistNavigationChoiceViewHolder
|
||||||
private constructor(private val binding: ItemPickerChoiceBinding) :
|
private constructor(private val binding: ItemPickerChoiceBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -184,7 +184,16 @@ class DiscDividerViewHolder private constructor(divider: MaterialDivider) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: ViewGroup) = DiscDividerViewHolder(MaterialDivider(parent.context))
|
fun from(parent: ViewGroup) =
|
||||||
|
DiscDividerViewHolder(
|
||||||
|
MaterialDivider(parent.context).apply {
|
||||||
|
layoutParams =
|
||||||
|
RecyclerView.LayoutParams(
|
||||||
|
RecyclerView.LayoutParams.MATCH_PARENT,
|
||||||
|
RecyclerView.LayoutParams.WRAP_CONTENT,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package org.oxycblt.auxio.detail.list
|
package org.oxycblt.auxio.detail.list
|
||||||
|
|
||||||
import android.text.format.Formatter
|
import android.text.format.Formatter
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -27,7 +26,6 @@ import org.oxycblt.auxio.R
|
|||||||
import org.oxycblt.auxio.databinding.ItemSongPropertyBinding
|
import org.oxycblt.auxio.databinding.ItemSongPropertyBinding
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.music.resolve
|
import org.oxycblt.auxio.music.resolve
|
||||||
import org.oxycblt.auxio.music.resolveNames
|
import org.oxycblt.auxio.music.resolveNames
|
||||||
import org.oxycblt.auxio.playback.formatDurationMs
|
import org.oxycblt.auxio.playback.formatDurationMs
|
||||||
@@ -95,7 +93,7 @@ data class SongProperty(@StringRes val name: Int, val value: Value) {
|
|||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class SongPropertyViewHolder private constructor(private val binding: ItemSongPropertyBinding) :
|
class SongPropertyViewHolder private constructor(private val binding: ItemSongPropertyBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bind(property: SongProperty) {
|
fun bind(property: SongProperty) {
|
||||||
val context = binding.context
|
val context = binding.context
|
||||||
binding.propertyName.hint = context.getString(property.name)
|
binding.propertyName.hint = context.getString(property.name)
|
||||||
@@ -161,8 +159,10 @@ class SongPropertyViewHolder private constructor(private val binding: ItemSongPr
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
SongPropertyViewHolder(ItemSongPropertyBinding.inflate(parent.context.inflater))
|
SongPropertyViewHolder(
|
||||||
|
ItemSongPropertyBinding.inflate(parent.context.inflater, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -19,13 +19,11 @@
|
|||||||
package org.oxycblt.auxio.home.tabs
|
package org.oxycblt.auxio.home.tabs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.ItemTabBinding
|
import org.oxycblt.auxio.databinding.ItemTabBinding
|
||||||
import org.oxycblt.auxio.list.EditClickListListener
|
import org.oxycblt.auxio.list.EditClickListListener
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.music.MusicType
|
import org.oxycblt.auxio.music.MusicType
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
import timber.log.Timber as L
|
import timber.log.Timber as L
|
||||||
@@ -98,7 +96,7 @@ class TabAdapter(private val listener: EditClickListListener<Tab>) :
|
|||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class TabViewHolder private constructor(private val binding: ItemTabBinding) :
|
class TabViewHolder private constructor(private val binding: ItemTabBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
@@ -133,6 +131,7 @@ class TabViewHolder private constructor(private val binding: ItemTabBinding) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) = TabViewHolder(ItemTabBinding.inflate(parent.context.inflater))
|
fun from(parent: ViewGroup) =
|
||||||
|
TabViewHolder(ItemTabBinding.inflate(parent.context.inflater, parent, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ package org.oxycblt.auxio.list.menu
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemMenuOptionBinding
|
import org.oxycblt.auxio.databinding.ItemMenuOptionBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,12 +44,12 @@ class MenuItemAdapter(private val listener: ClickableListListener<MenuItem>) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [DialogRecyclerView.ViewHolder] that displays a [MenuItem].
|
* A [RecyclerView.ViewHolder] that displays a [MenuItem].
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class MenuItemViewHolder private constructor(private val binding: ItemMenuOptionBinding) :
|
class MenuItemViewHolder private constructor(private val binding: ItemMenuOptionBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
@@ -73,7 +73,9 @@ class MenuItemViewHolder private constructor(private val binding: ItemMenuOption
|
|||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: ViewGroup) =
|
fun from(parent: ViewGroup) =
|
||||||
MenuItemViewHolder(ItemMenuOptionBinding.inflate(parent.context.inflater))
|
MenuItemViewHolder(
|
||||||
|
ItemMenuOptionBinding.inflate(parent.context.inflater, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package org.oxycblt.auxio.list.recycler
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
@@ -31,9 +30,7 @@ import org.oxycblt.auxio.R
|
|||||||
import org.oxycblt.auxio.util.getDimenPixels
|
import org.oxycblt.auxio.util.getDimenPixels
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [RecyclerView] intended for use in Dialogs, adding features such as:
|
* A [RecyclerView] intended for use in dialogs, with NestedScrollView-style scroll indicators.
|
||||||
* - NestedScrollView scrollIndicators behavior emulation
|
|
||||||
* - Dialog-specific [ViewHolder] that automatically resolves certain issues.
|
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
@@ -102,13 +99,4 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
bottomDivider.isInvisible =
|
bottomDivider.isInvisible =
|
||||||
lmm.findLastCompletelyVisibleItemPosition() == (lmm.itemCount - 1)
|
lmm.findLastCompletelyVisibleItemPosition() == (lmm.itemCount - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A [RecyclerView.ViewHolder] that implements dialog-specific fixes. */
|
|
||||||
abstract class ViewHolder(root: View) : RecyclerView.ViewHolder(root) {
|
|
||||||
init {
|
|
||||||
// ViewHolders are not automatically full-width in dialogs, manually resize
|
|
||||||
// them to be as such.
|
|
||||||
root.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
package org.oxycblt.auxio.list.recycler
|
package org.oxycblt.auxio.list.recycler
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.view.View
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.divider.MaterialDivider
|
import com.google.android.material.divider.MaterialDivider
|
||||||
import org.oxycblt.auxio.IntegerTable
|
import org.oxycblt.auxio.IntegerTable
|
||||||
@@ -83,7 +83,8 @@ class SongViewHolder private constructor(private val binding: ItemSongBinding) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) = SongViewHolder(ItemSongBinding.inflate(parent.context.inflater))
|
fun from(parent: ViewGroup) =
|
||||||
|
SongViewHolder(ItemSongBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
@@ -133,7 +134,8 @@ class AlbumViewHolder private constructor(private val binding: ItemParentBinding
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) = AlbumViewHolder(ItemParentBinding.inflate(parent.context.inflater))
|
fun from(parent: ViewGroup) =
|
||||||
|
AlbumViewHolder(ItemParentBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
@@ -198,8 +200,8 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
ArtistViewHolder(ItemParentBinding.inflate(parent.context.inflater))
|
ArtistViewHolder(ItemParentBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
@@ -256,7 +258,8 @@ class GenreViewHolder private constructor(private val binding: ItemParentBinding
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) = GenreViewHolder(ItemParentBinding.inflate(parent.context.inflater))
|
fun from(parent: ViewGroup) =
|
||||||
|
GenreViewHolder(ItemParentBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
@@ -313,8 +316,8 @@ class PlaylistViewHolder private constructor(private val binding: ItemParentBind
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
PlaylistViewHolder(ItemParentBinding.inflate(parent.context.inflater))
|
PlaylistViewHolder(ItemParentBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
@@ -351,8 +354,8 @@ class BasicHeaderViewHolder private constructor(private val binding: ItemHeaderB
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
BasicHeaderViewHolder(ItemHeaderBinding.inflate(parent.context.inflater))
|
BasicHeaderViewHolder(ItemHeaderBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
@@ -381,7 +384,16 @@ class DividerViewHolder private constructor(divider: MaterialDivider) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) = DividerViewHolder(MaterialDivider(parent.context))
|
fun from(parent: ViewGroup) =
|
||||||
|
DividerViewHolder(
|
||||||
|
MaterialDivider(parent.context).apply {
|
||||||
|
layoutParams =
|
||||||
|
RecyclerView.LayoutParams(
|
||||||
|
RecyclerView.LayoutParams.MATCH_PARENT,
|
||||||
|
RecyclerView.LayoutParams.WRAP_CONTENT,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -18,13 +18,12 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.list.sort
|
package org.oxycblt.auxio.list.sort
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemSortModeBinding
|
import org.oxycblt.auxio.databinding.ItemSortModeBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.util.context
|
import org.oxycblt.auxio.util.context
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
|
|
||||||
@@ -78,12 +77,12 @@ class SortModeAdapter(private val listener: ClickableListListener<Sort.Mode>) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [DialogRecyclerView.ViewHolder] that displays a [Sort.Mode].
|
* A [RecyclerView.ViewHolder] that displays a [Sort.Mode].
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class SortModeViewHolder private constructor(private val binding: ItemSortModeBinding) :
|
class SortModeViewHolder private constructor(private val binding: ItemSortModeBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
@@ -105,8 +104,8 @@ class SortModeViewHolder private constructor(private val binding: ItemSortModeBi
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
SortModeViewHolder(ItemSortModeBinding.inflate(parent.context.inflater))
|
SortModeViewHolder(ItemSortModeBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
object : DiffUtil.ItemCallback<Sort.Mode>() {
|
object : DiffUtil.ItemCallback<Sort.Mode>() {
|
||||||
|
|||||||
@@ -18,11 +18,9 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.music.decision
|
package org.oxycblt.auxio.music.decision
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemNewPlaylistChoiceBinding
|
import org.oxycblt.auxio.databinding.ItemNewPlaylistChoiceBinding
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +57,7 @@ class NewPlaylistFooterAdapter(private val listener: Listener) :
|
|||||||
*/
|
*/
|
||||||
class NewPlaylistFooterViewHolder
|
class NewPlaylistFooterViewHolder
|
||||||
private constructor(private val binding: ItemNewPlaylistChoiceBinding) :
|
private constructor(private val binding: ItemNewPlaylistChoiceBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
@@ -76,9 +74,9 @@ private constructor(private val binding: ItemNewPlaylistChoiceBinding) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
NewPlaylistFooterViewHolder(
|
NewPlaylistFooterViewHolder(
|
||||||
ItemNewPlaylistChoiceBinding.inflate(parent.context.inflater)
|
ItemNewPlaylistChoiceBinding.inflate(parent.context.inflater, parent, false)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,12 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.music.decision
|
package org.oxycblt.auxio.music.decision
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.music.resolve
|
import org.oxycblt.auxio.music.resolve
|
||||||
import org.oxycblt.auxio.util.context
|
import org.oxycblt.auxio.util.context
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
@@ -48,13 +47,13 @@ class PlaylistChoiceAdapter(val listener: ClickableListListener<PlaylistChoice>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [DialogRecyclerView.ViewHolder] that displays an individual playlist choice. Use [from] to
|
* A [RecyclerView.ViewHolder] that displays an individual playlist choice. Use [from] to create an
|
||||||
* create an instance.
|
* instance.
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class PlaylistChoiceViewHolder private constructor(private val binding: ItemPickerChoiceBinding) :
|
class PlaylistChoiceViewHolder private constructor(private val binding: ItemPickerChoiceBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bind(choice: PlaylistChoice, listener: ClickableListListener<PlaylistChoice>) {
|
fun bind(choice: PlaylistChoice, listener: ClickableListListener<PlaylistChoice>) {
|
||||||
listener.bind(choice, this)
|
listener.bind(choice, this)
|
||||||
binding.pickerImage.apply {
|
binding.pickerImage.apply {
|
||||||
@@ -71,8 +70,10 @@ class PlaylistChoiceViewHolder private constructor(private val binding: ItemPick
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
PlaylistChoiceViewHolder(ItemPickerChoiceBinding.inflate(parent.context.inflater))
|
PlaylistChoiceViewHolder(
|
||||||
|
ItemPickerChoiceBinding.inflate(parent.context.inflater, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.ItemMusicLocationBinding
|
import org.oxycblt.auxio.databinding.ItemMusicLocationBinding
|
||||||
import org.oxycblt.auxio.databinding.ItemNoLocationsBinding
|
import org.oxycblt.auxio.databinding.ItemNoLocationsBinding
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.util.context
|
import org.oxycblt.auxio.util.context
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
import org.oxycblt.musikr.fs.Location
|
import org.oxycblt.musikr.fs.Location
|
||||||
@@ -118,7 +117,7 @@ class LocationAdapter<T : Location>(private val listener: Listener) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LocationViewHolder<T : Location>(private val binding: ItemMusicLocationBinding) :
|
class LocationViewHolder<T : Location>(private val binding: ItemMusicLocationBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
||||||
fun bind(location: T, listener: LocationAdapter.Listener) {
|
fun bind(location: T, listener: LocationAdapter.Listener) {
|
||||||
binding.locationPath.text = location.path.resolve(binding.context)
|
binding.locationPath.text = location.path.resolve(binding.context)
|
||||||
@@ -140,7 +139,7 @@ class LocationViewHolder<T : Location>(private val binding: ItemMusicLocationBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
class EmptyLocationViewHolder(private val binding: ItemNoLocationsBinding) :
|
class EmptyLocationViewHolder(private val binding: ItemNoLocationsBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
||||||
fun bind() {
|
fun bind() {
|
||||||
binding.locationPath.text = binding.context.getString(R.string.lbl_no_folders)
|
binding.locationPath.text = binding.context.getString(R.string.lbl_no_folders)
|
||||||
|
|||||||
+8
-7
@@ -18,13 +18,12 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.playback.decision
|
package org.oxycblt.auxio.playback.decision
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.music.resolve
|
import org.oxycblt.auxio.music.resolve
|
||||||
import org.oxycblt.auxio.util.context
|
import org.oxycblt.auxio.util.context
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
@@ -49,14 +48,14 @@ class ArtistPlaybackChoiceAdapter(private val listener: ClickableListListener<Ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [DialogRecyclerView.ViewHolder] that displays a smaller variant of a typical [Artist] item, for
|
* A [RecyclerView.ViewHolder] that displays a smaller variant of a typical [Artist] item, for use
|
||||||
* use [ArtistPlaybackChoiceAdapter]. Use [from] to create an instance.
|
* [ArtistPlaybackChoiceAdapter]. Use [from] to create an instance.
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class ArtistPlaybackChoiceViewHolder
|
class ArtistPlaybackChoiceViewHolder
|
||||||
private constructor(private val binding: ItemPickerChoiceBinding) :
|
private constructor(private val binding: ItemPickerChoiceBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
@@ -77,8 +76,10 @@ private constructor(private val binding: ItemPickerChoiceBinding) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
ArtistPlaybackChoiceViewHolder(ItemPickerChoiceBinding.inflate(parent.context.inflater))
|
ArtistPlaybackChoiceViewHolder(
|
||||||
|
ItemPickerChoiceBinding.inflate(parent.context.inflater, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -18,13 +18,12 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.playback.decision
|
package org.oxycblt.auxio.playback.decision
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
import org.oxycblt.auxio.databinding.ItemPickerChoiceBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
||||||
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
|
|
||||||
import org.oxycblt.auxio.music.resolve
|
import org.oxycblt.auxio.music.resolve
|
||||||
import org.oxycblt.auxio.util.context
|
import org.oxycblt.auxio.util.context
|
||||||
import org.oxycblt.auxio.util.inflater
|
import org.oxycblt.auxio.util.inflater
|
||||||
@@ -49,14 +48,14 @@ class GenrePlaybackChoiceAdapter(private val listener: ClickableListListener<Gen
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [DialogRecyclerView.ViewHolder] that displays a smaller variant of a typical [Genre] item, for
|
* A [RecyclerView.ViewHolder] that displays a smaller variant of a typical [Genre] item, for use
|
||||||
* use [GenrePlaybackChoiceAdapter]. Use [from] to create an instance.
|
* [GenrePlaybackChoiceAdapter]. Use [from] to create an instance.
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class GenrePlaybackChoiceViewHolder
|
class GenrePlaybackChoiceViewHolder
|
||||||
private constructor(private val binding: ItemPickerChoiceBinding) :
|
private constructor(private val binding: ItemPickerChoiceBinding) :
|
||||||
DialogRecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
/**
|
/**
|
||||||
* Bind new data to this instance.
|
* Bind new data to this instance.
|
||||||
*
|
*
|
||||||
@@ -77,8 +76,10 @@ private constructor(private val binding: ItemPickerChoiceBinding) :
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
GenrePlaybackChoiceViewHolder(ItemPickerChoiceBinding.inflate(parent.context.inflater))
|
GenrePlaybackChoiceViewHolder(
|
||||||
|
ItemPickerChoiceBinding.inflate(parent.context.inflater, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package org.oxycblt.auxio.playback.queue
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -174,8 +173,10 @@ class QueueSongViewHolder private constructor(private val binding: ItemEditableS
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
QueueSongViewHolder(ItemEditableSongBinding.inflate(parent.context.inflater))
|
QueueSongViewHolder(
|
||||||
|
ItemEditableSongBinding.inflate(parent.context.inflater, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK = SongViewHolder.DIFF_CALLBACK
|
val DIFF_CALLBACK = SongViewHolder.DIFF_CALLBACK
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package org.oxycblt.auxio.ui.accent
|
package org.oxycblt.auxio.ui.accent
|
||||||
|
|
||||||
import android.R as SR
|
import android.R as SR
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.TooltipCompat
|
import androidx.appcompat.widget.TooltipCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -133,7 +132,7 @@ class AccentViewHolder private constructor(private val binding: ItemAccentBindin
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: View) =
|
fun from(parent: ViewGroup) =
|
||||||
AccentViewHolder(ItemAccentBinding.inflate(parent.context.inflater))
|
AccentViewHolder(ItemAccentBinding.inflate(parent.context.inflater, parent, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user