mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Fix inconsistent toolbar animation state on back.
This commit is contained in:
@@ -52,7 +52,7 @@ abstract class DSLSettingsFragment(
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
scrollAnimationHelper.onScrolled(recyclerView, 0, 0)
|
||||
scrollAnimationHelper.setImmediateState(recyclerView)
|
||||
}
|
||||
|
||||
protected open fun getOnScrollAnimationHelper(toolbarShadow: View): OnScrollAnimationHelper {
|
||||
@@ -86,8 +86,20 @@ abstract class DSLSettingsFragment(
|
||||
|
||||
when (newAnimationState) {
|
||||
AnimationState.NONE -> throw AssertionError()
|
||||
AnimationState.HIDE -> hide()
|
||||
AnimationState.SHOW -> show()
|
||||
AnimationState.HIDE -> hide(duration)
|
||||
AnimationState.SHOW -> show(duration)
|
||||
}
|
||||
|
||||
lastAnimationState = newAnimationState
|
||||
}
|
||||
|
||||
fun setImmediateState(recyclerView: RecyclerView) {
|
||||
val newAnimationState = getAnimationState(recyclerView)
|
||||
|
||||
when (newAnimationState) {
|
||||
AnimationState.NONE -> throw AssertionError()
|
||||
AnimationState.HIDE -> hide(0L)
|
||||
AnimationState.SHOW -> show(0L)
|
||||
}
|
||||
|
||||
lastAnimationState = newAnimationState
|
||||
@@ -97,9 +109,9 @@ abstract class DSLSettingsFragment(
|
||||
return if (recyclerView.canScrollVertically(-1)) AnimationState.SHOW else AnimationState.HIDE
|
||||
}
|
||||
|
||||
protected abstract fun show()
|
||||
protected abstract fun show(duration: Long)
|
||||
|
||||
protected abstract fun hide()
|
||||
protected abstract fun hide(duration: Long)
|
||||
|
||||
enum class AnimationState {
|
||||
NONE,
|
||||
@@ -110,13 +122,13 @@ abstract class DSLSettingsFragment(
|
||||
|
||||
open class ToolbarShadowAnimationHelper(private val toolbarShadow: View) : OnScrollAnimationHelper() {
|
||||
|
||||
override fun show() {
|
||||
override fun show(duration: Long) {
|
||||
toolbarShadow.animate()
|
||||
.setDuration(duration)
|
||||
.alpha(1f)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
override fun hide(duration: Long) {
|
||||
toolbarShadow.animate()
|
||||
.setDuration(duration)
|
||||
.alpha(0f)
|
||||
|
||||
@@ -715,8 +715,8 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
}
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
override fun show(duration: Long) {
|
||||
super.show(duration)
|
||||
|
||||
toolbarAvatar
|
||||
.animate()
|
||||
@@ -736,8 +736,8 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
.alpha(1f)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
super.hide()
|
||||
override fun hide(duration: Long) {
|
||||
super.hide(duration)
|
||||
|
||||
toolbarAvatar
|
||||
.animate()
|
||||
|
||||
Reference in New Issue
Block a user