Fix home loading when nothing show
This commit is contained in:
parent
54c50b1a98
commit
7c95fe2e69
3 changed files with 43 additions and 22 deletions
|
@ -12,6 +12,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.album.AlbumFullWidthAdapter
|
import code.name.monkey.retromusic.adapter.album.AlbumFullWidthAdapter
|
||||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||||
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
|
@ -97,25 +98,32 @@ class HomeAdapter(
|
||||||
|
|
||||||
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||||
fun bindView(list: ArrayList<Album>, titleRes: Int, subtitleRes: Int) {
|
fun bindView(list: ArrayList<Album>, titleRes: Int, subtitleRes: Int) {
|
||||||
recyclerView.apply {
|
if (list.isNotEmpty()) {
|
||||||
adapter = AlbumFullWidthAdapter(activity, list, displayMetrics)
|
recyclerView.apply {
|
||||||
|
show()
|
||||||
|
adapter = AlbumFullWidthAdapter(activity, list, displayMetrics)
|
||||||
|
}
|
||||||
|
titleContainer . show ()
|
||||||
|
title.text = activity.getString(titleRes)
|
||||||
|
text.text = activity.getString(subtitleRes)
|
||||||
}
|
}
|
||||||
title.text = activity.getString(titleRes)
|
|
||||||
text.text = activity.getString(subtitleRes)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) {
|
inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||||
fun bindView(list: ArrayList<Artist>, titleRes: Int, subtitleRes: Int) {
|
fun bindView(list: ArrayList<Artist>, titleRes: Int, subtitleRes: Int) {
|
||||||
recyclerView.apply {
|
if (list.isNotEmpty()) {
|
||||||
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
recyclerView.apply {
|
||||||
val artistAdapter = ArtistAdapter(activity, list,
|
show()
|
||||||
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), false, null)
|
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
||||||
adapter = artistAdapter
|
val artistAdapter = ArtistAdapter(activity, list,
|
||||||
|
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), false, null)
|
||||||
|
adapter = artistAdapter
|
||||||
|
}
|
||||||
|
titleContainer.show()
|
||||||
|
title.text = activity.getString(titleRes)
|
||||||
|
text.text = activity.getString(subtitleRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
title.text = activity.getString(titleRes)
|
|
||||||
text.text = activity.getString(subtitleRes)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,20 +131,25 @@ class HomeAdapter(
|
||||||
fun bindView(arrayList: ArrayList<Playlist>, titleRes: Int, subtitleRes: Int) {
|
fun bindView(arrayList: ArrayList<Playlist>, titleRes: Int, subtitleRes: Int) {
|
||||||
if (arrayList.isNotEmpty()) {
|
if (arrayList.isNotEmpty()) {
|
||||||
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, arrayList[0])
|
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, arrayList[0])
|
||||||
recyclerView.apply {
|
if (songs.isNotEmpty()) {
|
||||||
val songAdapter = SongAdapter(activity, songs, R.layout.item_album_card, false, null)
|
recyclerView.apply {
|
||||||
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
show()
|
||||||
adapter = songAdapter
|
val songAdapter = SongAdapter(activity, songs, R.layout.item_album_card, false, null)
|
||||||
|
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
||||||
|
adapter = songAdapter
|
||||||
|
|
||||||
|
}
|
||||||
|
titleContainer.show()
|
||||||
|
title.text = activity.getString(titleRes)
|
||||||
|
text.text = activity.getString(subtitleRes)
|
||||||
}
|
}
|
||||||
title.text = activity.getString(titleRes)
|
|
||||||
text.text = activity.getString(subtitleRes)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
||||||
|
val titleContainer: View = itemView.findViewById(R.id.titleContainer)
|
||||||
val title: MaterialTextView = itemView.findViewById(R.id.title)
|
val title: MaterialTextView = itemView.findViewById(R.id.title)
|
||||||
val text: MaterialTextView = itemView.findViewById(R.id.text)
|
val text: MaterialTextView = itemView.findViewById(R.id.text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -61,8 +63,10 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:nestedScrollingEnabled="false"
|
android:nestedScrollingEnabled="false"
|
||||||
|
android:visibility="gone"
|
||||||
app:itemMargin="28dp"
|
app:itemMargin="28dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer" />
|
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||||
|
tools:visibility="visible" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -16,9 +16,11 @@
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -61,8 +63,10 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:nestedScrollingEnabled="false"
|
android:nestedScrollingEnabled="false"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer" />
|
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in a new issue