Fixed inconsistent transitions

This commit is contained in:
Prathamesh More 2021-09-11 11:41:16 +05:30
parent a25c80a9bc
commit f9c918234d
6 changed files with 83 additions and 4 deletions

View file

@ -18,6 +18,7 @@ import android.os.Bundle
import android.view.* import android.view.*
import androidx.annotation.NonNull import androidx.annotation.NonNull
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.doOnPreDraw import androidx.core.view.doOnPreDraw
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
@ -48,8 +49,6 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
_binding = FragmentMainRecyclerBinding.bind(view) _binding = FragmentMainRecyclerBinding.bind(view)
enterTransition = MaterialFadeThrough()
exitTransition = MaterialFadeThrough()
postponeEnterTransition() postponeEnterTransition()
view.doOnPreDraw { startPostponedEnterTransition() } view.doOnPreDraw { startPostponedEnterTransition() }
@ -61,6 +60,10 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
setupToolbar() setupToolbar()
} }
fun toolbar(): Toolbar {
return binding.toolbar
}
private fun setupToolbar() { private fun setupToolbar() {
binding.toolbar.setNavigationOnClickListener { binding.toolbar.setNavigationOnClickListener {
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true).addTarget(requireView()) exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true).addTarget(requireView())

View file

@ -53,8 +53,6 @@ class HomeFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
_binding = getBinding(PreferenceUtil.isHomeBanner, view) _binding = getBinding(PreferenceUtil.isHomeBanner, view)
enterTransition = MaterialFadeThrough()
exitTransition = MaterialFadeThrough()
mainActivity.setSupportActionBar(binding.toolbar) mainActivity.setSupportActionBar(binding.toolbar)
mainActivity.supportActionBar?.title = null mainActivity.supportActionBar?.title = null
setStatusBarColorAuto(view) setStatusBarColorAuto(view)

View file

@ -0,0 +1,30 @@
<?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>

View file

@ -0,0 +1,9 @@
<?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>

View file

@ -0,0 +1,30 @@
<?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>

View file

@ -0,0 +1,9 @@
<?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>