Updated the material library back to alpha03 version

The aforementioned fragment has fixed issue with layouts being oversized on API21 (maybe a bit lower and higher as well, did not test) which was notable on homepage.
Unfortunately it deprecated most of the logic behind hiding of the top action view. Since it inherited and overridden the functionality from HideBottomViewOnScrollBehavior it no longer called the old methods and so the whole class was rendered _useless_. Fortunately we didn't need the whole backing implementation so the parent class was changed to the bare minimum. Hopefully this incident will not repeat.

Thanks goes to material team for introducing breaking changes in feature update.
This commit is contained in:
Viktor De Pasquale 2020-01-06 16:24:27 +01:00
parent ea9947081f
commit c0b56b927f
2 changed files with 15 additions and 25 deletions

View File

@ -121,7 +121,7 @@ dependencies {
implementation "androidx.navigation:navigation-ui-ktx:${vNav}"
implementation 'androidx.biometric:biometric:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.preference:preference:1.1.0'
@ -132,5 +132,5 @@ dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.core:core-ktx:1.2.0-rc01'
// DO NOT UPDATE, 1.2.x has bunch of things broken in functionality against 1.1.x
implementation 'com.google.android.material:material:1.1.0-beta02'
implementation 'com.google.android.material:material:1.2.0-alpha03'
}

View File

@ -4,23 +4,24 @@ import android.animation.TimeInterpolator
import android.view.View
import android.view.ViewGroup
import android.view.ViewPropertyAnimator
import androidx.annotation.Dimension
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.ViewCompat
import com.google.android.material.animation.AnimationUtils
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior
class HideTopViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<V>(),
class HideTopViewOnScrollBehavior<V : View> :
CoordinatorLayout.Behavior<V>(),
HideableBehavior<V> {
companion object {
private const val STATE_SCROLLED_DOWN = 1
private const val STATE_SCROLLED_UP = 2
private const val ENTER_ANIMATION_DURATION = 225
private const val EXIT_ANIMATION_DURATION = 175
}
private var height = 0
private var currentState = STATE_SCROLLED_UP
private var additionalHiddenOffsetY = 0
private var currentAnimator: ViewPropertyAnimator? = null
private var lockState: Boolean = false
@ -34,26 +35,13 @@ class HideTopViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<V>(
return super.onLayoutChild(parent, child, layoutDirection)
}
/**
* Sets an additional offset for the y position used to hide the view.
*
* @param child the child view that is hidden by this behavior
* @param offset the additional offset in pixels that should be added when the view slides away
*/
override fun setAdditionalHiddenOffsetY(child: V, @Dimension offset: Int) {
additionalHiddenOffsetY = offset
if (currentState == STATE_SCROLLED_DOWN) {
child.translationY = (height + additionalHiddenOffsetY).toFloat()
}
}
override fun onStartNestedScroll(
coordinatorLayout: CoordinatorLayout,
child: V,
directTargetChild: View,
target: View,
nestedScrollAxes: Int
nestedScrollAxes: Int,
type: Int
) = nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
override fun onNestedScroll(
@ -63,7 +51,9 @@ class HideTopViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<V>(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int
dyUnconsumed: Int,
type: Int,
consumed: IntArray
) {
// when initiating scroll while the view is at the bottom or at the top and pushing it
// further, the parent will report consumption of 0
@ -95,7 +85,7 @@ class HideTopViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<V>(
* Perform an animation that will slide the child from it's current position to be totally on the
* screen.
*/
override fun slideDown(child: V) {
private fun slideDown(child: V) {
if (currentState == STATE_SCROLLED_UP || lockState) {
return
}
@ -118,7 +108,7 @@ class HideTopViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<V>(
* Perform an animation that will slide the child from it's current position to be totally off the
* screen.
*/
override fun slideUp(child: V) {
private fun slideUp(child: V) {
if (currentState == STATE_SCROLLED_DOWN || lockState) {
return
}
@ -131,7 +121,7 @@ class HideTopViewOnScrollBehavior<V : View> : HideBottomViewOnScrollBehavior<V>(
currentState = STATE_SCROLLED_DOWN
animateChildTo(
child,
-(height + additionalHiddenOffsetY),
-height,
EXIT_ANIMATION_DURATION.toLong(),
AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR
)