More fixes to app bar when switching controllers

This commit is contained in:
Jays2Kings 2022-04-23 04:34:03 -04:00
parent fc4bb9c36f
commit 861e0c3ba8

View file

@ -379,9 +379,11 @@ fun Controller.scrollViewWith(
colorToolbar(!atTopOfRecyclerView())
recycler.post {
if (isControllerVisible) {
activityBinding!!.appBar.updateAppBarAfterY(recycler)
colorToolbar(!atTopOfRecyclerView())
}
}
recycler.addOnScrollListener(
object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
@ -455,8 +457,7 @@ fun Controller.scrollViewWith(
if (newState == RecyclerView.SCROLL_STATE_IDLE &&
(this@scrollViewWith as? BaseController<*>)?.isDragging != true
) {
if (router?.backstack?.lastOrNull()
?.controller == this@scrollViewWith && statusBarHeight > -1 &&
if (isControllerVisible && statusBarHeight > -1 &&
activity != null && activityBinding!!.appBar.height > 0 &&
recycler.translationY == 0f
) {
@ -512,7 +513,7 @@ fun Controller.setItemAnimatorForAppBar(recycler: RecyclerView) {
var itemAppBarAnimator: Animator? = null
fun animateAppBar() {
if (this !is SmallToolbarInterface) {
if (this !is SmallToolbarInterface && isControllerVisible) {
itemAppBarAnimator?.cancel()
val duration = (recycler.itemAnimator?.changeDuration ?: 250) * 2
itemAppBarAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
@ -538,7 +539,9 @@ fun Controller.setItemAnimatorForAppBar(recycler: RecyclerView) {
}
override fun onAnimationFinished(viewHolder: RecyclerView.ViewHolder) {
if (isControllerVisible) {
activityBinding?.appBar?.updateAppBarAfterY(recycler)
}
super.onAnimationFinished(viewHolder)
}