Added proper transitions
This commit is contained in:
parent
bc146d8b11
commit
30282e79fe
14 changed files with 48 additions and 95 deletions
|
@ -103,6 +103,9 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
}
|
||||
}
|
||||
navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||
// This is more like a work-around as for start destination of navGraph
|
||||
// enterTransition won't work as expected
|
||||
navGraph.setStartDestination(R.id.libraryFragment)
|
||||
when (destination.id) {
|
||||
R.id.action_home, R.id.action_song, R.id.action_album, R.id.action_artist, R.id.action_folder, R.id.action_playlist, R.id.action_genre -> {
|
||||
// Save the last tab
|
||||
|
@ -128,6 +131,16 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
override fun onSupportNavigateUp(): Boolean =
|
||||
findNavController(R.id.fragment_container).navigateUp()
|
||||
|
||||
override fun onBackPressed() {
|
||||
val bottomTabs = listOf(R.id.action_home, R.id.action_song, R.id.action_album, R.id.action_artist, R.id.action_folder, R.id.action_playlist, R.id.action_genre)
|
||||
val currentDestinationId = findNavController(R.id.fragment_container).currentDestination?.id
|
||||
if (bottomTabs.contains(currentDestinationId)) {
|
||||
finish()
|
||||
} else {
|
||||
findNavController(R.id.fragment_container).navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
|
||||
|
|
|
@ -227,5 +227,12 @@ fun Context.getColorCompat(@ColorRes colorRes: Int): Int {
|
|||
|
||||
@ColorInt
|
||||
fun Context.darkAccentColor(): Int {
|
||||
return ColorUtils.blendARGB(accentColor(), surfaceColor(), 0.975f)
|
||||
return ColorUtils.blendARGB(
|
||||
accentColor(),
|
||||
surfaceColor(),
|
||||
if (surfaceColor().isColorLight) 0.96f else 0.975f
|
||||
)
|
||||
}
|
||||
|
||||
inline val @receiver:ColorInt Int.isColorLight
|
||||
get() = ColorUtil.isColorLight(this)
|
||||
|
|
|
@ -37,6 +37,7 @@ import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
|||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.google.android.material.transition.MaterialFadeThrough
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
|
@ -56,6 +57,9 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
_binding = FragmentMainRecyclerBinding.bind(view)
|
||||
postponeEnterTransition()
|
||||
view.doOnPreDraw { startPostponedEnterTransition() }
|
||||
enterTransition = MaterialFadeThrough().apply {
|
||||
addTarget(binding.recyclerView)
|
||||
}
|
||||
mainActivity.setSupportActionBar(binding.toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
initLayoutManager()
|
||||
|
|
|
@ -72,6 +72,7 @@ import com.afollestad.materialcab.createCab
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.transition.MaterialFadeThrough
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import java.io.*
|
||||
import java.lang.ref.WeakReference
|
||||
|
@ -106,6 +107,9 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
|||
mainActivity.addMusicServiceEventListener(libraryViewModel)
|
||||
mainActivity.setSupportActionBar(binding.toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
enterTransition = MaterialFadeThrough().apply {
|
||||
addTarget(binding.recyclerView)
|
||||
}
|
||||
setUpBreadCrumbs()
|
||||
setUpRecyclerView()
|
||||
setUpAdapter()
|
||||
|
|
|
@ -42,6 +42,7 @@ import code.name.monkey.retromusic.glide.RetroGlideExtension
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.google.android.material.transition.MaterialFadeThrough
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
|
||||
class HomeFragment :
|
||||
|
@ -58,6 +59,10 @@ class HomeFragment :
|
|||
setupListeners()
|
||||
binding.titleWelcome.text = String.format("%s", PreferenceUtil.userName)
|
||||
|
||||
enterTransition = MaterialFadeThrough().apply {
|
||||
addTarget(binding.contentContainer)
|
||||
}
|
||||
|
||||
val homeAdapter = HomeAdapter(mainActivity)
|
||||
binding.recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(mainActivity)
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="0"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="0"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
|
@ -16,8 +16,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:transitionGroup="true">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
|
@ -72,7 +71,7 @@
|
|||
android:id="@+id/contentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:transitionGroup="true">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/imageContainer"
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:transitionGroup="true">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
|
@ -71,7 +70,8 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/contentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:transitionGroup="true">
|
||||
|
||||
<code.name.monkey.retromusic.views.RetroShapeableImageView
|
||||
android:id="@+id/userImage"
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:transitionGroup="true">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
|
@ -69,7 +68,7 @@
|
|||
android:id="@+id/contentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:transitionGroup="true">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/imageContainer"
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:transitionGroup="true">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
|
@ -68,7 +67,8 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/contentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:transitionGroup="true">
|
||||
|
||||
<code.name.monkey.retromusic.views.RetroShapeableImageView
|
||||
android:id="@+id/userImage"
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:transitionGroup="true">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
|
@ -40,14 +39,15 @@
|
|||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||
tools:listitem="@layout/item_list" />
|
||||
tools:listitem="@layout/item_list"
|
||||
android:transitionGroup="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue