Merge branch 'bugfix/86-show-downloaded-status-in-searchresults' into 'develop'

#86: Use correct downloaded status for tracks, disable albums and artists

See merge request funkwhale/funkwhale-android!80
This commit is contained in:
Ryan Harg 2021-08-27 13:21:59 +00:00
commit 565e7e0746
1 changed files with 90 additions and 82 deletions

View File

@ -173,7 +173,9 @@ class SearchAdapter(
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]
}
@ -207,7 +209,18 @@ class SearchAdapter(
searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
if (resultType == ResultType.Track.ordinal) {
when (resultType) {
ResultType.Artist.ordinal -> {
rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(
0, 0, 0, 0
)
}
ResultType.Album.ordinal -> {
rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(
0, 0, 0, 0
)
}
ResultType.Track.ordinal -> {
(item as? Track)?.let { track ->
context?.let { context ->
if (track == currentTrack || track.current) {
@ -238,29 +251,23 @@ class SearchAdapter(
}
when (track.cached || track.downloaded) {
true -> searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.downloaded,
0,
0,
0
true -> rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.downloaded, 0, 0, 0
)
false -> searchHeaderViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
0,
0
false -> rowTrackViewHolder?.title?.setCompoundDrawablesWithIntrinsicBounds(
0, 0, 0, 0
)
}
if (track.cached && !track.downloaded) {
searchHeaderViewHolder?.title?.compoundDrawables?.forEach {
rowTrackViewHolder?.title?.compoundDrawables?.forEach {
it?.colorFilter =
PorterDuffColorFilter(context.getColor(R.color.cached), PorterDuff.Mode.SRC_IN)
}
}
if (track.downloaded) {
searchHeaderViewHolder?.title?.compoundDrawables?.forEach {
rowTrackViewHolder?.title?.compoundDrawables?.forEach {
it?.colorFilter =
PorterDuffColorFilter(context.getColor(R.color.downloaded), PorterDuff.Mode.SRC_IN)
}
@ -295,6 +302,7 @@ class SearchAdapter(
}
}
}
}
fun getPositionOf(type: ResultType, position: Int): Int {
return when (type) {