Fix inconsistent toolbar animation state on back.
This commit is contained in:
parent
e504c490c8
commit
93bb49dc16
2 changed files with 23 additions and 11 deletions
|
@ -52,7 +52,7 @@ abstract class DSLSettingsFragment(
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
scrollAnimationHelper.onScrolled(recyclerView, 0, 0)
|
scrollAnimationHelper.setImmediateState(recyclerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun getOnScrollAnimationHelper(toolbarShadow: View): OnScrollAnimationHelper {
|
protected open fun getOnScrollAnimationHelper(toolbarShadow: View): OnScrollAnimationHelper {
|
||||||
|
@ -86,8 +86,20 @@ abstract class DSLSettingsFragment(
|
||||||
|
|
||||||
when (newAnimationState) {
|
when (newAnimationState) {
|
||||||
AnimationState.NONE -> throw AssertionError()
|
AnimationState.NONE -> throw AssertionError()
|
||||||
AnimationState.HIDE -> hide()
|
AnimationState.HIDE -> hide(duration)
|
||||||
AnimationState.SHOW -> show()
|
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
|
lastAnimationState = newAnimationState
|
||||||
|
@ -97,9 +109,9 @@ abstract class DSLSettingsFragment(
|
||||||
return if (recyclerView.canScrollVertically(-1)) AnimationState.SHOW else AnimationState.HIDE
|
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 {
|
enum class AnimationState {
|
||||||
NONE,
|
NONE,
|
||||||
|
@ -110,13 +122,13 @@ abstract class DSLSettingsFragment(
|
||||||
|
|
||||||
open class ToolbarShadowAnimationHelper(private val toolbarShadow: View) : OnScrollAnimationHelper() {
|
open class ToolbarShadowAnimationHelper(private val toolbarShadow: View) : OnScrollAnimationHelper() {
|
||||||
|
|
||||||
override fun show() {
|
override fun show(duration: Long) {
|
||||||
toolbarShadow.animate()
|
toolbarShadow.animate()
|
||||||
.setDuration(duration)
|
.setDuration(duration)
|
||||||
.alpha(1f)
|
.alpha(1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hide() {
|
override fun hide(duration: Long) {
|
||||||
toolbarShadow.animate()
|
toolbarShadow.animate()
|
||||||
.setDuration(duration)
|
.setDuration(duration)
|
||||||
.alpha(0f)
|
.alpha(0f)
|
||||||
|
|
|
@ -715,8 +715,8 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun show() {
|
override fun show(duration: Long) {
|
||||||
super.show()
|
super.show(duration)
|
||||||
|
|
||||||
toolbarAvatar
|
toolbarAvatar
|
||||||
.animate()
|
.animate()
|
||||||
|
@ -736,8 +736,8 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||||
.alpha(1f)
|
.alpha(1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hide() {
|
override fun hide(duration: Long) {
|
||||||
super.hide()
|
super.hide(duration)
|
||||||
|
|
||||||
toolbarAvatar
|
toolbarAvatar
|
||||||
.animate()
|
.animate()
|
||||||
|
|
Loading…
Add table
Reference in a new issue