Added suggestions

This commit is contained in:
Hemanth S 2020-07-14 19:16:16 +05:30
parent 547e49507e
commit 06a52b1323
10 changed files with 45 additions and 15 deletions

View file

@ -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)
} }

View file

@ -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) {

View file

@ -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) {

View file

@ -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()

View file

@ -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
} }

View 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>

View 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%" />

View file

@ -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" />

View file

@ -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"

View file

@ -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"