Rabbit-R1/android (non root)/java/sources/com/google/android/material/appbar/CollapsingToolbarLayout.java

1034 lines
39 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package com.google.android.material.appbar;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.math.MathUtils;
import androidx.core.util.ObjectsCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.R;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.elevation.ElevationOverlayProvider;
import com.google.android.material.internal.CollapsingTextHelper;
import com.google.android.material.internal.DescendantOffsetUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes2.dex */
public class CollapsingToolbarLayout extends FrameLayout {
private static final int DEFAULT_SCRIM_ANIMATION_DURATION = 600;
private static final int DEF_STYLE_RES = R.style.Widget_Design_CollapsingToolbar;
public static final int TITLE_COLLAPSE_MODE_FADE = 1;
public static final int TITLE_COLLAPSE_MODE_SCALE = 0;
final CollapsingTextHelper collapsingTextHelper;
private boolean collapsingTitleEnabled;
private Drawable contentScrim;
int currentOffset;
private boolean drawCollapsingTitle;
private View dummyView;
final ElevationOverlayProvider elevationOverlayProvider;
private int expandedMarginBottom;
private int expandedMarginEnd;
private int expandedMarginStart;
private int expandedMarginTop;
private int extraMultilineHeight;
private boolean extraMultilineHeightEnabled;
private boolean forceApplySystemWindowInsetTop;
WindowInsetsCompat lastInsets;
private AppBarLayout.OnOffsetChangedListener onOffsetChangedListener;
private boolean refreshToolbar;
private int scrimAlpha;
private long scrimAnimationDuration;
private final TimeInterpolator scrimAnimationFadeInInterpolator;
private final TimeInterpolator scrimAnimationFadeOutInterpolator;
private ValueAnimator scrimAnimator;
private int scrimVisibleHeightTrigger;
private boolean scrimsAreShown;
Drawable statusBarScrim;
private int titleCollapseMode;
private final Rect tmpRect;
private ViewGroup toolbar;
private View toolbarDirectChild;
private int toolbarId;
private int topInsetApplied;
/* loaded from: classes2.dex */
public interface StaticLayoutBuilderConfigurer extends com.google.android.material.internal.StaticLayoutBuilderConfigurer {
}
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes2.dex */
public @interface TitleCollapseMode {
}
private boolean isTitleCollapseFadeMode() {
return this.titleCollapseMode == 1;
}
private boolean isToolbarChild(View view) {
View view2 = this.toolbarDirectChild;
if (view2 == null || view2 == this) {
if (view == this.toolbar) {
return true;
}
} else if (view == view2) {
return true;
}
return false;
}
public Drawable getContentScrim() {
return this.contentScrim;
}
public int getExpandedTitleMarginBottom() {
return this.expandedMarginBottom;
}
public int getExpandedTitleMarginEnd() {
return this.expandedMarginEnd;
}
public int getExpandedTitleMarginStart() {
return this.expandedMarginStart;
}
public int getExpandedTitleMarginTop() {
return this.expandedMarginTop;
}
int getScrimAlpha() {
return this.scrimAlpha;
}
public long getScrimAnimationDuration() {
return this.scrimAnimationDuration;
}
public Drawable getStatusBarScrim() {
return this.statusBarScrim;
}
public int getTitleCollapseMode() {
return this.titleCollapseMode;
}
public boolean isExtraMultilineHeightEnabled() {
return this.extraMultilineHeightEnabled;
}
public boolean isForceApplySystemWindowInsetTop() {
return this.forceApplySystemWindowInsetTop;
}
public boolean isTitleEnabled() {
return this.collapsingTitleEnabled;
}
public void setExtraMultilineHeightEnabled(boolean z) {
this.extraMultilineHeightEnabled = z;
}
public void setForceApplySystemWindowInsetTop(boolean z) {
this.forceApplySystemWindowInsetTop = z;
}
public void setScrimAnimationDuration(long j) {
this.scrimAnimationDuration = j;
}
public CollapsingToolbarLayout(Context context) {
this(context, null);
}
public CollapsingToolbarLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.collapsingToolbarLayoutStyle);
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public CollapsingToolbarLayout(android.content.Context r11, android.util.AttributeSet r12, int r13) {
/*
Method dump skipped, instructions count: 425
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.CollapsingToolbarLayout.<init>(android.content.Context, android.util.AttributeSet, int):void");
}
@Override // android.view.ViewGroup, android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
ViewParent parent = getParent();
if (parent instanceof AppBarLayout) {
AppBarLayout appBarLayout = (AppBarLayout) parent;
disableLiftOnScrollIfNeeded(appBarLayout);
ViewCompat.setFitsSystemWindows(this, ViewCompat.getFitsSystemWindows(appBarLayout));
if (this.onOffsetChangedListener == null) {
this.onOffsetChangedListener = new OffsetUpdateListener();
}
appBarLayout.addOnOffsetChangedListener(this.onOffsetChangedListener);
ViewCompat.requestApplyInsets(this);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
ViewParent parent = getParent();
AppBarLayout.OnOffsetChangedListener onOffsetChangedListener = this.onOffsetChangedListener;
if (onOffsetChangedListener != null && (parent instanceof AppBarLayout)) {
((AppBarLayout) parent).removeOnOffsetChangedListener(onOffsetChangedListener);
}
super.onDetachedFromWindow();
}
WindowInsetsCompat onWindowInsetChanged(WindowInsetsCompat windowInsetsCompat) {
WindowInsetsCompat windowInsetsCompat2 = ViewCompat.getFitsSystemWindows(this) ? windowInsetsCompat : null;
if (!ObjectsCompat.equals(this.lastInsets, windowInsetsCompat2)) {
this.lastInsets = windowInsetsCompat2;
requestLayout();
}
return windowInsetsCompat.consumeSystemWindowInsets();
}
@Override // android.view.View
public void draw(Canvas canvas) {
Drawable drawable;
super.draw(canvas);
ensureToolbar();
if (this.toolbar == null && (drawable = this.contentScrim) != null && this.scrimAlpha > 0) {
drawable.mutate().setAlpha(this.scrimAlpha);
this.contentScrim.draw(canvas);
}
if (this.collapsingTitleEnabled && this.drawCollapsingTitle) {
if (this.toolbar != null && this.contentScrim != null && this.scrimAlpha > 0 && isTitleCollapseFadeMode() && this.collapsingTextHelper.getExpansionFraction() < this.collapsingTextHelper.getFadeModeThresholdFraction()) {
int save = canvas.save();
canvas.clipRect(this.contentScrim.getBounds(), Region.Op.DIFFERENCE);
this.collapsingTextHelper.draw(canvas);
canvas.restoreToCount(save);
} else {
this.collapsingTextHelper.draw(canvas);
}
}
if (this.statusBarScrim == null || this.scrimAlpha <= 0) {
return;
}
WindowInsetsCompat windowInsetsCompat = this.lastInsets;
int systemWindowInsetTop = windowInsetsCompat != null ? windowInsetsCompat.getSystemWindowInsetTop() : 0;
if (systemWindowInsetTop > 0) {
this.statusBarScrim.setBounds(0, -this.currentOffset, getWidth(), systemWindowInsetTop - this.currentOffset);
this.statusBarScrim.mutate().setAlpha(this.scrimAlpha);
this.statusBarScrim.draw(canvas);
}
}
@Override // android.view.View
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
this.collapsingTextHelper.maybeUpdateFontWeightAdjustment(configuration);
}
@Override // android.view.ViewGroup
protected boolean drawChild(Canvas canvas, View view, long j) {
boolean z;
if (this.contentScrim == null || this.scrimAlpha <= 0 || !isToolbarChild(view)) {
z = false;
} else {
updateContentScrimBounds(this.contentScrim, view, getWidth(), getHeight());
this.contentScrim.mutate().setAlpha(this.scrimAlpha);
this.contentScrim.draw(canvas);
z = true;
}
return super.drawChild(canvas, view, j) || z;
}
@Override // android.view.View
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
Drawable drawable = this.contentScrim;
if (drawable != null) {
updateContentScrimBounds(drawable, i, i2);
}
}
private void disableLiftOnScrollIfNeeded(AppBarLayout appBarLayout) {
if (isTitleCollapseFadeMode()) {
appBarLayout.setLiftOnScroll(false);
}
}
private void updateContentScrimBounds(Drawable drawable, int i, int i2) {
updateContentScrimBounds(drawable, this.toolbar, i, i2);
}
private void updateContentScrimBounds(Drawable drawable, View view, int i, int i2) {
if (isTitleCollapseFadeMode() && view != null && this.collapsingTitleEnabled) {
i2 = view.getBottom();
}
drawable.setBounds(0, 0, i, i2);
}
private void ensureToolbar() {
if (this.refreshToolbar) {
ViewGroup viewGroup = null;
this.toolbar = null;
this.toolbarDirectChild = null;
int i = this.toolbarId;
if (i != -1) {
ViewGroup viewGroup2 = (ViewGroup) findViewById(i);
this.toolbar = viewGroup2;
if (viewGroup2 != null) {
this.toolbarDirectChild = findDirectChild(viewGroup2);
}
}
if (this.toolbar == null) {
int childCount = getChildCount();
int i2 = 0;
while (true) {
if (i2 >= childCount) {
break;
}
View childAt = getChildAt(i2);
if (isToolbar(childAt)) {
viewGroup = (ViewGroup) childAt;
break;
}
i2++;
}
this.toolbar = viewGroup;
}
updateDummyView();
this.refreshToolbar = false;
}
}
private static boolean isToolbar(View view) {
return (view instanceof Toolbar) || (view instanceof android.widget.Toolbar);
}
private View findDirectChild(View view) {
for (ViewParent parent = view.getParent(); parent != this && parent != null; parent = parent.getParent()) {
if (parent instanceof View) {
view = parent;
}
}
return view;
}
private void updateDummyView() {
View view;
if (!this.collapsingTitleEnabled && (view = this.dummyView) != null) {
ViewParent parent = view.getParent();
if (parent instanceof ViewGroup) {
((ViewGroup) parent).removeView(this.dummyView);
}
}
if (!this.collapsingTitleEnabled || this.toolbar == null) {
return;
}
if (this.dummyView == null) {
this.dummyView = new View(getContext());
}
if (this.dummyView.getParent() == null) {
this.toolbar.addView(this.dummyView, -1, -1);
}
}
@Override // android.widget.FrameLayout, android.view.View
protected void onMeasure(int i, int i2) {
ensureToolbar();
super.onMeasure(i, i2);
int mode = View.MeasureSpec.getMode(i2);
WindowInsetsCompat windowInsetsCompat = this.lastInsets;
int systemWindowInsetTop = windowInsetsCompat != null ? windowInsetsCompat.getSystemWindowInsetTop() : 0;
if ((mode == 0 || this.forceApplySystemWindowInsetTop) && systemWindowInsetTop > 0) {
this.topInsetApplied = systemWindowInsetTop;
super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + systemWindowInsetTop, 1073741824));
}
if (this.extraMultilineHeightEnabled && this.collapsingTextHelper.getMaxLines() > 1) {
updateTitleFromToolbarIfNeeded();
updateTextBounds(0, 0, getMeasuredWidth(), getMeasuredHeight(), true);
int expandedLineCount = this.collapsingTextHelper.getExpandedLineCount();
if (expandedLineCount > 1) {
this.extraMultilineHeight = Math.round(this.collapsingTextHelper.getExpandedTextFullHeight()) * (expandedLineCount - 1);
super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + this.extraMultilineHeight, 1073741824));
}
}
ViewGroup viewGroup = this.toolbar;
if (viewGroup != null) {
View view = this.toolbarDirectChild;
if (view == null || view == this) {
setMinimumHeight(getHeightWithMargins(viewGroup));
} else {
setMinimumHeight(getHeightWithMargins(view));
}
}
}
@Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
WindowInsetsCompat windowInsetsCompat = this.lastInsets;
if (windowInsetsCompat != null) {
int systemWindowInsetTop = windowInsetsCompat.getSystemWindowInsetTop();
int childCount = getChildCount();
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = getChildAt(i5);
if (!ViewCompat.getFitsSystemWindows(childAt) && childAt.getTop() < systemWindowInsetTop) {
ViewCompat.offsetTopAndBottom(childAt, systemWindowInsetTop);
}
}
}
int childCount2 = getChildCount();
for (int i6 = 0; i6 < childCount2; i6++) {
getViewOffsetHelper(getChildAt(i6)).onViewLayout();
}
updateTextBounds(i, i2, i3, i4, false);
updateTitleFromToolbarIfNeeded();
updateScrimVisibility();
int childCount3 = getChildCount();
for (int i7 = 0; i7 < childCount3; i7++) {
getViewOffsetHelper(getChildAt(i7)).applyOffsets();
}
}
private void updateTextBounds(int i, int i2, int i3, int i4, boolean z) {
View view;
if (!this.collapsingTitleEnabled || (view = this.dummyView) == null) {
return;
}
boolean z2 = ViewCompat.isAttachedToWindow(view) && this.dummyView.getVisibility() == 0;
this.drawCollapsingTitle = z2;
if (z2 || z) {
boolean z3 = ViewCompat.getLayoutDirection(this) == 1;
updateCollapsedBounds(z3);
this.collapsingTextHelper.setExpandedBounds(z3 ? this.expandedMarginEnd : this.expandedMarginStart, this.tmpRect.top + this.expandedMarginTop, (i3 - i) - (z3 ? this.expandedMarginStart : this.expandedMarginEnd), (i4 - i2) - this.expandedMarginBottom);
this.collapsingTextHelper.recalculate(z);
}
}
private void updateTitleFromToolbarIfNeeded() {
if (this.toolbar != null && this.collapsingTitleEnabled && TextUtils.isEmpty(this.collapsingTextHelper.getText())) {
setTitle(getToolbarTitle(this.toolbar));
}
}
private void updateCollapsedBounds(boolean z) {
int i;
int i2;
int i3;
int i4;
View view = this.toolbarDirectChild;
if (view == null) {
view = this.toolbar;
}
int maxOffsetForPinChild = getMaxOffsetForPinChild(view);
DescendantOffsetUtils.getDescendantRect(this, this.dummyView, this.tmpRect);
ViewGroup viewGroup = this.toolbar;
if (viewGroup instanceof Toolbar) {
Toolbar toolbar = (Toolbar) viewGroup;
i = toolbar.getTitleMarginStart();
i3 = toolbar.getTitleMarginEnd();
i4 = toolbar.getTitleMarginTop();
i2 = toolbar.getTitleMarginBottom();
} else {
ViewGroup viewGroup2 = this.toolbar;
if (viewGroup2 instanceof android.widget.Toolbar) {
android.widget.Toolbar toolbar2 = (android.widget.Toolbar) viewGroup2;
i = toolbar2.getTitleMarginStart();
i3 = toolbar2.getTitleMarginEnd();
i4 = toolbar2.getTitleMarginTop();
i2 = toolbar2.getTitleMarginBottom();
} else {
i = 0;
i2 = 0;
i3 = 0;
i4 = 0;
}
}
CollapsingTextHelper collapsingTextHelper = this.collapsingTextHelper;
int i5 = this.tmpRect.left + (z ? i3 : i);
int i6 = this.tmpRect.top + maxOffsetForPinChild + i4;
int i7 = this.tmpRect.right;
if (!z) {
i = i3;
}
collapsingTextHelper.setCollapsedBounds(i5, i6, i7 - i, (this.tmpRect.bottom + maxOffsetForPinChild) - i2);
}
private static CharSequence getToolbarTitle(View view) {
if (view instanceof Toolbar) {
return ((Toolbar) view).getTitle();
}
if (view instanceof android.widget.Toolbar) {
return ((android.widget.Toolbar) view).getTitle();
}
return null;
}
private static int getHeightWithMargins(View view) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
return view.getMeasuredHeight() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
}
return view.getMeasuredHeight();
}
static ViewOffsetHelper getViewOffsetHelper(View view) {
ViewOffsetHelper viewOffsetHelper = (ViewOffsetHelper) view.getTag(R.id.view_offset_helper);
if (viewOffsetHelper != null) {
return viewOffsetHelper;
}
ViewOffsetHelper viewOffsetHelper2 = new ViewOffsetHelper(view);
view.setTag(R.id.view_offset_helper, viewOffsetHelper2);
return viewOffsetHelper2;
}
public void setTitle(CharSequence charSequence) {
this.collapsingTextHelper.setText(charSequence);
updateContentDescriptionFromTitle();
}
public CharSequence getTitle() {
if (this.collapsingTitleEnabled) {
return this.collapsingTextHelper.getText();
}
return null;
}
public void setTitleCollapseMode(int i) {
this.titleCollapseMode = i;
boolean isTitleCollapseFadeMode = isTitleCollapseFadeMode();
this.collapsingTextHelper.setFadeModeEnabled(isTitleCollapseFadeMode);
ViewParent parent = getParent();
if (parent instanceof AppBarLayout) {
disableLiftOnScrollIfNeeded((AppBarLayout) parent);
}
if (isTitleCollapseFadeMode && this.contentScrim == null) {
setContentScrimColor(getDefaultContentScrimColorForTitleCollapseFadeMode());
}
}
private int getDefaultContentScrimColorForTitleCollapseFadeMode() {
ColorStateList colorStateListOrNull = MaterialColors.getColorStateListOrNull(getContext(), R.attr.colorSurfaceContainer);
if (colorStateListOrNull != null) {
return colorStateListOrNull.getDefaultColor();
}
return this.elevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(getResources().getDimension(R.dimen.design_appbar_elevation));
}
public void setTitleEnabled(boolean z) {
if (z != this.collapsingTitleEnabled) {
this.collapsingTitleEnabled = z;
updateContentDescriptionFromTitle();
updateDummyView();
requestLayout();
}
}
public void setTitleEllipsize(TextUtils.TruncateAt truncateAt) {
this.collapsingTextHelper.setTitleTextEllipsize(truncateAt);
}
public TextUtils.TruncateAt getTitleTextEllipsize() {
return this.collapsingTextHelper.getTitleTextEllipsize();
}
private TextUtils.TruncateAt convertEllipsizeToTruncateAt(int i) {
if (i == 0) {
return TextUtils.TruncateAt.START;
}
if (i == 1) {
return TextUtils.TruncateAt.MIDDLE;
}
if (i == 3) {
return TextUtils.TruncateAt.MARQUEE;
}
return TextUtils.TruncateAt.END;
}
public void setScrimsShown(boolean z) {
setScrimsShown(z, ViewCompat.isLaidOut(this) && !isInEditMode());
}
public void setScrimsShown(boolean z, boolean z2) {
if (this.scrimsAreShown != z) {
if (z2) {
animateScrim(z ? 255 : 0);
} else {
setScrimAlpha(z ? 255 : 0);
}
this.scrimsAreShown = z;
}
}
private void animateScrim(int i) {
ensureToolbar();
ValueAnimator valueAnimator = this.scrimAnimator;
if (valueAnimator == null) {
ValueAnimator valueAnimator2 = new ValueAnimator();
this.scrimAnimator = valueAnimator2;
valueAnimator2.setInterpolator(i > this.scrimAlpha ? this.scrimAnimationFadeInInterpolator : this.scrimAnimationFadeOutInterpolator);
this.scrimAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.appbar.CollapsingToolbarLayout.2
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator3) {
CollapsingToolbarLayout.this.setScrimAlpha(((Integer) valueAnimator3.getAnimatedValue()).intValue());
}
});
} else if (valueAnimator.isRunning()) {
this.scrimAnimator.cancel();
}
this.scrimAnimator.setDuration(this.scrimAnimationDuration);
this.scrimAnimator.setIntValues(this.scrimAlpha, i);
this.scrimAnimator.start();
}
void setScrimAlpha(int i) {
ViewGroup viewGroup;
if (i != this.scrimAlpha) {
if (this.contentScrim != null && (viewGroup = this.toolbar) != null) {
ViewCompat.postInvalidateOnAnimation(viewGroup);
}
this.scrimAlpha = i;
ViewCompat.postInvalidateOnAnimation(this);
}
}
public void setContentScrim(Drawable drawable) {
Drawable drawable2 = this.contentScrim;
if (drawable2 != drawable) {
if (drawable2 != null) {
drawable2.setCallback(null);
}
Drawable mutate = drawable != null ? drawable.mutate() : null;
this.contentScrim = mutate;
if (mutate != null) {
updateContentScrimBounds(mutate, getWidth(), getHeight());
this.contentScrim.setCallback(this);
this.contentScrim.setAlpha(this.scrimAlpha);
}
ViewCompat.postInvalidateOnAnimation(this);
}
}
public void setContentScrimColor(int i) {
setContentScrim(new ColorDrawable(i));
}
public void setContentScrimResource(int i) {
setContentScrim(ContextCompat.getDrawable(getContext(), i));
}
public void setStatusBarScrim(Drawable drawable) {
Drawable drawable2 = this.statusBarScrim;
if (drawable2 != drawable) {
if (drawable2 != null) {
drawable2.setCallback(null);
}
Drawable mutate = drawable != null ? drawable.mutate() : null;
this.statusBarScrim = mutate;
if (mutate != null) {
if (mutate.isStateful()) {
this.statusBarScrim.setState(getDrawableState());
}
DrawableCompat.setLayoutDirection(this.statusBarScrim, ViewCompat.getLayoutDirection(this));
this.statusBarScrim.setVisible(getVisibility() == 0, false);
this.statusBarScrim.setCallback(this);
this.statusBarScrim.setAlpha(this.scrimAlpha);
}
ViewCompat.postInvalidateOnAnimation(this);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
int[] drawableState = getDrawableState();
Drawable drawable = this.statusBarScrim;
boolean state = (drawable == null || !drawable.isStateful()) ? false : drawable.setState(drawableState);
Drawable drawable2 = this.contentScrim;
if (drawable2 != null && drawable2.isStateful()) {
state |= drawable2.setState(drawableState);
}
CollapsingTextHelper collapsingTextHelper = this.collapsingTextHelper;
if (collapsingTextHelper != null) {
state |= collapsingTextHelper.setState(drawableState);
}
if (state) {
invalidate();
}
}
@Override // android.view.View
protected boolean verifyDrawable(Drawable drawable) {
return super.verifyDrawable(drawable) || drawable == this.contentScrim || drawable == this.statusBarScrim;
}
@Override // android.view.View
public void setVisibility(int i) {
super.setVisibility(i);
boolean z = i == 0;
Drawable drawable = this.statusBarScrim;
if (drawable != null && drawable.isVisible() != z) {
this.statusBarScrim.setVisible(z, false);
}
Drawable drawable2 = this.contentScrim;
if (drawable2 == null || drawable2.isVisible() == z) {
return;
}
this.contentScrim.setVisible(z, false);
}
public void setStatusBarScrimColor(int i) {
setStatusBarScrim(new ColorDrawable(i));
}
public void setStatusBarScrimResource(int i) {
setStatusBarScrim(ContextCompat.getDrawable(getContext(), i));
}
public void setCollapsedTitleTextAppearance(int i) {
this.collapsingTextHelper.setCollapsedTextAppearance(i);
}
public void setCollapsedTitleTextColor(int i) {
setCollapsedTitleTextColor(ColorStateList.valueOf(i));
}
public void setCollapsedTitleTextColor(ColorStateList colorStateList) {
this.collapsingTextHelper.setCollapsedTextColor(colorStateList);
}
public void setCollapsedTitleGravity(int i) {
this.collapsingTextHelper.setCollapsedTextGravity(i);
}
public int getCollapsedTitleGravity() {
return this.collapsingTextHelper.getCollapsedTextGravity();
}
public void setExpandedTitleTextAppearance(int i) {
this.collapsingTextHelper.setExpandedTextAppearance(i);
}
public void setExpandedTitleColor(int i) {
setExpandedTitleTextColor(ColorStateList.valueOf(i));
}
public void setExpandedTitleTextColor(ColorStateList colorStateList) {
this.collapsingTextHelper.setExpandedTextColor(colorStateList);
}
public void setExpandedTitleGravity(int i) {
this.collapsingTextHelper.setExpandedTextGravity(i);
}
public int getExpandedTitleGravity() {
return this.collapsingTextHelper.getExpandedTextGravity();
}
public void setExpandedTitleTextSize(float f) {
this.collapsingTextHelper.setExpandedTextSize(f);
}
public float getExpandedTitleTextSize() {
return this.collapsingTextHelper.getExpandedTextSize();
}
public void setCollapsedTitleTextSize(float f) {
this.collapsingTextHelper.setCollapsedTextSize(f);
}
public float getCollapsedTitleTextSize() {
return this.collapsingTextHelper.getCollapsedTextSize();
}
public void setCollapsedTitleTypeface(Typeface typeface) {
this.collapsingTextHelper.setCollapsedTypeface(typeface);
}
public Typeface getCollapsedTitleTypeface() {
return this.collapsingTextHelper.getCollapsedTypeface();
}
public void setExpandedTitleTypeface(Typeface typeface) {
this.collapsingTextHelper.setExpandedTypeface(typeface);
}
public Typeface getExpandedTitleTypeface() {
return this.collapsingTextHelper.getExpandedTypeface();
}
public void setExpandedTitleMargin(int i, int i2, int i3, int i4) {
this.expandedMarginStart = i;
this.expandedMarginTop = i2;
this.expandedMarginEnd = i3;
this.expandedMarginBottom = i4;
requestLayout();
}
public void setExpandedTitleMarginStart(int i) {
this.expandedMarginStart = i;
requestLayout();
}
public void setExpandedTitleMarginTop(int i) {
this.expandedMarginTop = i;
requestLayout();
}
public void setExpandedTitleMarginEnd(int i) {
this.expandedMarginEnd = i;
requestLayout();
}
public void setExpandedTitleMarginBottom(int i) {
this.expandedMarginBottom = i;
requestLayout();
}
public void setMaxLines(int i) {
this.collapsingTextHelper.setMaxLines(i);
}
public int getMaxLines() {
return this.collapsingTextHelper.getMaxLines();
}
public int getLineCount() {
return this.collapsingTextHelper.getLineCount();
}
public void setLineSpacingAdd(float f) {
this.collapsingTextHelper.setLineSpacingAdd(f);
}
public float getLineSpacingAdd() {
return this.collapsingTextHelper.getLineSpacingAdd();
}
public void setLineSpacingMultiplier(float f) {
this.collapsingTextHelper.setLineSpacingMultiplier(f);
}
public float getLineSpacingMultiplier() {
return this.collapsingTextHelper.getLineSpacingMultiplier();
}
public void setHyphenationFrequency(int i) {
this.collapsingTextHelper.setHyphenationFrequency(i);
}
public int getHyphenationFrequency() {
return this.collapsingTextHelper.getHyphenationFrequency();
}
public void setStaticLayoutBuilderConfigurer(StaticLayoutBuilderConfigurer staticLayoutBuilderConfigurer) {
this.collapsingTextHelper.setStaticLayoutBuilderConfigurer(staticLayoutBuilderConfigurer);
}
public void setRtlTextDirectionHeuristicsEnabled(boolean z) {
this.collapsingTextHelper.setRtlTextDirectionHeuristicsEnabled(z);
}
public boolean isRtlTextDirectionHeuristicsEnabled() {
return this.collapsingTextHelper.isRtlTextDirectionHeuristicsEnabled();
}
public void setScrimVisibleHeightTrigger(int i) {
if (this.scrimVisibleHeightTrigger != i) {
this.scrimVisibleHeightTrigger = i;
updateScrimVisibility();
}
}
public int getScrimVisibleHeightTrigger() {
int i = this.scrimVisibleHeightTrigger;
if (i >= 0) {
return i + this.topInsetApplied + this.extraMultilineHeight;
}
WindowInsetsCompat windowInsetsCompat = this.lastInsets;
int systemWindowInsetTop = windowInsetsCompat != null ? windowInsetsCompat.getSystemWindowInsetTop() : 0;
int minimumHeight = ViewCompat.getMinimumHeight(this);
if (minimumHeight > 0) {
return Math.min((minimumHeight * 2) + systemWindowInsetTop, getHeight());
}
return getHeight() / 3;
}
public void setTitlePositionInterpolator(TimeInterpolator timeInterpolator) {
this.collapsingTextHelper.setPositionInterpolator(timeInterpolator);
}
public TimeInterpolator getTitlePositionInterpolator() {
return this.collapsingTextHelper.getPositionInterpolator();
}
@Override // android.widget.FrameLayout, android.view.ViewGroup
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
return layoutParams instanceof LayoutParams;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // android.widget.FrameLayout, android.view.ViewGroup
public LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(-1, -1);
}
@Override // android.widget.FrameLayout, android.view.ViewGroup
public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new LayoutParams(getContext(), attributeSet);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // android.widget.FrameLayout, android.view.ViewGroup
public FrameLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
return new LayoutParams(layoutParams);
}
/* loaded from: classes2.dex */
public static class LayoutParams extends FrameLayout.LayoutParams {
public static final int COLLAPSE_MODE_OFF = 0;
public static final int COLLAPSE_MODE_PARALLAX = 2;
public static final int COLLAPSE_MODE_PIN = 1;
private static final float DEFAULT_PARALLAX_MULTIPLIER = 0.5f;
int collapseMode;
float parallaxMult;
public int getCollapseMode() {
return this.collapseMode;
}
public float getParallaxMultiplier() {
return this.parallaxMult;
}
public void setCollapseMode(int i) {
this.collapseMode = i;
}
public void setParallaxMultiplier(float f) {
this.parallaxMult = f;
}
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.CollapsingToolbarLayout_Layout);
this.collapseMode = obtainStyledAttributes.getInt(R.styleable.CollapsingToolbarLayout_Layout_layout_collapseMode, 0);
setParallaxMultiplier(obtainStyledAttributes.getFloat(R.styleable.CollapsingToolbarLayout_Layout_layout_collapseParallaxMultiplier, 0.5f));
obtainStyledAttributes.recycle();
}
public LayoutParams(int i, int i2) {
super(i, i2);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
}
public LayoutParams(int i, int i2, int i3) {
super(i, i2, i3);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
}
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
}
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
super(marginLayoutParams);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
}
public LayoutParams(FrameLayout.LayoutParams layoutParams) {
super(layoutParams);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
}
public LayoutParams(LayoutParams layoutParams) {
super((FrameLayout.LayoutParams) layoutParams);
this.collapseMode = 0;
this.parallaxMult = 0.5f;
this.collapseMode = layoutParams.collapseMode;
this.parallaxMult = layoutParams.parallaxMult;
}
}
final void updateScrimVisibility() {
if (this.contentScrim == null && this.statusBarScrim == null) {
return;
}
setScrimsShown(getHeight() + this.currentOffset < getScrimVisibleHeightTrigger());
}
final int getMaxOffsetForPinChild(View view) {
return ((getHeight() - getViewOffsetHelper(view).getLayoutTop()) - view.getHeight()) - ((LayoutParams) view.getLayoutParams()).bottomMargin;
}
private void updateContentDescriptionFromTitle() {
setContentDescription(getTitle());
}
/* loaded from: classes2.dex */
private class OffsetUpdateListener implements AppBarLayout.OnOffsetChangedListener {
OffsetUpdateListener() {
}
@Override // com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener, com.google.android.material.appbar.AppBarLayout.BaseOnOffsetChangedListener
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
CollapsingToolbarLayout.this.currentOffset = i;
int systemWindowInsetTop = CollapsingToolbarLayout.this.lastInsets != null ? CollapsingToolbarLayout.this.lastInsets.getSystemWindowInsetTop() : 0;
int childCount = CollapsingToolbarLayout.this.getChildCount();
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = CollapsingToolbarLayout.this.getChildAt(i2);
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
ViewOffsetHelper viewOffsetHelper = CollapsingToolbarLayout.getViewOffsetHelper(childAt);
int i3 = layoutParams.collapseMode;
if (i3 == 1) {
viewOffsetHelper.setTopAndBottomOffset(MathUtils.clamp(-i, 0, CollapsingToolbarLayout.this.getMaxOffsetForPinChild(childAt)));
} else if (i3 == 2) {
viewOffsetHelper.setTopAndBottomOffset(Math.round((-i) * layoutParams.parallaxMult));
}
}
CollapsingToolbarLayout.this.updateScrimVisibility();
if (CollapsingToolbarLayout.this.statusBarScrim != null && systemWindowInsetTop > 0) {
ViewCompat.postInvalidateOnAnimation(CollapsingToolbarLayout.this);
}
int height = (CollapsingToolbarLayout.this.getHeight() - ViewCompat.getMinimumHeight(CollapsingToolbarLayout.this)) - systemWindowInsetTop;
float f = height;
CollapsingToolbarLayout.this.collapsingTextHelper.setFadeModeStartFraction(Math.min(1.0f, (r0 - CollapsingToolbarLayout.this.getScrimVisibleHeightTrigger()) / f));
CollapsingToolbarLayout.this.collapsingTextHelper.setCurrentOffsetY(CollapsingToolbarLayout.this.currentOffset + height);
CollapsingToolbarLayout.this.collapsingTextHelper.setExpansionFraction(Math.abs(i) / f);
}
}
}