Skip to content

Commit 32633a6

Browse files
pekingmeleticiarossi
authored andcommitted
[TopAppBar] Applied formatting only.
PiperOrigin-RevId: 713744692
1 parent d28488d commit 32633a6

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

lib/java/com/google/android/material/appbar/AppBarLayout.java

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,14 @@ public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int
268268
}
269269
}
270270

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);
276279

277280
if (a.hasValue(R.styleable.AppBarLayout_expanded)) {
278281
setExpanded(
@@ -354,16 +357,17 @@ private void initializeLiftOnScrollWithColor(
354357
private void initializeLiftOnScrollWithElevation(
355358
Context context, MaterialShapeDrawable background) {
356359
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+
};
367371

368372
setBackground(background);
369373
}
@@ -559,8 +563,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
559563
case MeasureSpec.AT_MOST:
560564
// For AT_MOST, we need to clamp our desired height with the max height
561565
newHeight =
562-
clamp(
563-
getMeasuredHeight() + getTopInset(), 0, MeasureSpec.getSize(heightMeasureSpec));
566+
clamp(getMeasuredHeight() + getTopInset(), 0, MeasureSpec.getSize(heightMeasureSpec));
564567
break;
565568
case MeasureSpec.UNSPECIFIED:
566569
// For UNSPECIFIED we can use any height so just add the top inset
@@ -634,9 +637,10 @@ private void invalidateScrollRanges() {
634637
// If there's a pending action, we should skip this step and respect the pending action.
635638
SavedState savedState =
636639
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);
640644
// Invalidate the scroll ranges
641645
totalScrollRange = INVALID_SCROLL_RANGE;
642646
downPreScrollRange = INVALID_SCROLL_RANGE;
@@ -1040,8 +1044,7 @@ private boolean isLiftOnScrollCompatibleBackground() {
10401044
return getBackground() instanceof MaterialShapeDrawable;
10411045
}
10421046

1043-
private void startLiftOnScrollColorAnimation(
1044-
float fromValue, float toValue) {
1047+
private void startLiftOnScrollColorAnimation(float fromValue, float toValue) {
10451048
if (liftOnScrollColorAnimator != null) {
10461049
liftOnScrollColorAnimator.cancel();
10471050
}
@@ -1225,6 +1228,7 @@ public static class LayoutParams extends LinearLayout.LayoutParams {
12251228
})
12261229
@Retention(RetentionPolicy.SOURCE)
12271230
public @interface ScrollFlags {}
1231+
12281232
/**
12291233
* Disable scrolling on the view. This flag should not be combined with any of the other scroll
12301234
* flags.
@@ -1296,8 +1300,8 @@ public static class LayoutParams extends LinearLayout.LayoutParams {
12961300

12971301
/**
12981302
* 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.
13011305
*/
13021306
public static final int SCROLL_EFFECT_COMPRESS = 1;
13031307

@@ -1396,9 +1400,7 @@ private ChildScrollEffect createScrollEffectFromInt(int scrollEffectInt) {
13961400
}
13971401
}
13981402

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 */
14021404
@Nullable
14031405
public ChildScrollEffect getScrollEffect() {
14041406
return scrollEffect;
@@ -1408,7 +1410,7 @@ public ChildScrollEffect getScrollEffect() {
14081410
* Set the scroll effect to be applied when the AppBarLayout's offset changes.
14091411
*
14101412
* @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.
14121414
*/
14131415
public void setScrollEffect(@Nullable ChildScrollEffect scrollEffect) {
14141416
this.scrollEffect = scrollEffect;
@@ -1417,9 +1419,9 @@ public void setScrollEffect(@Nullable ChildScrollEffect scrollEffect) {
14171419
/**
14181420
* Set the scroll effect to be applied when the AppBarLayout's offset changes.
14191421
*
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.
14231425
*/
14241426
public void setScrollEffect(@ScrollEffect int scrollEffect) {
14251427
this.scrollEffect = createScrollEffectFromInt(scrollEffect);
@@ -1816,7 +1818,7 @@ public boolean onLayoutChild(
18161818
// Keep fully expanded.
18171819
setHeaderTopBottomOffset(parent, abl, 0);
18181820
} else {
1819-
// Not fully scrolled, restore the visible percetage of child layout.
1821+
// Not fully scrolled, restore the visible percentage of child layout.
18201822
View child = abl.getChildAt(savedState.firstVisibleChildIndex);
18211823
int offset = -child.getBottom();
18221824
if (savedState.firstVisibleChildAtMinimumHeight) {
@@ -1850,8 +1852,7 @@ public boolean onLayoutChild(
18501852

18511853
// We may have changed size, so let's constrain the top and bottom offset correctly,
18521854
// just in case we're out of the bounds
1853-
setTopAndBottomOffset(
1854-
clamp(getTopAndBottomOffset(), -abl.getTotalScrollRange(), 0));
1855+
setTopAndBottomOffset(clamp(getTopAndBottomOffset(), -abl.getTotalScrollRange(), 0));
18551856

18561857
// Update the AppBarLayout's drawable state for any elevation changes. This is needed so that
18571858
// the elevation is set in the first layout, so that we don't get a visual jump pre-N (due to

lib/java/com/google/android/material/appbar/CollapsingToolbarLayout.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,14 +2155,16 @@ public void onOffsetChanged(AppBarLayout layout, int verticalOffset) {
21552155
int height = getHeight();
21562156
final int expandRange = height - getMinimumHeight() - insetTop;
21572157
final int scrimRange = height - getScrimVisibleHeightTrigger();
2158+
final int currentOffsetY = currentOffset + expandRange;
2159+
final float expansionFraction = Math.abs(verticalOffset) / (float) expandRange;
21582160
collapsingTitleHelper.setFadeModeStartFraction(
21592161
Math.min(1, (float) scrimRange / (float) expandRange));
2160-
collapsingTitleHelper.setCurrentOffsetY(currentOffset + expandRange);
2161-
collapsingTitleHelper.setExpansionFraction(Math.abs(verticalOffset) / (float) expandRange);
2162+
collapsingTitleHelper.setCurrentOffsetY(currentOffsetY);
2163+
collapsingTitleHelper.setExpansionFraction(expansionFraction);
21622164
collapsingSubtitleHelper.setFadeModeStartFraction(
21632165
Math.min(1, (float) scrimRange / (float) expandRange));
2164-
collapsingSubtitleHelper.setCurrentOffsetY(currentOffset + expandRange);
2165-
collapsingSubtitleHelper.setExpansionFraction(Math.abs(verticalOffset) / (float) expandRange);
2166+
collapsingSubtitleHelper.setCurrentOffsetY(currentOffsetY);
2167+
collapsingSubtitleHelper.setExpansionFraction(expansionFraction);
21662168
}
21672169
}
21682170

0 commit comments

Comments
 (0)