@@ -268,11 +268,14 @@ public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int
268
268
}
269
269
}
270
270
271
- liftOnScrollColorDuration = MotionUtils .resolveThemeDuration (context ,
272
- R .attr .motionDurationMedium2 ,
273
- getResources ().getInteger (R .integer .app_bar_elevation_anim_duration ));
274
- liftOnScrollColorInterpolator = MotionUtils .resolveThemeInterpolator (context ,
275
- R .attr .motionEasingStandardInterpolator , AnimationUtils .LINEAR_INTERPOLATOR );
271
+ liftOnScrollColorDuration =
272
+ MotionUtils .resolveThemeDuration (
273
+ context ,
274
+ R .attr .motionDurationMedium2 ,
275
+ getResources ().getInteger (R .integer .app_bar_elevation_anim_duration ));
276
+ liftOnScrollColorInterpolator =
277
+ MotionUtils .resolveThemeInterpolator (
278
+ context , R .attr .motionEasingStandardInterpolator , AnimationUtils .LINEAR_INTERPOLATOR );
276
279
277
280
if (a .hasValue (R .styleable .AppBarLayout_expanded )) {
278
281
setExpanded (
@@ -354,16 +357,17 @@ private void initializeLiftOnScrollWithColor(
354
357
private void initializeLiftOnScrollWithElevation (
355
358
Context context , MaterialShapeDrawable background ) {
356
359
background .initializeElevationOverlay (context );
357
- liftOnScrollColorUpdateListener = valueAnimator -> {
358
- float elevation = (float ) valueAnimator .getAnimatedValue ();
359
- background .setElevation (elevation );
360
- if (statusBarForeground instanceof MaterialShapeDrawable ) {
361
- ((MaterialShapeDrawable ) statusBarForeground ).setElevation (elevation );
362
- }
363
- for (LiftOnScrollListener liftOnScrollListener : liftOnScrollListeners ) {
364
- liftOnScrollListener .onUpdate (elevation , background .getResolvedTintColor ());
365
- }
366
- };
360
+ liftOnScrollColorUpdateListener =
361
+ valueAnimator -> {
362
+ float elevation = (float ) valueAnimator .getAnimatedValue ();
363
+ background .setElevation (elevation );
364
+ if (statusBarForeground instanceof MaterialShapeDrawable ) {
365
+ ((MaterialShapeDrawable ) statusBarForeground ).setElevation (elevation );
366
+ }
367
+ for (LiftOnScrollListener liftOnScrollListener : liftOnScrollListeners ) {
368
+ liftOnScrollListener .onUpdate (elevation , background .getResolvedTintColor ());
369
+ }
370
+ };
367
371
368
372
setBackground (background );
369
373
}
@@ -559,8 +563,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
559
563
case MeasureSpec .AT_MOST :
560
564
// For AT_MOST, we need to clamp our desired height with the max height
561
565
newHeight =
562
- clamp (
563
- getMeasuredHeight () + getTopInset (), 0 , MeasureSpec .getSize (heightMeasureSpec ));
566
+ clamp (getMeasuredHeight () + getTopInset (), 0 , MeasureSpec .getSize (heightMeasureSpec ));
564
567
break ;
565
568
case MeasureSpec .UNSPECIFIED :
566
569
// For UNSPECIFIED we can use any height so just add the top inset
@@ -634,9 +637,10 @@ private void invalidateScrollRanges() {
634
637
// If there's a pending action, we should skip this step and respect the pending action.
635
638
SavedState savedState =
636
639
behavior == null
637
- || totalScrollRange == INVALID_SCROLL_RANGE
638
- || pendingAction != PENDING_ACTION_NONE
639
- ? null : behavior .saveScrollState (AbsSavedState .EMPTY_STATE , this );
640
+ || totalScrollRange == INVALID_SCROLL_RANGE
641
+ || pendingAction != PENDING_ACTION_NONE
642
+ ? null
643
+ : behavior .saveScrollState (AbsSavedState .EMPTY_STATE , this );
640
644
// Invalidate the scroll ranges
641
645
totalScrollRange = INVALID_SCROLL_RANGE ;
642
646
downPreScrollRange = INVALID_SCROLL_RANGE ;
@@ -1040,8 +1044,7 @@ private boolean isLiftOnScrollCompatibleBackground() {
1040
1044
return getBackground () instanceof MaterialShapeDrawable ;
1041
1045
}
1042
1046
1043
- private void startLiftOnScrollColorAnimation (
1044
- float fromValue , float toValue ) {
1047
+ private void startLiftOnScrollColorAnimation (float fromValue , float toValue ) {
1045
1048
if (liftOnScrollColorAnimator != null ) {
1046
1049
liftOnScrollColorAnimator .cancel ();
1047
1050
}
@@ -1225,6 +1228,7 @@ public static class LayoutParams extends LinearLayout.LayoutParams {
1225
1228
})
1226
1229
@ Retention (RetentionPolicy .SOURCE )
1227
1230
public @interface ScrollFlags {}
1231
+
1228
1232
/**
1229
1233
* Disable scrolling on the view. This flag should not be combined with any of the other scroll
1230
1234
* flags.
@@ -1296,8 +1300,8 @@ public static class LayoutParams extends LinearLayout.LayoutParams {
1296
1300
1297
1301
/**
1298
1302
* An effect that will "compress" this view as it hits the scroll ceiling (typically the top of
1299
- * the screen). This is a parallax effect that masks this view and decreases its scroll ratio
1300
- * in relation to the AppBarLayout's offset.
1303
+ * the screen). This is a parallax effect that masks this view and decreases its scroll ratio in
1304
+ * relation to the AppBarLayout's offset.
1301
1305
*/
1302
1306
public static final int SCROLL_EFFECT_COMPRESS = 1 ;
1303
1307
@@ -1396,9 +1400,7 @@ private ChildScrollEffect createScrollEffectFromInt(int scrollEffectInt) {
1396
1400
}
1397
1401
}
1398
1402
1399
- /**
1400
- * Get the scroll effect to be applied when the AppBarLayout's offset changes
1401
- */
1403
+ /** Get the scroll effect to be applied when the AppBarLayout's offset changes */
1402
1404
@ Nullable
1403
1405
public ChildScrollEffect getScrollEffect () {
1404
1406
return scrollEffect ;
@@ -1408,7 +1410,7 @@ public ChildScrollEffect getScrollEffect() {
1408
1410
* Set the scroll effect to be applied when the AppBarLayout's offset changes.
1409
1411
*
1410
1412
* @param scrollEffect An {@code AppBarLayoutChildScrollEffect} implementation. If null is
1411
- * passed, the scroll effect will be cleared and no effect will be applied.
1413
+ * passed, the scroll effect will be cleared and no effect will be applied.
1412
1414
*/
1413
1415
public void setScrollEffect (@ Nullable ChildScrollEffect scrollEffect ) {
1414
1416
this .scrollEffect = scrollEffect ;
@@ -1417,9 +1419,9 @@ public void setScrollEffect(@Nullable ChildScrollEffect scrollEffect) {
1417
1419
/**
1418
1420
* Set the scroll effect to be applied when the AppBarLayout's offset changes.
1419
1421
*
1420
- * @param scrollEffect An {@code AppBarLayoutChildScrollEffect} implementation. If
1421
- * {@link #SCROLL_EFFECT_NONE} is passed, the scroll effect will be cleared and no
1422
- * effect will be applied.
1422
+ * @param scrollEffect An {@code AppBarLayoutChildScrollEffect} implementation. If {@link
1423
+ * #SCROLL_EFFECT_NONE} is passed, the scroll effect will be cleared and no effect will be
1424
+ * applied.
1423
1425
*/
1424
1426
public void setScrollEffect (@ ScrollEffect int scrollEffect ) {
1425
1427
this .scrollEffect = createScrollEffectFromInt (scrollEffect );
@@ -1816,7 +1818,7 @@ public boolean onLayoutChild(
1816
1818
// Keep fully expanded.
1817
1819
setHeaderTopBottomOffset (parent , abl , 0 );
1818
1820
} else {
1819
- // Not fully scrolled, restore the visible percetage of child layout.
1821
+ // Not fully scrolled, restore the visible percentage of child layout.
1820
1822
View child = abl .getChildAt (savedState .firstVisibleChildIndex );
1821
1823
int offset = -child .getBottom ();
1822
1824
if (savedState .firstVisibleChildAtMinimumHeight ) {
@@ -1850,8 +1852,7 @@ public boolean onLayoutChild(
1850
1852
1851
1853
// We may have changed size, so let's constrain the top and bottom offset correctly,
1852
1854
// just in case we're out of the bounds
1853
- setTopAndBottomOffset (
1854
- clamp (getTopAndBottomOffset (), -abl .getTotalScrollRange (), 0 ));
1855
+ setTopAndBottomOffset (clamp (getTopAndBottomOffset (), -abl .getTotalScrollRange (), 0 ));
1855
1856
1856
1857
// Update the AppBarLayout's drawable state for any elevation changes. This is needed so that
1857
1858
// the elevation is set in the first layout, so that we don't get a visual jump pre-N (due to
0 commit comments