mirror of
https://github.com/topjohnwu/Magisk
synced 2024-11-13 20:54:12 +01:00
Added a check against view being initialized in its behavior
The view will be simply hidden if not
This commit is contained in:
parent
3c0630bfc0
commit
b59e05c63e
@ -3,6 +3,7 @@ package com.topjohnwu.magisk.utils
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||
@ -15,10 +16,16 @@ class HideBottomViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<
|
||||
HideableBehavior<V> {
|
||||
|
||||
private var lockState: Boolean = false
|
||||
private var isLaidOut = false
|
||||
|
||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: V, dependency: View) =
|
||||
super.layoutDependsOn(parent, child, dependency) or (dependency is Snackbar.SnackbarLayout)
|
||||
|
||||
override fun onLayoutChild(parent: CoordinatorLayout, child: V, layoutDirection: Int): Boolean {
|
||||
isLaidOut = true
|
||||
return super.onLayoutChild(parent, child, layoutDirection)
|
||||
}
|
||||
|
||||
override fun onDependentViewChanged(
|
||||
parent: CoordinatorLayout,
|
||||
child: V,
|
||||
@ -92,8 +99,15 @@ class HideBottomViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<
|
||||
}
|
||||
|
||||
if (hide) {
|
||||
slideDown(view)
|
||||
// view is not laid out and drawn yet properly, so animation will not be attached
|
||||
// hence we just simply hide the view
|
||||
if (!isLaidOut) {
|
||||
view.isGone = true
|
||||
} else {
|
||||
slideDown(view)
|
||||
}
|
||||
} else {
|
||||
view.isVisible = true
|
||||
slideUp(view)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user