Added some animations

Renamed some interface classes
This commit is contained in:
Hemanth S 2020-09-28 00:29:09 +05:30
parent b78cbb60b4
commit fdfedf274f
21 changed files with 190 additions and 247 deletions

View file

@ -3,7 +3,9 @@ package code.name.monkey.retromusic.activities
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
@ -15,8 +17,13 @@ import code.name.monkey.retromusic.lyrics.LrcView
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.LyricUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialArcMotion
import com.google.android.material.transition.platform.MaterialContainerTransform
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
import kotlinx.android.synthetic.main.activity_lyrics.*
class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.Callback {
private lateinit var updateHelper: MusicProgressViewUpdateHelper
@ -31,7 +38,23 @@ class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.
return baseUrl
}
private fun buildContainerTransform( ): MaterialContainerTransform {
val transform = MaterialContainerTransform()
transform.setAllContainerColors(
MaterialColors.getColor(findViewById(android.R.id.content), R.attr.colorSurface)
)
transform.addTarget(android.R.id.content)
transform.duration = 300
transform.interpolator = FastOutSlowInInterpolator()
transform.pathMotion = MaterialArcMotion()
return transform
}
override fun onCreate(savedInstanceState: Bundle?) {
findViewById<View>(android.R.id.content).transitionName = "lyrics"
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
window.sharedElementEnterTransition = buildContainerTransform( )
window.sharedElementReturnTransition = buildContainerTransform( )
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_lyrics)
setStatusbarColorAuto()

View file

@ -38,10 +38,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
override fun onCreate(savedInstanceState: Bundle?) {
setDrawUnderStatusBar()
super.onCreate(savedInstanceState)
setupNavigationController()
if (!hasPermissions()) {
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
}
setStatusbarColorAuto()
setNavigationbarColorAuto()
setLightNavigationBar(true)
@ -51,7 +48,10 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
updateTabs()
//NavigationUI.setupWithNavController(getBottomNavigationView(), findNavController(R.id.fragment_container))
setupNavigationController()
if (!hasPermissions()) {
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
}
}
private fun setupNavigationController() {

View file

@ -13,6 +13,7 @@ import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
import code.name.monkey.retromusic.extensions.accentColor
import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.ThemedFastScroller
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
@ -20,7 +21,6 @@ import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeMana
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
import kotlinx.android.synthetic.main.activity_playing_queue.*
import kotlinx.android.synthetic.main.activity_playing_queue.title as NoImageTitle
open class PlayingQueueActivity : AbsMusicServiceActivity() {
@ -31,6 +31,13 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
private var playingQueueAdapter: PlayingQueueAdapter? = null
private lateinit var linearLayoutManager: LinearLayoutManager
private fun getUpNextAndQueueTime(): String {
val duration = MusicPlayerRemote.getQueueDurationMillis(MusicPlayerRemote.position)
return MusicUtil.buildInfoString(
resources.getString(R.string.up_next),
MusicUtil.getReadableDurationString(duration)
)
}
override fun onCreate(savedInstanceState: Bundle?) {
setDrawUnderStatusBar()
@ -47,6 +54,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
clearQueue.setOnClickListener {
MusicPlayerRemote.clearQueue()
}
checkForPadding()
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -99,8 +107,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
ThemedFastScroller.create(recyclerView)
}
override fun onServiceConnected() {
updateCurrentSong()
private fun checkForPadding() {
}
override fun onQueueChanged() {
@ -108,6 +115,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
finish()
return
}
checkForPadding()
updateQueue()
updateCurrentSong()
}
@ -118,9 +126,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
}
private fun updateCurrentSong() {
NoImageTitle.text = MusicPlayerRemote.currentSong.title
text.text = MusicPlayerRemote.currentSong.artistName
text2?.text = MusicPlayerRemote.currentSong.albumName
toolbar.subtitle = getUpNextAndQueueTime()
}
override fun onPlayingMetaChanged() {
@ -130,6 +136,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
private fun updateQueuePosition() {
playingQueueAdapter?.setCurrent(MusicPlayerRemote.position)
resetToCurrentPosition()
toolbar.subtitle = getUpNextAndQueueTime()
}
private fun updateQueue() {
@ -167,6 +174,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
}
private fun setupToolbar() {
toolbar.subtitle = getUpNextAndQueueTime()
toolbar.setBackgroundColor(surfaceColor())
setSupportActionBar(toolbar)
clearQueue.backgroundTintList = ColorStateList.valueOf(accentColor())

View file

@ -20,10 +20,10 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.albums.AlbumClickListener
import code.name.monkey.retromusic.fragments.artists.ArtistClickListener
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.interfaces.IArtistClickListener
import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide
@ -31,7 +31,7 @@ import com.google.android.material.card.MaterialCardView
class HomeAdapter(
private val activity: AppCompatActivity
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(), ArtistClickListener, AlbumClickListener {
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(), IArtistClickListener, IAlbumClickListener {
private var list = listOf<Home>()
@ -231,15 +231,16 @@ class HomeAdapter(
AlbumAdapter(activity, albums, PreferenceUtil.homeAlbumGridStyle, null, this)
fun gridLayoutManager() = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
fun linearLayoutManager() = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
override fun onArtist(artistId: Long, imageView: ImageView) {
override fun onArtist(artistId: Long, view: View) {
activity.findNavController(R.id.fragment_container).navigate(
R.id.artistDetailsFragment,
bundleOf(EXTRA_ARTIST_ID to artistId),
null,
FragmentNavigatorExtras(
imageView to activity.getString(R.string.transition_album_art)
view to "artist"
)
)
}
@ -250,7 +251,7 @@ class HomeAdapter(
bundleOf(EXTRA_ALBUM_ID to albumId),
null,
FragmentNavigatorExtras(
view to activity.getString(R.string.transition_album_art)
view to "album"
)
)
}

View file

@ -6,16 +6,17 @@ import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
import androidx.fragment.app.FragmentActivity
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.fragments.albums.AlbumClickListener
import code.name.monkey.retromusic.glide.AlbumGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SortOrder
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.interfaces.ICabHolder
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Song
@ -30,7 +31,7 @@ open class AlbumAdapter(
var dataSet: List<Album>,
protected var itemLayoutRes: Int,
ICabHolder: ICabHolder?,
private val albumClickListener: AlbumClickListener?
private val albumClickListener: IAlbumClickListener?
) : AbsMultiSelectAdapter<AlbumAdapter.ViewHolder, Album>(
activity,
ICabHolder,
@ -75,7 +76,7 @@ open class AlbumAdapter(
holder.title?.text = getAlbumTitle(album)
holder.text?.text = getAlbumText(album)
holder.playSongs?.setOnClickListener {
album.songs?.let { songs ->
album.songs.let { songs ->
MusicPlayerRemote.openQueue(
songs,
0,
@ -116,7 +117,7 @@ open class AlbumAdapter(
}
override fun getItemId(position: Int): Long {
return dataSet[position].id.toLong()
return dataSet[position].id
}
override fun getIdentifier(position: Int): Album? {
@ -161,7 +162,7 @@ open class AlbumAdapter(
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
init {
setImageTransitionName(activity.getString(R.string.transition_album_art))
setImageTransitionName("Album")
menu?.visibility = View.GONE
}
@ -170,6 +171,7 @@ open class AlbumAdapter(
if (isInQuickSelectMode) {
toggleChecked(layoutPosition)
} else {
ViewCompat.setTransitionName(itemView, "album")
albumClickListener?.onAlbumClick(dataSet[layoutPosition].id, itemView)
}
}

View file

@ -1,14 +1,17 @@
package code.name.monkey.retromusic.adapter.album
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.app.ActivityOptionsCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.LyricsActivity
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
@ -90,8 +93,13 @@ class AlbumCoverPagerAdapter(
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
albumCover = view.findViewById(R.id.player_image)
albumCover.setOnClickListener {
//LyricsDialog().show(childFragmentManager, "LyricsDialog")
showLyricsDialog()
val intent = Intent(requireContext(), LyricsActivity::class.java)
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
requireActivity(),
it,
"lyrics"
)
startActivity(intent, activityOptions.toBundle())
}
return view
}

View file

@ -3,10 +3,10 @@ package code.name.monkey.retromusic.adapter.album
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentActivity
import code.name.monkey.retromusic.fragments.albums.AlbumClickListener
import code.name.monkey.retromusic.glide.AlbumGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.helper.HorizontalAdapterHelper
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.interfaces.ICabHolder
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.util.MusicUtil
@ -17,7 +17,7 @@ class HorizontalAlbumAdapter(
activity: FragmentActivity,
dataSet: List<Album>,
ICabHolder: ICabHolder?,
albumClickListener: AlbumClickListener
albumClickListener: IAlbumClickListener
) : AlbumAdapter(
activity, dataSet, HorizontalAdapterHelper.LAYOUT_RES, ICabHolder, albumClickListener
) {

View file

@ -12,10 +12,10 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.artists.ArtistClickListener
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
import code.name.monkey.retromusic.interfaces.IArtistClickListener
import code.name.monkey.retromusic.interfaces.ICabHolder
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Song
@ -29,8 +29,8 @@ class ArtistAdapter(
val activity: FragmentActivity,
var dataSet: List<Artist>,
var itemLayoutRes: Int,
ICabHolder: ICabHolder?,
private val artistClickListener: ArtistClickListener
val ICabHolder: ICabHolder?,
val IArtistClickListener: IArtistClickListener
) : AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist>(
activity, ICabHolder, R.menu.menu_media_selection
), PopupTextProvider {
@ -45,7 +45,7 @@ class ArtistAdapter(
}
override fun getItemId(position: Int): Long {
return dataSet[position].id.toLong()
return dataSet[position].id
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
@ -140,11 +140,8 @@ class ArtistAdapter(
toggleChecked(layoutPosition)
} else {
image?.let {
ViewCompat.setTransitionName(
it,
activity.getString(R.string.transition_artist_image)
)
artistClickListener.onArtist(dataSet[layoutPosition].id, it)
ViewCompat.setTransitionName(itemView, "album")
IArtistClickListener.onArtist(dataSet[layoutPosition].id, itemView)
}
}
}

View file

@ -2,7 +2,6 @@ package code.name.monkey.retromusic.fragments
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.core.os.bundleOf
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
@ -16,9 +15,9 @@ import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.db.toSong
import code.name.monkey.retromusic.extensions.dipToPix
import code.name.monkey.retromusic.fragments.albums.AlbumClickListener
import code.name.monkey.retromusic.fragments.artists.ArtistClickListener
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.interfaces.IArtistClickListener
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.state.NowPlayingPanelState
@ -26,7 +25,7 @@ import code.name.monkey.retromusic.util.RetroUtil
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail),
ArtistClickListener, AlbumClickListener {
IArtistClickListener, IAlbumClickListener {
private val args by navArgs<DetailListFragmentArgs>()
override fun onActivityCreated(savedInstanceState: Bundle?) {
@ -175,12 +174,12 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
return 2
}
override fun onArtist(artistId: Long, imageView: ImageView) {
override fun onArtist(artistId: Long, view: View) {
findNavController().navigate(
R.id.artistDetailsFragment,
bundleOf(EXTRA_ARTIST_ID to artistId),
null,
FragmentNavigatorExtras(imageView to getString(R.string.transition_artist_image))
FragmentNavigatorExtras(view to "artist")
)
}
@ -189,7 +188,9 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to albumId),
null,
FragmentNavigatorExtras(view to getString(R.string.transition_album_art))
FragmentNavigatorExtras(
view to "album"
)
)
}
}

View file

@ -7,6 +7,7 @@ import android.view.*
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat
import androidx.core.view.ViewCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.navigation.findNavController
@ -17,6 +18,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
import code.name.monkey.retromusic.EXTRA_ARTIST_ID
@ -37,6 +39,7 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SingleColorTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SortOrder
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.network.Result
@ -48,8 +51,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import com.google.android.material.transition.platform.MaterialArcMotion
import com.google.android.material.transition.platform.MaterialContainerTransform
import com.google.android.material.transition.MaterialContainerTransform
import kotlinx.android.synthetic.main.fragment_album_content.*
import kotlinx.android.synthetic.main.fragment_album_details.*
import kotlinx.coroutines.Dispatchers
@ -61,7 +63,7 @@ import org.koin.core.parameter.parametersOf
import java.util.*
class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_details),
AlbumClickListener {
IAlbumClickListener {
private val arguments by navArgs<AlbumDetailsFragmentArgs>()
private val detailsViewModel by viewModel<AlbumDetailsViewModel> {
@ -79,12 +81,15 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
}
private fun setUpTransitions() {
val transform = MaterialContainerTransform()
transform.setAllContainerColors(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
sharedElementEnterTransition = transform
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sharedElementEnterTransition = MaterialContainerTransform().apply {
duration = 1000L
pathMotion = MaterialArcMotion()
}
setUpTransitions()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -93,6 +98,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
mainActivity.addMusicServiceEventListener(detailsViewModel)
mainActivity.setSupportActionBar(toolbar)
toolbar.title = " "
ViewCompat.setTransitionName(container, "album")
postponeEnterTransition()
detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer {
startPostponedEnterTransition()
@ -133,7 +139,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
serviceActivity?.removeMusicServiceEventListener(detailsViewModel)
}
private fun setupRecyclerView() {
simpleSongAdapter = SimpleSongAdapter(
requireActivity() as AppCompatActivity,
@ -275,7 +280,9 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to albumId),
null,
FragmentNavigatorExtras(view to getString(R.string.transition_album_art))
FragmentNavigatorExtras(
view to "album"
)
)
}

View file

@ -5,21 +5,22 @@ import android.view.*
import androidx.core.os.bundleOf
import androidx.lifecycle.Observer
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.GridLayoutManager
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.extensions.findActivityNavController
import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.helper.SortOrder
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
AlbumClickListener {
IAlbumClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -98,12 +99,12 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
}
override fun onAlbumClick(albumId: Long, view: View) {
findActivityNavController(R.id.fragment_container).navigate(
findNavController().navigate(
R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to albumId),
null,
FragmentNavigatorExtras(
view to getString(R.string.transition_album_art)
view to "album"
)
)
}
@ -283,7 +284,3 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
}
}
interface AlbumClickListener {
fun onAlbumClick(albumId: Long, view: View)
}

View file

@ -9,6 +9,7 @@ import android.view.MenuItem
import android.view.View
import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat
import androidx.core.view.ViewCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.FragmentNavigatorExtras
@ -17,6 +18,7 @@ import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
@ -26,11 +28,11 @@ import code.name.monkey.retromusic.extensions.applyColor
import code.name.monkey.retromusic.extensions.applyOutlineColor
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.extensions.showToast
import code.name.monkey.retromusic.fragments.albums.AlbumClickListener
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.SingleColorTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.network.Result
import code.name.monkey.retromusic.network.model.LastFmArtist
@ -40,6 +42,7 @@ import code.name.monkey.retromusic.util.CustomArtistImageUtil
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.bumptech.glide.Glide
import com.google.android.material.transition.MaterialContainerTransform
import kotlinx.android.synthetic.main.fragment_artist_content.*
import kotlinx.android.synthetic.main.fragment_artist_details.*
import kotlinx.coroutines.Dispatchers
@ -52,7 +55,7 @@ import java.util.*
import kotlin.collections.ArrayList
class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_details),
AlbumClickListener {
IAlbumClickListener {
private val arguments by navArgs<ArtistDetailsFragmentArgs>()
private val detailsViewModel: ArtistDetailsViewModel by viewModel {
parametersOf(arguments.extraArtistId)
@ -64,20 +67,35 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
private var lang: String? = null
private var biography: Spanned? = null
private fun setUpTransitions() {
val transform = MaterialContainerTransform()
transform.setAllContainerColors(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
sharedElementEnterTransition = transform
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setUpTransitions()
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
mainActivity.setSupportActionBar(toolbar)
toolbar.title = null
setupRecyclerView()
ViewCompat.setTransitionName(container, "artist")
postponeEnterTransition()
detailsViewModel.getArtist().observe(viewLifecycleOwner, Observer {
startPostponedEnterTransition()
showArtist(it)
})
playAction.apply {
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
}
@ -207,7 +225,7 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
bundleOf(EXTRA_ALBUM_ID to albumId),
null,
FragmentNavigatorExtras(
view to getString(R.string.transition_album_art)
view to "album"
)
)
}

View file

@ -2,23 +2,24 @@ package code.name.monkey.retromusic.fragments.artists
import android.os.Bundle
import android.view.*
import android.widget.ImageView
import androidx.core.os.bundleOf
import androidx.lifecycle.Observer
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.GridLayoutManager
import code.name.monkey.retromusic.EXTRA_ARTIST_ID
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.extensions.findActivityNavController
import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder
import code.name.monkey.retromusic.interfaces.IArtistClickListener
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
ArtistClickListener {
IArtistClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
libraryViewModel.getArtists().observe(viewLifecycleOwner, Observer {
@ -95,9 +96,13 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
}
}
override fun onArtist(artistId: Long, imageView: ImageView) {
val controller = findActivityNavController(R.id.fragment_container)
controller.navigate(R.id.artistDetailsFragment, bundleOf(EXTRA_ARTIST_ID to artistId))
override fun onArtist(artistId: Long, view: View) {
findNavController().navigate(
R.id.artistDetailsFragment,
bundleOf(EXTRA_ARTIST_ID to artistId),
null,
FragmentNavigatorExtras(view to "artist")
)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -256,7 +261,3 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
return false
}
}
interface ArtistClickListener {
fun onArtist(artistId: Long, imageView: ImageView)
}

View file

@ -19,6 +19,7 @@ import code.name.monkey.retromusic.util.DensityUtil
import code.name.monkey.retromusic.util.ThemedFastScroller.create
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.transition.Hold
import kotlinx.android.synthetic.main.fragment_main_recycler.*
import me.zhanghai.android.fastscroll.FastScroller
import me.zhanghai.android.fastscroll.FastScrollerBuilder
@ -36,6 +37,14 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
protected var adapter: A? = null
protected var layoutManager: LM? = null
private fun setUpTransitions() {
exitTransition = Hold()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setUpTransitions()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View file

@ -36,7 +36,6 @@ import code.name.monkey.retromusic.TOP_PLAYED_PLAYLIST
import code.name.monkey.retromusic.adapter.HomeAdapter
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
import code.name.monkey.retromusic.extensions.findActivityNavController
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest
import code.name.monkey.retromusic.glide.UserProfileGlideRequest
@ -67,14 +66,14 @@ class HomeFragment :
}
lastAdded.setOnClickListener {
findActivityNavController(R.id.fragment_container).navigate(
findNavController().navigate(
R.id.detailListFragment,
bundleOf("type" to LAST_ADDED_PLAYLIST)
)
}
topPlayed.setOnClickListener {
findActivityNavController(R.id.fragment_container).navigate(
findNavController().navigate(
R.id.detailListFragment,
bundleOf("type" to TOP_PLAYED_PLAYLIST)
)
@ -85,7 +84,7 @@ class HomeFragment :
}
history.setOnClickListener {
findActivityNavController(R.id.fragment_container).navigate(
findNavController().navigate(
R.id.detailListFragment,
bundleOf("type" to HISTORY_PLAYLIST)
)

View file

@ -8,10 +8,11 @@ import android.widget.FrameLayout
import android.widget.TextView
import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.EXTRA_ARTIST_ID
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.findActivityNavController
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.extensions.whichFragment
@ -148,10 +149,12 @@ class FullPlayerFragment : AbsPlayerFragment(R.layout.fragment_full),
private fun setupArtist() {
artistImage.setOnClickListener {
mainActivity.collapsePanel()
findActivityNavController(R.id.fragment_container)
findNavController()
.navigate(
R.id.artistDetailsFragment,
bundleOf(EXTRA_ARTIST_ID to MusicPlayerRemote.currentSong.artistId)
bundleOf(EXTRA_ARTIST_ID to MusicPlayerRemote.currentSong.artistId),
null,
FragmentNavigatorExtras(it to "artist")
)
}
}

View file

@ -0,0 +1,7 @@
package code.name.monkey.retromusic.interfaces
import android.view.View
interface IAlbumClickListener {
fun onAlbumClick(albumId: Long, view: View)
}

View file

@ -0,0 +1,7 @@
package code.name.monkey.retromusic.interfaces
import android.view.View
interface IArtistClickListener {
fun onArtist(artistId: Long, view: View)
}

View file

@ -37,98 +37,16 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/nowPlaying"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingHorizontal="78dp"
android:paddingVertical="22dp"
android:text="@string/now_playing"
android:textAppearance="@style/TextViewHeadline6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="76dp"
android:paddingEnd="8dp"
android:singleLine="true"
android:textAppearance="@style/TextViewSubtitle1"
app:layout_constraintBottom_toTopOf="@id/upNext"
app:layout_constraintEnd_toStartOf="@+id/text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/nowPlaying"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
android:singleLine="true"
android:textAppearance="@style/TextViewBody2"
android:textColor="?android:textColorSecondary"
app:layout_constraintBottom_toTopOf="@id/upNext"
app:layout_constraintEnd_toStartOf="@+id/text2"
app:layout_constraintStart_toEndOf="@+id/title"
app:layout_constraintTop_toBottomOf="@id/nowPlaying"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="64dp"
android:singleLine="true"
android:textAppearance="@style/TextViewBody2"
android:textColor="?android:textColorSecondary"
app:layout_constraintBottom_toTopOf="@id/upNext"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/text"
app:layout_constraintTop_toBottomOf="@id/nowPlaying"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/upNext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingHorizontal="78dp"
android:paddingVertical="22dp"
android:text="@string/up_next"
android:textAppearance="@style/TextViewHeadline6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingBottom="96dp"
android:scrollbars="none"
app:layout_constraintTop_toBottomOf="@id/upNext"
tools:listitem="@layout/item_queue" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingBottom="96dp"
android:scrollbars="none"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_queue" />
<com.google.android.material.textview.MaterialTextView
android:id="@android:id/empty"

View file

@ -37,79 +37,16 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/nowPlaying"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="12dp"
android:text="@string/now_playing"
android:textAppearance="@style/TextViewHeadline6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewSubtitle1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/nowPlaying"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewBody2"
android:textColor="?android:textColorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/upNext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="12dp"
android:text="@string/up_next"
android:textAppearance="@style/TextViewHeadline6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingBottom="96dp"
android:scrollbars="none"
app:layout_constraintTop_toBottomOf="@id/upNext" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingBottom="96dp"
android:scrollbars="none"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_queue" />
<com.google.android.material.textview.MaterialTextView
android:id="@android:id/empty"
@ -132,5 +69,6 @@
android:textAppearance="@style/TextViewHeadline6"
app:icon="@drawable/ic_clear_all" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>

View file

@ -3,8 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionName="@string/transition_album_art">
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
@ -32,10 +31,10 @@
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:overScrollMode="never"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">