Hide search results sections if no result for a kind.

This commit is contained in:
Antoine POPINEAU 2020-05-30 14:15:59 +02:00
parent 98b2b31e20
commit 1038ee00ff
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
1 changed files with 26 additions and 3 deletions

View File

@ -90,9 +90,32 @@ class SearchAdapter(private val context: Context?, private val listener: OnSearc
if (resultType == ResultType.Header.ordinal) {
context?.let { context ->
if (position == 0) holder.title.text = context.getString(R.string.artists)
if (position == (artists.size + 1)) holder.title.text = context.getString(R.string.albums)
if (position == (artists.size + albums.size + 2)) holder.title.text = context.getString(R.string.tracks)
if (position == 0) {
holder.title.text = context.getString(R.string.artists)
holder.itemView.visibility = View.VISIBLE
if (artists.isEmpty()) {
holder.itemView.visibility = View.GONE
}
}
if (position == (artists.size + 1)) {
holder.title.text = context.getString(R.string.albums)
holder.itemView.visibility = View.VISIBLE
if (albums.isEmpty()) {
holder.itemView.visibility = View.GONE
}
}
if (position == (artists.size + albums.size + 2)){
holder.title.text = context.getString(R.string.tracks)
holder.itemView.visibility = View.VISIBLE
if (tracks.isEmpty()) {
holder.itemView.visibility = View.GONE
}
}
}
return