Browse Source

Hide search results sections if no result for a kind.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
1038ee00ff
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 29
      app/src/main/java/com/github/apognu/otter/adapters/SearchAdapter.kt

29
app/src/main/java/com/github/apognu/otter/adapters/SearchAdapter.kt

@ -90,9 +90,32 @@ class SearchAdapter(private val context: Context?, private val listener: OnSearc @@ -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

Loading…
Cancel
Save