|
|
@ -173,7 +173,9 @@ class SearchAdapter( |
|
|
|
albums[position - artists.size - 2] |
|
|
|
albums[position - artists.size - 2] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ResultType.Track.ordinal -> tracks[position - artists.size - albums.size - sectionCount] |
|
|
|
ResultType.Track.ordinal -> { |
|
|
|
|
|
|
|
tracks[position - artists.size - albums.size - sectionCount] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else -> tracks[position] |
|
|
|
else -> tracks[position] |
|
|
|
} |
|
|
|
} |
|
|
@ -207,92 +209,98 @@ class SearchAdapter( |
|
|
|
|
|
|
|
|
|
|
|
searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0) |
|
|
|
searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0) |
|
|
|
|
|
|
|
|
|
|
|
if (resultType == ResultType.Track.ordinal) { |
|
|
|
when (resultType) { |
|
|
|
(item as? Track)?.let { track -> |
|
|
|
ResultType.Artist.ordinal -> { |
|
|
|
context?.let { context -> |
|
|
|
rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds( |
|
|
|
if (track == currentTrack || track.current) { |
|
|
|
0, 0, 0, 0 |
|
|
|
searchHeaderViewHolder?.title?.setTypeface( |
|
|
|
) |
|
|
|
searchHeaderViewHolder.title.typeface, |
|
|
|
} |
|
|
|
Typeface.BOLD |
|
|
|
ResultType.Album.ordinal -> { |
|
|
|
) |
|
|
|
rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds( |
|
|
|
rowTrackViewHolder?.artist?.setTypeface( |
|
|
|
0, 0, 0, 0 |
|
|
|
rowTrackViewHolder.artist.typeface, |
|
|
|
) |
|
|
|
Typeface.BOLD |
|
|
|
} |
|
|
|
) |
|
|
|
ResultType.Track.ordinal -> { |
|
|
|
} |
|
|
|
(item as? Track)?.let { track -> |
|
|
|
|
|
|
|
context?.let { context -> |
|
|
|
when (track.favorite) { |
|
|
|
if (track == currentTrack || track.current) { |
|
|
|
true -> rowTrackViewHolder?.favorite?.setColorFilter(context.getColor(R.color.colorFavorite)) |
|
|
|
searchHeaderViewHolder?.title?.setTypeface( |
|
|
|
false -> rowTrackViewHolder?.favorite?.setColorFilter(context.getColor(R.color.colorSelected)) |
|
|
|
searchHeaderViewHolder.title.typeface, |
|
|
|
} |
|
|
|
Typeface.BOLD |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
rowTrackViewHolder?.artist?.setTypeface( |
|
|
|
|
|
|
|
rowTrackViewHolder.artist.typeface, |
|
|
|
|
|
|
|
Typeface.BOLD |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rowTrackViewHolder?.favorite?.setOnClickListener { |
|
|
|
when (track.favorite) { |
|
|
|
favoriteListener?.let { |
|
|
|
true -> rowTrackViewHolder?.favorite?.setColorFilter(context.getColor(R.color.colorFavorite)) |
|
|
|
favoriteListener.onToggleFavorite(track.id, !track.favorite) |
|
|
|
false -> rowTrackViewHolder?.favorite?.setColorFilter(context.getColor(R.color.colorSelected)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tracks[position - artists.size - albums.size - sectionCount].favorite = |
|
|
|
rowTrackViewHolder?.favorite?.setOnClickListener { |
|
|
|
!track.favorite |
|
|
|
favoriteListener?.let { |
|
|
|
|
|
|
|
favoriteListener.onToggleFavorite(track.id, !track.favorite) |
|
|
|
|
|
|
|
|
|
|
|
notifyItemChanged(position) |
|
|
|
tracks[position - artists.size - albums.size - sectionCount].favorite = |
|
|
|
} |
|
|
|
!track.favorite |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when (track.cached || track.downloaded) { |
|
|
|
notifyItemChanged(position) |
|
|
|
true -> searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds( |
|
|
|
} |
|
|
|
R.drawable.downloaded, |
|
|
|
} |
|
|
|
0, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
false -> searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds( |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (track.cached && !track.downloaded) { |
|
|
|
|
|
|
|
searchHeaderViewHolder?.title?.compoundDrawables?.forEach { |
|
|
|
|
|
|
|
it?.colorFilter = |
|
|
|
|
|
|
|
PorterDuffColorFilter(context.getColor(R.color.cached), PorterDuff.Mode.SRC_IN) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (track.downloaded) { |
|
|
|
when (track.cached || track.downloaded) { |
|
|
|
searchHeaderViewHolder?.title?.compoundDrawables?.forEach { |
|
|
|
true -> rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds( |
|
|
|
it?.colorFilter = |
|
|
|
R.drawable.downloaded, 0, 0, 0 |
|
|
|
PorterDuffColorFilter(context.getColor(R.color.downloaded), PorterDuff.Mode.SRC_IN) |
|
|
|
) |
|
|
|
} |
|
|
|
false -> rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds( |
|
|
|
} |
|
|
|
0, 0, 0, 0 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rowTrackViewHolder?.actions?.setOnClickListener { |
|
|
|
if (track.cached && !track.downloaded) { |
|
|
|
PopupMenu( |
|
|
|
rowTrackViewHolder?.title?.compoundDrawables?.forEach { |
|
|
|
context, |
|
|
|
it?.colorFilter = |
|
|
|
rowTrackViewHolder.actions, |
|
|
|
PorterDuffColorFilter(context.getColor(R.color.cached), PorterDuff.Mode.SRC_IN) |
|
|
|
Gravity.START, |
|
|
|
|
|
|
|
R.attr.actionOverflowMenuStyle, |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
).apply { |
|
|
|
|
|
|
|
inflate(R.menu.row_track) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setOnMenuItemClickListener { |
|
|
|
|
|
|
|
when (it.itemId) { |
|
|
|
|
|
|
|
R.id.track_add_to_queue -> CommandBus.send(Command.AddToQueue(listOf(track))) |
|
|
|
|
|
|
|
R.id.track_play_next -> CommandBus.send(Command.PlayNext(track)) |
|
|
|
|
|
|
|
R.id.track_pin -> CommandBus.send(Command.PinTrack(track)) |
|
|
|
|
|
|
|
R.id.track_add_to_playlist -> CommandBus.send(Command.AddToPlaylist(listOf(track))) |
|
|
|
|
|
|
|
R.id.queue_remove -> CommandBus.send(Command.RemoveFromQueue(track)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
true |
|
|
|
if (track.downloaded) { |
|
|
|
|
|
|
|
rowTrackViewHolder?.title?.compoundDrawables?.forEach { |
|
|
|
|
|
|
|
it?.colorFilter = |
|
|
|
|
|
|
|
PorterDuffColorFilter(context.getColor(R.color.downloaded), PorterDuff.Mode.SRC_IN) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
show() |
|
|
|
rowTrackViewHolder?.actions?.setOnClickListener { |
|
|
|
|
|
|
|
PopupMenu( |
|
|
|
|
|
|
|
context, |
|
|
|
|
|
|
|
rowTrackViewHolder.actions, |
|
|
|
|
|
|
|
Gravity.START, |
|
|
|
|
|
|
|
R.attr.actionOverflowMenuStyle, |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
).apply { |
|
|
|
|
|
|
|
inflate(R.menu.row_track) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setOnMenuItemClickListener { |
|
|
|
|
|
|
|
when (it.itemId) { |
|
|
|
|
|
|
|
R.id.track_add_to_queue -> CommandBus.send(Command.AddToQueue(listOf(track))) |
|
|
|
|
|
|
|
R.id.track_play_next -> CommandBus.send(Command.PlayNext(track)) |
|
|
|
|
|
|
|
R.id.track_pin -> CommandBus.send(Command.PinTrack(track)) |
|
|
|
|
|
|
|
R.id.track_add_to_playlist -> CommandBus.send(Command.AddToPlaylist(listOf(track))) |
|
|
|
|
|
|
|
R.id.queue_remove -> CommandBus.send(Command.RemoveFromQueue(track)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|