Fixing animations
This commit is contained in:
parent
5a51d0bfc0
commit
44baab2109
25 changed files with 476 additions and 386 deletions
|
@ -28,16 +28,17 @@ import com.bumptech.glide.Glide
|
|||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
|
||||
open class AlbumAdapter(
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Album>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Album>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsMultiSelectAdapter<AlbumAdapter.ViewHolder, Album>(
|
||||
activity,
|
||||
cabHolder,
|
||||
R.menu.menu_media_selection
|
||||
activity,
|
||||
cabHolder,
|
||||
R.menu.menu_media_selection
|
||||
), FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
var dataSet: ArrayList<Album>
|
||||
protected set
|
||||
|
||||
|
@ -87,14 +88,32 @@ open class AlbumAdapter(
|
|||
holder.itemView.isActivated = isChecked
|
||||
holder.title?.text = getAlbumTitle(album)
|
||||
holder.text?.text = getAlbumText(album)
|
||||
holder.playSongs?.setOnClickListener { album.songs?.let { songs -> MusicPlayerRemote.openQueue(songs, 0, true) } }
|
||||
holder.playSongs?.setOnClickListener {
|
||||
album.songs?.let { songs ->
|
||||
MusicPlayerRemote.openQueue(
|
||||
songs,
|
||||
0,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
loadAlbumCover(album, holder)
|
||||
}
|
||||
|
||||
protected open fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.title?.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
holder.text?.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
holder.title?.setTextColor(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
activity,
|
||||
ColorUtil.isColorLight(color)
|
||||
)
|
||||
)
|
||||
holder.text?.setTextColor(
|
||||
MaterialValueHelper.getSecondaryTextColor(
|
||||
activity,
|
||||
ColorUtil.isColorLight(color)
|
||||
)
|
||||
)
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
}
|
||||
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
|
||||
|
@ -106,17 +125,17 @@ open class AlbumAdapter(
|
|||
}
|
||||
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(activity).generatePalette(activity).build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
.checkIgnoreMediaStore(activity).generatePalette(activity).build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
|
||||
override fun onColorReady(color: Int) {
|
||||
setColors(color, holder)
|
||||
}
|
||||
})
|
||||
override fun onColorReady(color: Int) {
|
||||
setColors(color, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
@ -136,7 +155,7 @@ open class AlbumAdapter(
|
|||
}
|
||||
|
||||
override fun onMultipleItemAction(
|
||||
menuItem: MenuItem, selection: ArrayList<Album>
|
||||
menuItem: MenuItem, selection: ArrayList<Album>
|
||||
) {
|
||||
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
||||
}
|
||||
|
@ -152,10 +171,11 @@ open class AlbumAdapter(
|
|||
override fun getSectionName(position: Int): String {
|
||||
var sectionName: String? = null
|
||||
when (PreferenceUtil.getInstance(activity).albumSortOrder) {
|
||||
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName = dataSet[position].title
|
||||
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName =
|
||||
dataSet[position].title
|
||||
SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName
|
||||
SortOrder.AlbumSortOrder.ALBUM_YEAR -> return MusicUtil.getYearString(
|
||||
dataSet[position].year
|
||||
dataSet[position].year
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -175,13 +195,11 @@ open class AlbumAdapter(
|
|||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(
|
||||
R.string.transition_album_art
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(
|
||||
activity, dataSet[adapterPosition].id, activityOptions
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${dataSet[adapterPosition].id}"
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, dataSet[adapterPosition].id, activityOptions)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class AlbumCoverPagerAdapter(
|
||||
fm: FragmentManager,
|
||||
private val dataSet: ArrayList<Song>
|
||||
fm: FragmentManager,
|
||||
private val dataSet: ArrayList<Song>
|
||||
) : CustomFragmentStatePagerAdapter(fm) {
|
||||
|
||||
private var currentColorReceiver: AlbumCoverFragment.ColorReceiver? = null
|
||||
|
@ -90,9 +90,9 @@ class AlbumCoverPagerAdapter(
|
|||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val finalLayout = when {
|
||||
PreferenceUtil.getInstance(activity).carouselEffect() -> R.layout.fragment_album_carousel_cover
|
||||
|
@ -119,13 +119,13 @@ class AlbumCoverPagerAdapter(
|
|||
|
||||
private fun loadAlbumCover() {
|
||||
SongGlideRequest.Builder.from(Glide.with(requireContext()), song)
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext()).build()
|
||||
.into(object : RetroMusicColoredTarget(albumCover) {
|
||||
override fun onColorReady(color: Int) {
|
||||
setColor(color)
|
||||
}
|
||||
})
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext()).build()
|
||||
.into(object : RetroMusicColoredTarget(albumCover) {
|
||||
override fun onColorReady(color: Int) {
|
||||
setColor(color)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setColor(color: Int) {
|
||||
|
|
|
@ -31,9 +31,9 @@ import code.name.monkey.retromusic.views.MetalRecyclerViewPager
|
|||
import com.bumptech.glide.Glide
|
||||
|
||||
class AlbumFullWidthAdapter(
|
||||
private val activity: Activity,
|
||||
private val dataSet: ArrayList<Album>,
|
||||
metrics: DisplayMetrics
|
||||
private val activity: Activity,
|
||||
private val dataSet: ArrayList<Album>,
|
||||
metrics: DisplayMetrics
|
||||
) : MetalRecyclerViewPager.MetalAdapter<AlbumFullWidthAdapter.FullMetalViewHolder>(metrics) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FullMetalViewHolder {
|
||||
|
@ -46,7 +46,15 @@ class AlbumFullWidthAdapter(
|
|||
val album = dataSet[position]
|
||||
holder.title?.text = getAlbumTitle(album)
|
||||
holder.text?.text = getAlbumText(album)
|
||||
holder.playSongs?.setOnClickListener { album.songs?.let { songs -> MusicPlayerRemote.openQueue(songs, 0, true) } }
|
||||
holder.playSongs?.setOnClickListener {
|
||||
album.songs?.let { songs ->
|
||||
MusicPlayerRemote.openQueue(
|
||||
songs,
|
||||
0,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
loadAlbumCover(album, holder)
|
||||
}
|
||||
|
||||
|
@ -63,14 +71,13 @@ class AlbumFullWidthAdapter(
|
|||
return
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity)
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onColorReady(color: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
.checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity)
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onColorReady(color: Int) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
@ -80,7 +87,11 @@ class AlbumFullWidthAdapter(
|
|||
inner class FullMetalViewHolder(itemView: View) : MetalRecyclerViewPager.MetalViewHolder(itemView) {
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(activity, image, activity.getString(R.string.transition_album_art))
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${dataSet[adapterPosition].id}"
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, dataSet[adapterPosition].id, activityOptions)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,150 +3,158 @@ package code.name.monkey.retromusic.adapter.artist
|
|||
import android.app.ActivityOptions
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.*
|
||||
import code.name.monkey.retromusic.glide.*
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class ArtistAdapter(
|
||||
val activity: AppCompatActivity,
|
||||
var dataSet: ArrayList<Artist>,
|
||||
var itemLayoutRes: Int,
|
||||
var usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
val activity: AppCompatActivity,
|
||||
var dataSet: ArrayList<Artist>,
|
||||
var itemLayoutRes: Int,
|
||||
var usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
fun swapDataSet(dataSet: ArrayList<Artist>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun swapDataSet(dataSet: ArrayList<Artist>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun usePalette(usePalette: Boolean) {
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun usePalette(usePalette: Boolean) {
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
|
||||
return createViewHolder(view)
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
|
||||
return createViewHolder(view)
|
||||
}
|
||||
|
||||
private fun createViewHolder(view: View): ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
private fun createViewHolder(view: View): ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val artist = dataSet[position]
|
||||
val isChecked = isChecked(artist)
|
||||
holder.itemView.isActivated = isChecked
|
||||
holder.title?.text = artist.name
|
||||
holder.text?.visibility = View.GONE
|
||||
loadArtistImage(artist, holder)
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val artist = dataSet[position]
|
||||
val isChecked = isChecked(artist)
|
||||
holder.itemView.isActivated = isChecked
|
||||
holder.title?.text = artist.name
|
||||
holder.text?.visibility = View.GONE
|
||||
loadArtistImage(artist, holder)
|
||||
}
|
||||
|
||||
fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
holder.title?.setTextColor(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
activity, ColorUtil.isColorLight(
|
||||
color
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
holder.title?.setTextColor(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
activity, ColorUtil.isColorLight(
|
||||
color
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
|
||||
}
|
||||
holder.mask?.backgroundTintList = ColorStateList.valueOf(color)
|
||||
}
|
||||
|
||||
private fun loadArtistImage(artist: Artist, holder: ViewHolder) {
|
||||
if (holder.image == null) {
|
||||
return
|
||||
}
|
||||
ArtistGlideRequest.Builder.from(Glide.with(activity), artist).generatePalette(activity)
|
||||
.build().into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
private fun loadArtistImage(artist: Artist, holder: ViewHolder) {
|
||||
if (holder.image == null) {
|
||||
return
|
||||
}
|
||||
ArtistGlideRequest.Builder.from(Glide.with(activity), artist).generatePalette(activity)
|
||||
.build().into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
|
||||
override fun onColorReady(color: Int) {
|
||||
setColors(color, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
override fun onColorReady(color: Int) {
|
||||
setColors(color, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
override fun getIdentifier(position: Int): Artist? {
|
||||
return dataSet[position]
|
||||
}
|
||||
override fun getIdentifier(position: Int): Artist? {
|
||||
return dataSet[position]
|
||||
}
|
||||
|
||||
override fun getName(artist: Artist): String {
|
||||
return artist.name
|
||||
}
|
||||
override fun getName(artist: Artist): String {
|
||||
return artist.name
|
||||
}
|
||||
|
||||
override fun onMultipleItemAction(
|
||||
menuItem: MenuItem, selection: ArrayList<Artist>
|
||||
) {
|
||||
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
||||
}
|
||||
override fun onMultipleItemAction(
|
||||
menuItem: MenuItem, selection: ArrayList<Artist>
|
||||
) {
|
||||
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.itemId)
|
||||
}
|
||||
|
||||
private fun getSongList(artists: List<Artist>): ArrayList<Song> {
|
||||
val songs = ArrayList<Song>()
|
||||
for (artist in artists) {
|
||||
songs.addAll(artist.songs) // maybe async in future?
|
||||
}
|
||||
return songs
|
||||
}
|
||||
private fun getSongList(artists: List<Artist>): ArrayList<Song> {
|
||||
val songs = ArrayList<Song>()
|
||||
for (artist in artists) {
|
||||
songs.addAll(artist.songs) // maybe async in future?
|
||||
}
|
||||
return songs
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
return MusicUtil.getSectionName(dataSet[position].name)
|
||||
}
|
||||
override fun getSectionName(position: Int): String {
|
||||
return MusicUtil.getSectionName(dataSet[position].name)
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
|
||||
init {
|
||||
setImageTransitionName(activity.getString(R.string.transition_artist_image))
|
||||
menu?.visibility = View.GONE
|
||||
}
|
||||
init {
|
||||
setImageTransitionName(activity.getString(R.string.transition_artist_image))
|
||||
menu?.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(
|
||||
R.string.transition_artist_image
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToArtistOptions(
|
||||
activity, dataSet[adapterPosition].id, activityOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_artist_image)}_${dataSet[adapterPosition].id}"
|
||||
)
|
||||
NavigationUtil.goToArtistOptions(
|
||||
activity, dataSet[adapterPosition].id, activityOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
toggleChecked(adapterPosition)
|
||||
return super.onLongClick(v)
|
||||
}
|
||||
}
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
toggleChecked(adapterPosition)
|
||||
return super.onLongClick(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,29 +19,25 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder implements View.OnLongClickListener, View.OnClickListener {
|
||||
@Nullable
|
||||
public TextView title;
|
||||
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder
|
||||
implements View.OnLongClickListener, View.OnClickListener {
|
||||
|
||||
@Nullable
|
||||
public TextView text;
|
||||
public View dragView;
|
||||
|
||||
@Nullable
|
||||
public TextView time;
|
||||
public View dummyContainer;
|
||||
|
||||
@Nullable
|
||||
public TextView imageText;
|
||||
public ImageView image;
|
||||
|
||||
@Nullable
|
||||
public ViewGroup imageContainer;
|
||||
|
@ -50,30 +46,34 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold
|
|||
public MaterialCardView imageContainerCard;
|
||||
|
||||
@Nullable
|
||||
public View menu;
|
||||
|
||||
@Nullable
|
||||
public View dragView;
|
||||
|
||||
@Nullable
|
||||
public View paletteColorContainer;
|
||||
|
||||
@Nullable
|
||||
public RecyclerView recyclerView;
|
||||
|
||||
@Nullable
|
||||
public ImageButton playSongs;
|
||||
|
||||
@Nullable
|
||||
public View mask;
|
||||
public TextView imageText;
|
||||
|
||||
@Nullable
|
||||
public MaterialCardView imageTextContainer;
|
||||
|
||||
@Nullable
|
||||
public ImageView image;
|
||||
public View mask;
|
||||
|
||||
@Nullable
|
||||
public View dummyContainer;
|
||||
public View menu;
|
||||
|
||||
@Nullable
|
||||
public View paletteColorContainer;
|
||||
|
||||
@Nullable
|
||||
public ImageButton playSongs;
|
||||
|
||||
@Nullable
|
||||
public RecyclerView recyclerView;
|
||||
|
||||
@Nullable
|
||||
public TextView text;
|
||||
|
||||
@Nullable
|
||||
public TextView time;
|
||||
|
||||
@Nullable
|
||||
public TextView title;
|
||||
|
||||
public MediaEntryViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
@ -97,7 +97,8 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold
|
|||
dummyContainer = itemView.findViewById(R.id.dummy_view);
|
||||
|
||||
if (imageContainerCard != null) {
|
||||
imageContainerCard.setCardBackgroundColor(ATHUtil.INSTANCE.resolveColor(itemView.getContext(), R.attr.colorSurface));
|
||||
imageContainerCard.setCardBackgroundColor(
|
||||
ATHUtil.INSTANCE.resolveColor(itemView.getContext(), R.attr.colorSurface));
|
||||
}
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
@ -108,17 +109,20 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setImageTransitionName(@NonNull String transitionName) {
|
||||
if (imageContainerCard != null) {
|
||||
imageContainerCard.setTransitionName(transitionName);
|
||||
}
|
||||
if (image != null) {
|
||||
image.setTransitionName(transitionName);
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ import code.name.monkey.retromusic.interfaces.CabHolder
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
open class PlaylistSongAdapter(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder, false) {
|
||||
|
||||
init {
|
||||
|
@ -60,13 +60,11 @@ open class PlaylistSongAdapter(
|
|||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.action_go_to_album) {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(
|
||||
R.string.transition_album_art
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(
|
||||
activity, dataSet[adapterPosition - 1].albumId, activityOptions
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${song.albumId}"
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, activityOptions)
|
||||
return true
|
||||
}
|
||||
return super.onSongMenuItemClick(item)
|
||||
|
|
|
@ -26,22 +26,23 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* Created by hemanths on 13/08/17.
|
||||
*/
|
||||
|
||||
open class SongAdapter(
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true
|
||||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true
|
||||
) : AbsMultiSelectAdapter<SongAdapter.ViewHolder, Song>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), MaterialCab.Callback, FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
var dataSet: ArrayList<Song>
|
||||
|
||||
protected var usePalette = false
|
||||
|
@ -104,18 +105,18 @@ open class SongAdapter(
|
|||
return
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), song).checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity).build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
.generatePalette(activity).build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
super.onLoadCleared(placeholder)
|
||||
setColors(defaultFooterColor, holder)
|
||||
}
|
||||
|
||||
override fun onColorReady(color: Int) {
|
||||
if (usePalette) setColors(color, holder)
|
||||
else setColors(defaultFooterColor, holder)
|
||||
}
|
||||
})
|
||||
override fun onColorReady(color: Int) {
|
||||
if (usePalette) setColors(color, holder)
|
||||
else setColors(defaultFooterColor, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getSongTitle(song: Song): String? {
|
||||
|
@ -183,10 +184,12 @@ open class SongAdapter(
|
|||
if (image != null && image!!.visibility == View.VISIBLE) {
|
||||
when (item.itemId) {
|
||||
R.id.action_go_to_album -> {
|
||||
val options: ActivityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(R.string.transition_album_art)
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${song.albumId}"
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, options)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, activityOptions)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue