Added suggestions
This commit is contained in:
parent
547e49507e
commit
06a52b1323
10 changed files with 45 additions and 15 deletions
|
@ -623,6 +623,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
||||||
fragment: Fragment,
|
fragment: Fragment,
|
||||||
tag: String
|
tag: String
|
||||||
) {
|
) {
|
||||||
|
|
||||||
supportFragmentManager.commit {
|
supportFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, fragment, tag)
|
replace(R.id.fragment_container, fragment, tag)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class HomeAdapter(
|
||||||
.inflate(R.layout.section_recycler_view, parent, false)
|
.inflate(R.layout.section_recycler_view, parent, false)
|
||||||
return when (viewType) {
|
return when (viewType) {
|
||||||
RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout)
|
RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout)
|
||||||
PLAYLISTS -> PlaylistViewHolder(layout)
|
FAVOURITES -> PlaylistViewHolder(layout)
|
||||||
SUGGESTIONS -> {
|
SUGGESTIONS -> {
|
||||||
SuggestionsViewHolder(
|
SuggestionsViewHolder(
|
||||||
LayoutInflater.from(activity).inflate(
|
LayoutInflater.from(activity).inflate(
|
||||||
|
@ -89,19 +89,19 @@ class HomeAdapter(
|
||||||
val viewHolder = holder as ArtistViewHolder
|
val viewHolder = holder as ArtistViewHolder
|
||||||
viewHolder.bindView(list[position].arrayList as List<Artist>, R.string.top_artists)
|
viewHolder.bindView(list[position].arrayList as List<Artist>, R.string.top_artists)
|
||||||
}
|
}
|
||||||
PLAYLISTS -> {
|
|
||||||
val viewHolder = holder as PlaylistViewHolder
|
|
||||||
viewHolder.bindView(
|
|
||||||
list[position].arrayList as List<Playlist>,
|
|
||||||
R.string.favorites
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SUGGESTIONS -> {
|
SUGGESTIONS -> {
|
||||||
val viewHolder = holder as SuggestionsViewHolder
|
val viewHolder = holder as SuggestionsViewHolder
|
||||||
viewHolder.bindView(
|
viewHolder.bindView(
|
||||||
list[position].arrayList as List<Song>
|
list[position].arrayList as List<Song>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
FAVOURITES -> {
|
||||||
|
val viewHolder = holder as PlaylistViewHolder
|
||||||
|
viewHolder.bindView(
|
||||||
|
list[position].arrayList as List<Playlist>,
|
||||||
|
R.string.favorites
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class HomeAdapter(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, PLAYLISTS, SUGGESTIONS)
|
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, SUGGESTIONS, FAVOURITES)
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
annotation class HomeSection
|
annotation class HomeSection
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ class HomeAdapter(
|
||||||
const val TOP_ALBUMS = 1
|
const val TOP_ALBUMS = 1
|
||||||
const val RECENT_ARTISTS = 2
|
const val RECENT_ARTISTS = 2
|
||||||
const val TOP_ARTISTS = 0
|
const val TOP_ARTISTS = 0
|
||||||
const val SUGGESTIONS = 4
|
const val SUGGESTIONS = 5
|
||||||
const val PLAYLISTS = 5
|
const val FAVOURITES = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||||
|
|
|
@ -55,8 +55,8 @@ class LibraryViewModel(application: Application) :
|
||||||
_repository.topAlbums(),
|
_repository.topAlbums(),
|
||||||
_repository.recentArtists(),
|
_repository.recentArtists(),
|
||||||
_repository.recentAlbums(),
|
_repository.recentAlbums(),
|
||||||
_repository.favoritePlaylist(),
|
_repository.suggestions(),
|
||||||
_repository.suggestions()
|
_repository.favoritePlaylist()
|
||||||
)
|
)
|
||||||
for (r in result) {
|
for (r in result) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ class AlbumsFragment :
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||||
MainActivityFragmentCallbacks {
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
mainActivity.libraryViewModel.allAlbums()
|
mainActivity.libraryViewModel.allAlbums()
|
||||||
|
|
|
@ -110,7 +110,7 @@ class RepositoryImpl constructor(private val context: Context) : Repository {
|
||||||
val playlists = PlaylistLoader.getFavoritePlaylist(context)
|
val playlists = PlaylistLoader.getFavoritePlaylist(context)
|
||||||
return if (playlists.isNotEmpty()) Home(
|
return if (playlists.isNotEmpty()) Home(
|
||||||
playlists,
|
playlists,
|
||||||
HomeAdapter.PLAYLISTS,
|
HomeAdapter.FAVOURITES,
|
||||||
R.drawable.ic_favorite_white_24dp
|
R.drawable.ic_favorite_white_24dp
|
||||||
) else null
|
) else null
|
||||||
}
|
}
|
||||||
|
|
22
app/src/main/res/anim/item_animation_fall_down.xml
Normal file
22
app/src/main/res/anim/item_animation_fall_down.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="@integer/anim_duration_medium">
|
||||||
|
|
||||||
|
<translate
|
||||||
|
android:fromYDelta="-20%"
|
||||||
|
android:interpolator="@android:anim/decelerate_interpolator"
|
||||||
|
android:toYDelta="0" />
|
||||||
|
|
||||||
|
<alpha
|
||||||
|
android:fromAlpha="0"
|
||||||
|
android:interpolator="@android:anim/decelerate_interpolator"
|
||||||
|
android:toAlpha="1" />
|
||||||
|
|
||||||
|
<scale
|
||||||
|
android:fromXScale="105%"
|
||||||
|
android:fromYScale="105%"
|
||||||
|
android:interpolator="@android:anim/decelerate_interpolator"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:toXScale="100%"
|
||||||
|
android:toYScale="100%" />
|
||||||
|
</set>
|
5
app/src/main/res/anim/layout_animation_fall_down.xml
Normal file
5
app/src/main/res/anim/layout_animation_fall_down.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:animation="@anim/item_animation_fall_down"
|
||||||
|
android:animationOrder="normal"
|
||||||
|
android:delay="15%" />
|
|
@ -54,6 +54,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
android:layoutAnimation="@anim/layout_animation_fall_down"
|
||||||
android:overScrollMode="never"
|
android:overScrollMode="never"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
android:layoutAnimation="@anim/layout_animation_fall_down"
|
||||||
android:overScrollMode="never"
|
android:overScrollMode="never"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
app:layout_dodgeInsetEdges="bottom"
|
app:layout_dodgeInsetEdges="bottom"
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layoutAnimation="@anim/layout_animation_fall_down"
|
||||||
android:nestedScrollingEnabled="false"
|
android:nestedScrollingEnabled="false"
|
||||||
android:overScrollMode="never"
|
android:overScrollMode="never"
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
|
|
Loading…
Reference in a new issue