Fix incorrect appbar lift state when opening MangaController in hidden state (#5990)

This commit is contained in:
Ivan Iskandar 2021-10-01 20:13:00 +07:00 committed by GitHub
parent 7ed25704d6
commit 09f0ac866f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,6 +77,10 @@ class HideToolbarOnScrollBehavior : AppBarLayout.Behavior() {
child: AppBarLayout,
isVisible: Boolean
) {
val current = getTopBottomOffsetForScrollingSibling(child)
val target = if (isVisible) 0 else -toolbarHeight
if (current == target) return
offsetAnimator?.cancel()
offsetAnimator = ValueAnimator().apply {
interpolator = DecelerateInterpolator()
@ -85,18 +89,12 @@ class HideToolbarOnScrollBehavior : AppBarLayout.Behavior() {
setHeaderTopBottomOffset(coordinatorLayout, child, it.animatedValue as Int)
}
doOnEnd {
if (!isVisible &&
!child.isLifted &&
(child as? ElevationAppBarLayout)?.isTransparentWhenNotLifted == true
) {
child.isLifted = true
if ((child as? ElevationAppBarLayout)?.isTransparentWhenNotLifted == true) {
child.isLifted = !isVisible
}
}
setIntValues(current, target)
start()
}
offsetAnimator?.setIntValues(
getTopBottomOffsetForScrollingSibling(child),
if (isVisible) 0 else -toolbarHeight
)
offsetAnimator?.start()
}
}