Code refactor and Genre category added to home
This commit is contained in:
parent
d4ab36fd69
commit
c23e959356
21 changed files with 149 additions and 58 deletions
|
@ -50,6 +50,7 @@ class HomeAdapter(
|
|||
.inflate(R.layout.metal_section_recycler_view, parent, false)
|
||||
)
|
||||
}
|
||||
GENRES -> GenreViewHolder(layout)
|
||||
FAVOURITES -> PlaylistViewHolder(layout)
|
||||
else -> {
|
||||
SuggestionsViewHolder(
|
||||
|
@ -103,6 +104,10 @@ class HomeAdapter(
|
|||
R.string.favorites
|
||||
)
|
||||
}
|
||||
GENRES -> {
|
||||
val viewHolder = holder as GenreViewHolder
|
||||
viewHolder.bind(list[position].arrayList as List<Genre>, R.string.genres)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,15 @@ class HomeAdapter(
|
|||
|
||||
companion object {
|
||||
|
||||
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, SUGGESTIONS, FAVOURITES)
|
||||
@IntDef(
|
||||
RECENT_ALBUMS,
|
||||
TOP_ALBUMS,
|
||||
RECENT_ARTISTS,
|
||||
TOP_ARTISTS,
|
||||
SUGGESTIONS,
|
||||
FAVOURITES,
|
||||
GENRES
|
||||
)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class HomeSection
|
||||
|
||||
|
@ -127,6 +140,7 @@ class HomeAdapter(
|
|||
const val TOP_ARTISTS = 0
|
||||
const val SUGGESTIONS = 5
|
||||
const val FAVOURITES = 4
|
||||
const val GENRES = 6
|
||||
}
|
||||
|
||||
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
|
@ -214,6 +228,18 @@ class HomeAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private inner class GenreViewHolder(itemView: View) : AbsHomeViewItem(itemView) {
|
||||
fun bind(genres: List<Genre>, titleRes: Int) {
|
||||
title.text = activity.getString(titleRes)
|
||||
recyclerView.apply {
|
||||
show()
|
||||
layoutManager = GridLayoutManager(activity, 2, GridLayoutManager.HORIZONTAL, false)
|
||||
val genreAdapter = GenreAdapter(activity, genres, R.layout.item_grid_genre)
|
||||
adapter = genreAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
||||
val title: AppCompatTextView = itemView.findViewById(R.id.title)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue