Initial commit
This commit is contained in:
1094
sources/com/google/android/material/appbar/AppBarLayout.java
Normal file
1094
sources/com/google/android/material/appbar/AppBarLayout.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,745 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
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.OnApplyWindowInsetsListener;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import com.google.android.material.R$id;
|
||||
import com.google.android.material.R$style;
|
||||
import com.google.android.material.R$styleable;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.internal.CollapsingTextHelper;
|
||||
import com.google.android.material.internal.DescendantOffsetUtils;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CollapsingToolbarLayout extends FrameLayout {
|
||||
private boolean a;
|
||||
private int b;
|
||||
private Toolbar c;
|
||||
private View d;
|
||||
private View e;
|
||||
private int f;
|
||||
private int g;
|
||||
private int h;
|
||||
private int i;
|
||||
private final Rect j;
|
||||
final CollapsingTextHelper k;
|
||||
private boolean l;
|
||||
private boolean m;
|
||||
private Drawable n;
|
||||
Drawable o;
|
||||
private int p;
|
||||
private boolean q;
|
||||
private ValueAnimator r;
|
||||
private long s;
|
||||
private int t;
|
||||
private AppBarLayout.OnOffsetChangedListener u;
|
||||
int v;
|
||||
WindowInsetsCompat x;
|
||||
|
||||
private class OffsetUpdateListener implements AppBarLayout.OnOffsetChangedListener {
|
||||
OffsetUpdateListener() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.appbar.AppBarLayout.BaseOnOffsetChangedListener
|
||||
public void a(AppBarLayout appBarLayout, int i) {
|
||||
CollapsingToolbarLayout collapsingToolbarLayout = CollapsingToolbarLayout.this;
|
||||
collapsingToolbarLayout.v = i;
|
||||
WindowInsetsCompat windowInsetsCompat = collapsingToolbarLayout.x;
|
||||
int e = windowInsetsCompat != null ? windowInsetsCompat.e() : 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 d = CollapsingToolbarLayout.d(childAt);
|
||||
int i3 = layoutParams.a;
|
||||
if (i3 == 1) {
|
||||
d.b(MathUtils.a(-i, 0, CollapsingToolbarLayout.this.a(childAt)));
|
||||
} else if (i3 == 2) {
|
||||
d.b(Math.round((-i) * layoutParams.b));
|
||||
}
|
||||
}
|
||||
CollapsingToolbarLayout.this.a();
|
||||
CollapsingToolbarLayout collapsingToolbarLayout2 = CollapsingToolbarLayout.this;
|
||||
if (collapsingToolbarLayout2.o != null && e > 0) {
|
||||
ViewCompat.A(collapsingToolbarLayout2);
|
||||
}
|
||||
CollapsingToolbarLayout.this.k.b(Math.abs(i) / ((CollapsingToolbarLayout.this.getHeight() - ViewCompat.l(CollapsingToolbarLayout.this)) - e));
|
||||
}
|
||||
}
|
||||
|
||||
public CollapsingToolbarLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void b() {
|
||||
if (this.a) {
|
||||
Toolbar toolbar = null;
|
||||
this.c = null;
|
||||
this.d = null;
|
||||
int i = this.b;
|
||||
if (i != -1) {
|
||||
this.c = (Toolbar) findViewById(i);
|
||||
Toolbar toolbar2 = this.c;
|
||||
if (toolbar2 != null) {
|
||||
this.d = b(toolbar2);
|
||||
}
|
||||
}
|
||||
if (this.c == null) {
|
||||
int childCount = getChildCount();
|
||||
int i2 = 0;
|
||||
while (true) {
|
||||
if (i2 >= childCount) {
|
||||
break;
|
||||
}
|
||||
View childAt = getChildAt(i2);
|
||||
if (childAt instanceof Toolbar) {
|
||||
toolbar = (Toolbar) childAt;
|
||||
break;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
this.c = toolbar;
|
||||
}
|
||||
d();
|
||||
this.a = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static int c(View view) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
|
||||
return view.getHeight();
|
||||
}
|
||||
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
|
||||
return view.getHeight() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
|
||||
}
|
||||
|
||||
private void d() {
|
||||
View view;
|
||||
if (!this.l && (view = this.e) != null) {
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent instanceof ViewGroup) {
|
||||
((ViewGroup) parent).removeView(this.e);
|
||||
}
|
||||
}
|
||||
if (!this.l || this.c == null) {
|
||||
return;
|
||||
}
|
||||
if (this.e == null) {
|
||||
this.e = new View(getContext());
|
||||
}
|
||||
if (this.e.getParent() == null) {
|
||||
this.c.addView(this.e, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean e(View view) {
|
||||
View view2 = this.d;
|
||||
if (view2 == null || view2 == this) {
|
||||
if (view == this.c) {
|
||||
return true;
|
||||
}
|
||||
} else if (view == view2) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
WindowInsetsCompat a(WindowInsetsCompat windowInsetsCompat) {
|
||||
WindowInsetsCompat windowInsetsCompat2 = ViewCompat.h(this) ? windowInsetsCompat : null;
|
||||
if (!ObjectsCompat.a(this.x, windowInsetsCompat2)) {
|
||||
this.x = windowInsetsCompat2;
|
||||
requestLayout();
|
||||
}
|
||||
return windowInsetsCompat.a();
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.ViewGroup
|
||||
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||||
return layoutParams instanceof LayoutParams;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void draw(Canvas canvas) {
|
||||
Drawable drawable;
|
||||
super.draw(canvas);
|
||||
b();
|
||||
if (this.c == null && (drawable = this.n) != null && this.p > 0) {
|
||||
drawable.mutate().setAlpha(this.p);
|
||||
this.n.draw(canvas);
|
||||
}
|
||||
if (this.l && this.m) {
|
||||
this.k.a(canvas);
|
||||
}
|
||||
if (this.o == null || this.p <= 0) {
|
||||
return;
|
||||
}
|
||||
WindowInsetsCompat windowInsetsCompat = this.x;
|
||||
int e = windowInsetsCompat != null ? windowInsetsCompat.e() : 0;
|
||||
if (e > 0) {
|
||||
this.o.setBounds(0, -this.v, getWidth(), e - this.v);
|
||||
this.o.mutate().setAlpha(this.p);
|
||||
this.o.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
protected boolean drawChild(Canvas canvas, View view, long j) {
|
||||
boolean z;
|
||||
if (this.n == null || this.p <= 0 || !e(view)) {
|
||||
z = false;
|
||||
} else {
|
||||
this.n.mutate().setAlpha(this.p);
|
||||
this.n.draw(canvas);
|
||||
z = true;
|
||||
}
|
||||
return super.drawChild(canvas, view, j) || z;
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void drawableStateChanged() {
|
||||
super.drawableStateChanged();
|
||||
int[] drawableState = getDrawableState();
|
||||
Drawable drawable = this.o;
|
||||
boolean z = false;
|
||||
if (drawable != null && drawable.isStateful()) {
|
||||
z = false | drawable.setState(drawableState);
|
||||
}
|
||||
Drawable drawable2 = this.n;
|
||||
if (drawable2 != null && drawable2.isStateful()) {
|
||||
z |= drawable2.setState(drawableState);
|
||||
}
|
||||
CollapsingTextHelper collapsingTextHelper = this.k;
|
||||
if (collapsingTextHelper != null) {
|
||||
z |= collapsingTextHelper.a(drawableState);
|
||||
}
|
||||
if (z) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int getCollapsedTitleGravity() {
|
||||
return this.k.c();
|
||||
}
|
||||
|
||||
public Typeface getCollapsedTitleTypeface() {
|
||||
return this.k.e();
|
||||
}
|
||||
|
||||
public Drawable getContentScrim() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
public int getExpandedTitleGravity() {
|
||||
return this.k.g();
|
||||
}
|
||||
|
||||
public int getExpandedTitleMarginBottom() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public int getExpandedTitleMarginEnd() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public int getExpandedTitleMarginStart() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public int getExpandedTitleMarginTop() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public Typeface getExpandedTitleTypeface() {
|
||||
return this.k.h();
|
||||
}
|
||||
|
||||
int getScrimAlpha() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
public long getScrimAnimationDuration() {
|
||||
return this.s;
|
||||
}
|
||||
|
||||
public int getScrimVisibleHeightTrigger() {
|
||||
int i = this.t;
|
||||
if (i >= 0) {
|
||||
return i;
|
||||
}
|
||||
WindowInsetsCompat windowInsetsCompat = this.x;
|
||||
int e = windowInsetsCompat != null ? windowInsetsCompat.e() : 0;
|
||||
int l = ViewCompat.l(this);
|
||||
return l > 0 ? Math.min((l * 2) + e, getHeight()) : getHeight() / 3;
|
||||
}
|
||||
|
||||
public Drawable getStatusBarScrim() {
|
||||
return this.o;
|
||||
}
|
||||
|
||||
public CharSequence getTitle() {
|
||||
if (this.l) {
|
||||
return this.k.j();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Object parent = getParent();
|
||||
if (parent instanceof AppBarLayout) {
|
||||
ViewCompat.a(this, ViewCompat.h((View) parent));
|
||||
if (this.u == null) {
|
||||
this.u = new OffsetUpdateListener();
|
||||
}
|
||||
((AppBarLayout) parent).a(this.u);
|
||||
ViewCompat.B(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
ViewParent parent = getParent();
|
||||
AppBarLayout.OnOffsetChangedListener onOffsetChangedListener = this.u;
|
||||
if (onOffsetChangedListener != null && (parent instanceof AppBarLayout)) {
|
||||
((AppBarLayout) parent).b(onOffsetChangedListener);
|
||||
}
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
|
||||
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||||
View view;
|
||||
super.onLayout(z, i, i2, i3, i4);
|
||||
WindowInsetsCompat windowInsetsCompat = this.x;
|
||||
if (windowInsetsCompat != null) {
|
||||
int e = windowInsetsCompat.e();
|
||||
int childCount = getChildCount();
|
||||
for (int i5 = 0; i5 < childCount; i5++) {
|
||||
View childAt = getChildAt(i5);
|
||||
if (!ViewCompat.h(childAt) && childAt.getTop() < e) {
|
||||
ViewCompat.d(childAt, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.l && (view = this.e) != null) {
|
||||
this.m = ViewCompat.w(view) && this.e.getVisibility() == 0;
|
||||
if (this.m) {
|
||||
boolean z2 = ViewCompat.k(this) == 1;
|
||||
View view2 = this.d;
|
||||
if (view2 == null) {
|
||||
view2 = this.c;
|
||||
}
|
||||
int a = a(view2);
|
||||
DescendantOffsetUtils.a(this, this.e, this.j);
|
||||
this.k.a(this.j.left + (z2 ? this.c.getTitleMarginEnd() : this.c.getTitleMarginStart()), this.j.top + a + this.c.getTitleMarginTop(), this.j.right + (z2 ? this.c.getTitleMarginStart() : this.c.getTitleMarginEnd()), (this.j.bottom + a) - this.c.getTitleMarginBottom());
|
||||
this.k.b(z2 ? this.h : this.f, this.j.top + this.g, (i3 - i) - (z2 ? this.f : this.h), (i4 - i2) - this.i);
|
||||
this.k.m();
|
||||
}
|
||||
}
|
||||
int childCount2 = getChildCount();
|
||||
for (int i6 = 0; i6 < childCount2; i6++) {
|
||||
d(getChildAt(i6)).c();
|
||||
}
|
||||
if (this.c != null) {
|
||||
if (this.l && TextUtils.isEmpty(this.k.j())) {
|
||||
setTitle(this.c.getTitle());
|
||||
}
|
||||
View view3 = this.d;
|
||||
if (view3 == null || view3 == this) {
|
||||
setMinimumHeight(c(this.c));
|
||||
} else {
|
||||
setMinimumHeight(c(view3));
|
||||
}
|
||||
}
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
b();
|
||||
super.onMeasure(i, i2);
|
||||
int mode = View.MeasureSpec.getMode(i2);
|
||||
WindowInsetsCompat windowInsetsCompat = this.x;
|
||||
int e = windowInsetsCompat != null ? windowInsetsCompat.e() : 0;
|
||||
if (mode != 0 || e <= 0) {
|
||||
return;
|
||||
}
|
||||
super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(getMeasuredHeight() + e, 1073741824));
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
||||
super.onSizeChanged(i, i2, i3, i4);
|
||||
Drawable drawable = this.n;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(0, 0, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCollapsedTitleGravity(int i) {
|
||||
this.k.b(i);
|
||||
}
|
||||
|
||||
public void setCollapsedTitleTextAppearance(int i) {
|
||||
this.k.a(i);
|
||||
}
|
||||
|
||||
public void setCollapsedTitleTextColor(int i) {
|
||||
setCollapsedTitleTextColor(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
public void setCollapsedTitleTypeface(Typeface typeface) {
|
||||
this.k.a(typeface);
|
||||
}
|
||||
|
||||
public void setContentScrim(Drawable drawable) {
|
||||
Drawable drawable2 = this.n;
|
||||
if (drawable2 != drawable) {
|
||||
if (drawable2 != null) {
|
||||
drawable2.setCallback(null);
|
||||
}
|
||||
this.n = drawable != null ? drawable.mutate() : null;
|
||||
Drawable drawable3 = this.n;
|
||||
if (drawable3 != null) {
|
||||
drawable3.setBounds(0, 0, getWidth(), getHeight());
|
||||
this.n.setCallback(this);
|
||||
this.n.setAlpha(this.p);
|
||||
}
|
||||
ViewCompat.A(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setContentScrimColor(int i) {
|
||||
setContentScrim(new ColorDrawable(i));
|
||||
}
|
||||
|
||||
public void setContentScrimResource(int i) {
|
||||
setContentScrim(ContextCompat.c(getContext(), i));
|
||||
}
|
||||
|
||||
public void setExpandedTitleColor(int i) {
|
||||
setExpandedTitleTextColor(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
public void setExpandedTitleGravity(int i) {
|
||||
this.k.d(i);
|
||||
}
|
||||
|
||||
public void setExpandedTitleMarginBottom(int i) {
|
||||
this.i = i;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setExpandedTitleMarginEnd(int i) {
|
||||
this.h = i;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setExpandedTitleMarginStart(int i) {
|
||||
this.f = i;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setExpandedTitleMarginTop(int i) {
|
||||
this.g = i;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setExpandedTitleTextAppearance(int i) {
|
||||
this.k.c(i);
|
||||
}
|
||||
|
||||
public void setExpandedTitleTextColor(ColorStateList colorStateList) {
|
||||
this.k.b(colorStateList);
|
||||
}
|
||||
|
||||
public void setExpandedTitleTypeface(Typeface typeface) {
|
||||
this.k.b(typeface);
|
||||
}
|
||||
|
||||
void setScrimAlpha(int i) {
|
||||
Toolbar toolbar;
|
||||
if (i != this.p) {
|
||||
if (this.n != null && (toolbar = this.c) != null) {
|
||||
ViewCompat.A(toolbar);
|
||||
}
|
||||
this.p = i;
|
||||
ViewCompat.A(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setScrimAnimationDuration(long j) {
|
||||
this.s = j;
|
||||
}
|
||||
|
||||
public void setScrimVisibleHeightTrigger(int i) {
|
||||
if (this.t != i) {
|
||||
this.t = i;
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
public void setScrimsShown(boolean z) {
|
||||
a(z, ViewCompat.x(this) && !isInEditMode());
|
||||
}
|
||||
|
||||
public void setStatusBarScrim(Drawable drawable) {
|
||||
Drawable drawable2 = this.o;
|
||||
if (drawable2 != drawable) {
|
||||
if (drawable2 != null) {
|
||||
drawable2.setCallback(null);
|
||||
}
|
||||
this.o = drawable != null ? drawable.mutate() : null;
|
||||
Drawable drawable3 = this.o;
|
||||
if (drawable3 != null) {
|
||||
if (drawable3.isStateful()) {
|
||||
this.o.setState(getDrawableState());
|
||||
}
|
||||
DrawableCompat.a(this.o, ViewCompat.k(this));
|
||||
this.o.setVisible(getVisibility() == 0, false);
|
||||
this.o.setCallback(this);
|
||||
this.o.setAlpha(this.p);
|
||||
}
|
||||
ViewCompat.A(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatusBarScrimColor(int i) {
|
||||
setStatusBarScrim(new ColorDrawable(i));
|
||||
}
|
||||
|
||||
public void setStatusBarScrimResource(int i) {
|
||||
setStatusBarScrim(ContextCompat.c(getContext(), i));
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence charSequence) {
|
||||
this.k.a(charSequence);
|
||||
c();
|
||||
}
|
||||
|
||||
public void setTitleEnabled(boolean z) {
|
||||
if (z != this.l) {
|
||||
this.l = z;
|
||||
c();
|
||||
d();
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setVisibility(int i) {
|
||||
super.setVisibility(i);
|
||||
boolean z = i == 0;
|
||||
Drawable drawable = this.o;
|
||||
if (drawable != null && drawable.isVisible() != z) {
|
||||
this.o.setVisible(z, false);
|
||||
}
|
||||
Drawable drawable2 = this.n;
|
||||
if (drawable2 == null || drawable2.isVisible() == z) {
|
||||
return;
|
||||
}
|
||||
this.n.setVisible(z, false);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected boolean verifyDrawable(Drawable drawable) {
|
||||
return super.verifyDrawable(drawable) || drawable == this.n || drawable == this.o;
|
||||
}
|
||||
|
||||
public CollapsingToolbarLayout(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public void setCollapsedTitleTextColor(ColorStateList colorStateList) {
|
||||
this.k.a(colorStateList);
|
||||
}
|
||||
|
||||
public CollapsingToolbarLayout(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.a = true;
|
||||
this.j = new Rect();
|
||||
this.t = -1;
|
||||
this.k = new CollapsingTextHelper(this);
|
||||
this.k.b(AnimationUtils.e);
|
||||
TypedArray c = ThemeEnforcement.c(context, attributeSet, R$styleable.CollapsingToolbarLayout, i, R$style.Widget_Design_CollapsingToolbar, new int[0]);
|
||||
this.k.d(c.getInt(R$styleable.CollapsingToolbarLayout_expandedTitleGravity, 8388691));
|
||||
this.k.b(c.getInt(R$styleable.CollapsingToolbarLayout_collapsedTitleGravity, 8388627));
|
||||
int dimensionPixelSize = c.getDimensionPixelSize(R$styleable.CollapsingToolbarLayout_expandedTitleMargin, 0);
|
||||
this.i = dimensionPixelSize;
|
||||
this.h = dimensionPixelSize;
|
||||
this.g = dimensionPixelSize;
|
||||
this.f = dimensionPixelSize;
|
||||
if (c.hasValue(R$styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) {
|
||||
this.f = c.getDimensionPixelSize(R$styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0);
|
||||
}
|
||||
if (c.hasValue(R$styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) {
|
||||
this.h = c.getDimensionPixelSize(R$styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0);
|
||||
}
|
||||
if (c.hasValue(R$styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) {
|
||||
this.g = c.getDimensionPixelSize(R$styleable.CollapsingToolbarLayout_expandedTitleMarginTop, 0);
|
||||
}
|
||||
if (c.hasValue(R$styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) {
|
||||
this.i = c.getDimensionPixelSize(R$styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0);
|
||||
}
|
||||
this.l = c.getBoolean(R$styleable.CollapsingToolbarLayout_titleEnabled, true);
|
||||
setTitle(c.getText(R$styleable.CollapsingToolbarLayout_title));
|
||||
this.k.c(R$style.TextAppearance_Design_CollapsingToolbar_Expanded);
|
||||
this.k.a(androidx.appcompat.R$style.TextAppearance_AppCompat_Widget_ActionBar_Title);
|
||||
if (c.hasValue(R$styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
|
||||
this.k.c(c.getResourceId(R$styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0));
|
||||
}
|
||||
if (c.hasValue(R$styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) {
|
||||
this.k.a(c.getResourceId(R$styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
|
||||
}
|
||||
this.t = c.getDimensionPixelSize(R$styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1);
|
||||
this.s = c.getInt(R$styleable.CollapsingToolbarLayout_scrimAnimationDuration, 600);
|
||||
setContentScrim(c.getDrawable(R$styleable.CollapsingToolbarLayout_contentScrim));
|
||||
setStatusBarScrim(c.getDrawable(R$styleable.CollapsingToolbarLayout_statusBarScrim));
|
||||
this.b = c.getResourceId(R$styleable.CollapsingToolbarLayout_toolbarId, -1);
|
||||
c.recycle();
|
||||
setWillNotDraw(false);
|
||||
ViewCompat.a(this, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.appbar.CollapsingToolbarLayout.1
|
||||
@Override // androidx.core.view.OnApplyWindowInsetsListener
|
||||
public WindowInsetsCompat a(View view, WindowInsetsCompat windowInsetsCompat) {
|
||||
return CollapsingToolbarLayout.this.a(windowInsetsCompat);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
private void c() {
|
||||
setContentDescription(getTitle());
|
||||
}
|
||||
|
||||
public void a(boolean z, boolean z2) {
|
||||
if (this.q != z) {
|
||||
if (z2) {
|
||||
a(z ? 255 : 0);
|
||||
} else {
|
||||
setScrimAlpha(z ? 255 : 0);
|
||||
}
|
||||
this.q = z;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LayoutParams extends FrameLayout.LayoutParams {
|
||||
int a;
|
||||
float b;
|
||||
|
||||
public LayoutParams(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.a = 0;
|
||||
this.b = 0.5f;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.CollapsingToolbarLayout_Layout);
|
||||
this.a = obtainStyledAttributes.getInt(R$styleable.CollapsingToolbarLayout_Layout_layout_collapseMode, 0);
|
||||
a(obtainStyledAttributes.getFloat(R$styleable.CollapsingToolbarLayout_Layout_layout_collapseParallaxMultiplier, 0.5f));
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
public void a(float f) {
|
||||
this.b = f;
|
||||
}
|
||||
|
||||
public LayoutParams(int i, int i2) {
|
||||
super(i, i2);
|
||||
this.a = 0;
|
||||
this.b = 0.5f;
|
||||
}
|
||||
|
||||
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||||
super(layoutParams);
|
||||
this.a = 0;
|
||||
this.b = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(int i) {
|
||||
b();
|
||||
ValueAnimator valueAnimator = this.r;
|
||||
if (valueAnimator == null) {
|
||||
this.r = new ValueAnimator();
|
||||
this.r.setDuration(this.s);
|
||||
this.r.setInterpolator(i > this.p ? AnimationUtils.c : AnimationUtils.d);
|
||||
this.r.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.appbar.CollapsingToolbarLayout.2
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator2) {
|
||||
CollapsingToolbarLayout.this.setScrimAlpha(((Integer) valueAnimator2.getAnimatedValue()).intValue());
|
||||
}
|
||||
});
|
||||
} else if (valueAnimator.isRunning()) {
|
||||
this.r.cancel();
|
||||
}
|
||||
this.r.setIntValues(this.p, i);
|
||||
this.r.start();
|
||||
}
|
||||
|
||||
static ViewOffsetHelper d(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;
|
||||
}
|
||||
|
||||
private View b(View view) {
|
||||
for (ViewParent parent = view.getParent(); parent != this && parent != null; parent = parent.getParent()) {
|
||||
if (parent instanceof View) {
|
||||
view = parent;
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
final void a() {
|
||||
if (this.n == null && this.o == null) {
|
||||
return;
|
||||
}
|
||||
setScrimsShown(getHeight() + this.v < getScrimVisibleHeightTrigger());
|
||||
}
|
||||
|
||||
final int a(View view) {
|
||||
return ((getHeight() - d(view).a()) - view.getHeight()) - ((FrameLayout.LayoutParams) ((LayoutParams) view.getLayoutParams())).bottomMargin;
|
||||
}
|
||||
}
|
304
sources/com/google/android/material/appbar/HeaderBehavior.java
Normal file
304
sources/com/google/android/material/appbar/HeaderBehavior.java
Normal file
@@ -0,0 +1,304 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.widget.OverScroller;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class HeaderBehavior<V extends View> extends ViewOffsetBehavior<V> {
|
||||
private Runnable d;
|
||||
OverScroller e;
|
||||
private boolean f;
|
||||
private int g;
|
||||
private int h;
|
||||
private int i;
|
||||
private VelocityTracker j;
|
||||
|
||||
private class FlingRunnable implements Runnable {
|
||||
private final CoordinatorLayout a;
|
||||
private final V b;
|
||||
|
||||
FlingRunnable(CoordinatorLayout coordinatorLayout, V v) {
|
||||
this.a = coordinatorLayout;
|
||||
this.b = v;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
OverScroller overScroller;
|
||||
if (this.b == null || (overScroller = HeaderBehavior.this.e) == null) {
|
||||
return;
|
||||
}
|
||||
if (!overScroller.computeScrollOffset()) {
|
||||
HeaderBehavior.this.e(this.a, this.b);
|
||||
return;
|
||||
}
|
||||
HeaderBehavior headerBehavior = HeaderBehavior.this;
|
||||
headerBehavior.c(this.a, (CoordinatorLayout) this.b, headerBehavior.e.getCurrY());
|
||||
ViewCompat.a(this.b, this);
|
||||
}
|
||||
}
|
||||
|
||||
public HeaderBehavior() {
|
||||
this.g = -1;
|
||||
this.i = -1;
|
||||
}
|
||||
|
||||
private void d() {
|
||||
if (this.j == null) {
|
||||
this.j = VelocityTracker.obtain();
|
||||
}
|
||||
}
|
||||
|
||||
abstract boolean a(V v);
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:16:0x002c, code lost:
|
||||
|
||||
if (r0 != 3) goto L35;
|
||||
*/
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public boolean a(androidx.coordinatorlayout.widget.CoordinatorLayout r5, V r6, android.view.MotionEvent r7) {
|
||||
/*
|
||||
r4 = this;
|
||||
int r0 = r4.i
|
||||
if (r0 >= 0) goto L12
|
||||
android.content.Context r0 = r5.getContext()
|
||||
android.view.ViewConfiguration r0 = android.view.ViewConfiguration.get(r0)
|
||||
int r0 = r0.getScaledTouchSlop()
|
||||
r4.i = r0
|
||||
L12:
|
||||
int r0 = r7.getAction()
|
||||
r1 = 2
|
||||
r2 = 1
|
||||
if (r0 != r1) goto L1f
|
||||
boolean r0 = r4.f
|
||||
if (r0 == 0) goto L1f
|
||||
return r2
|
||||
L1f:
|
||||
int r0 = r7.getActionMasked()
|
||||
r3 = 0
|
||||
if (r0 == 0) goto L60
|
||||
r5 = -1
|
||||
if (r0 == r2) goto L51
|
||||
if (r0 == r1) goto L2f
|
||||
r6 = 3
|
||||
if (r0 == r6) goto L51
|
||||
goto L83
|
||||
L2f:
|
||||
int r6 = r4.g
|
||||
if (r6 != r5) goto L34
|
||||
goto L83
|
||||
L34:
|
||||
int r6 = r7.findPointerIndex(r6)
|
||||
if (r6 != r5) goto L3b
|
||||
goto L83
|
||||
L3b:
|
||||
float r5 = r7.getY(r6)
|
||||
int r5 = (int) r5
|
||||
int r6 = r4.h
|
||||
int r6 = r5 - r6
|
||||
int r6 = java.lang.Math.abs(r6)
|
||||
int r0 = r4.i
|
||||
if (r6 <= r0) goto L83
|
||||
r4.f = r2
|
||||
r4.h = r5
|
||||
goto L83
|
||||
L51:
|
||||
r4.f = r3
|
||||
r4.g = r5
|
||||
android.view.VelocityTracker r5 = r4.j
|
||||
if (r5 == 0) goto L83
|
||||
r5.recycle()
|
||||
r5 = 0
|
||||
r4.j = r5
|
||||
goto L83
|
||||
L60:
|
||||
r4.f = r3
|
||||
float r0 = r7.getX()
|
||||
int r0 = (int) r0
|
||||
float r1 = r7.getY()
|
||||
int r1 = (int) r1
|
||||
boolean r2 = r4.a(r6)
|
||||
if (r2 == 0) goto L83
|
||||
boolean r5 = r5.a(r6, r0, r1)
|
||||
if (r5 == 0) goto L83
|
||||
r4.h = r1
|
||||
int r5 = r7.getPointerId(r3)
|
||||
r4.g = r5
|
||||
r4.d()
|
||||
L83:
|
||||
android.view.VelocityTracker r5 = r4.j
|
||||
if (r5 == 0) goto L8a
|
||||
r5.addMovement(r7)
|
||||
L8a:
|
||||
boolean r5 = r4.f
|
||||
return r5
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.HeaderBehavior.a(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, android.view.MotionEvent):boolean");
|
||||
}
|
||||
|
||||
abstract int b(V v);
|
||||
|
||||
abstract int b(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3);
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:11:0x0021, code lost:
|
||||
|
||||
if (r0 != 3) goto L39;
|
||||
*/
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public boolean b(androidx.coordinatorlayout.widget.CoordinatorLayout r12, V r13, android.view.MotionEvent r14) {
|
||||
/*
|
||||
r11 = this;
|
||||
int r0 = r11.i
|
||||
if (r0 >= 0) goto L12
|
||||
android.content.Context r0 = r12.getContext()
|
||||
android.view.ViewConfiguration r0 = android.view.ViewConfiguration.get(r0)
|
||||
int r0 = r0.getScaledTouchSlop()
|
||||
r11.i = r0
|
||||
L12:
|
||||
int r0 = r14.getActionMasked()
|
||||
r1 = 1
|
||||
r2 = 0
|
||||
if (r0 == 0) goto L8d
|
||||
r3 = -1
|
||||
if (r0 == r1) goto L5c
|
||||
r4 = 2
|
||||
if (r0 == r4) goto L25
|
||||
r12 = 3
|
||||
if (r0 == r12) goto L7e
|
||||
goto Lae
|
||||
L25:
|
||||
int r0 = r11.g
|
||||
int r0 = r14.findPointerIndex(r0)
|
||||
if (r0 != r3) goto L2e
|
||||
return r2
|
||||
L2e:
|
||||
float r0 = r14.getY(r0)
|
||||
int r0 = (int) r0
|
||||
int r2 = r11.h
|
||||
int r2 = r2 - r0
|
||||
boolean r3 = r11.f
|
||||
if (r3 != 0) goto L49
|
||||
int r3 = java.lang.Math.abs(r2)
|
||||
int r4 = r11.i
|
||||
if (r3 <= r4) goto L49
|
||||
r11.f = r1
|
||||
if (r2 <= 0) goto L48
|
||||
int r2 = r2 - r4
|
||||
goto L49
|
||||
L48:
|
||||
int r2 = r2 + r4
|
||||
L49:
|
||||
r6 = r2
|
||||
boolean r2 = r11.f
|
||||
if (r2 == 0) goto Lae
|
||||
r11.h = r0
|
||||
int r7 = r11.b(r13)
|
||||
r8 = 0
|
||||
r3 = r11
|
||||
r4 = r12
|
||||
r5 = r13
|
||||
r3.a(r4, r5, r6, r7, r8)
|
||||
goto Lae
|
||||
L5c:
|
||||
android.view.VelocityTracker r0 = r11.j
|
||||
if (r0 == 0) goto L7e
|
||||
r0.addMovement(r14)
|
||||
android.view.VelocityTracker r0 = r11.j
|
||||
r4 = 1000(0x3e8, float:1.401E-42)
|
||||
r0.computeCurrentVelocity(r4)
|
||||
android.view.VelocityTracker r0 = r11.j
|
||||
int r4 = r11.g
|
||||
float r10 = r0.getYVelocity(r4)
|
||||
int r0 = r11.c(r13)
|
||||
int r8 = -r0
|
||||
r9 = 0
|
||||
r5 = r11
|
||||
r6 = r12
|
||||
r7 = r13
|
||||
r5.a(r6, r7, r8, r9, r10)
|
||||
L7e:
|
||||
r11.f = r2
|
||||
r11.g = r3
|
||||
android.view.VelocityTracker r12 = r11.j
|
||||
if (r12 == 0) goto Lae
|
||||
r12.recycle()
|
||||
r12 = 0
|
||||
r11.j = r12
|
||||
goto Lae
|
||||
L8d:
|
||||
float r0 = r14.getX()
|
||||
int r0 = (int) r0
|
||||
float r3 = r14.getY()
|
||||
int r3 = (int) r3
|
||||
boolean r12 = r12.a(r13, r0, r3)
|
||||
if (r12 == 0) goto Lb6
|
||||
boolean r12 = r11.a(r13)
|
||||
if (r12 == 0) goto Lb6
|
||||
r11.h = r3
|
||||
int r12 = r14.getPointerId(r2)
|
||||
r11.g = r12
|
||||
r11.d()
|
||||
Lae:
|
||||
android.view.VelocityTracker r12 = r11.j
|
||||
if (r12 == 0) goto Lb5
|
||||
r12.addMovement(r14)
|
||||
Lb5:
|
||||
return r1
|
||||
Lb6:
|
||||
return r2
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.HeaderBehavior.b(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, android.view.MotionEvent):boolean");
|
||||
}
|
||||
|
||||
abstract int c();
|
||||
|
||||
abstract int c(V v);
|
||||
|
||||
int c(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
return b(coordinatorLayout, (CoordinatorLayout) v, i, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
abstract void e(CoordinatorLayout coordinatorLayout, V v);
|
||||
|
||||
public HeaderBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.g = -1;
|
||||
this.i = -1;
|
||||
}
|
||||
|
||||
final int a(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3) {
|
||||
return b(coordinatorLayout, (CoordinatorLayout) v, c() - i, i2, i3);
|
||||
}
|
||||
|
||||
final boolean a(CoordinatorLayout coordinatorLayout, V v, int i, int i2, float f) {
|
||||
Runnable runnable = this.d;
|
||||
if (runnable != null) {
|
||||
v.removeCallbacks(runnable);
|
||||
this.d = null;
|
||||
}
|
||||
if (this.e == null) {
|
||||
this.e = new OverScroller(v.getContext());
|
||||
}
|
||||
this.e.fling(0, b(), 0, Math.round(f), 0, 0, i, i2);
|
||||
if (this.e.computeScrollOffset()) {
|
||||
this.d = new FlingRunnable(coordinatorLayout, v);
|
||||
ViewCompat.a(v, this.d);
|
||||
return true;
|
||||
}
|
||||
e(coordinatorLayout, v);
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class HeaderScrollingViewBehavior extends ViewOffsetBehavior<View> {
|
||||
final Rect d;
|
||||
final Rect e;
|
||||
private int f;
|
||||
private int g;
|
||||
|
||||
public HeaderScrollingViewBehavior() {
|
||||
this.d = new Rect();
|
||||
this.e = new Rect();
|
||||
this.f = 0;
|
||||
}
|
||||
|
||||
private static int c(int i) {
|
||||
if (i == 0) {
|
||||
return 8388659;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
abstract View a(List<View> list);
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean a(CoordinatorLayout coordinatorLayout, View view, int i, int i2, int i3, int i4) {
|
||||
View a;
|
||||
int i5 = view.getLayoutParams().height;
|
||||
if ((i5 != -1 && i5 != -2) || (a = a(coordinatorLayout.b(view))) == null) {
|
||||
return false;
|
||||
}
|
||||
if (ViewCompat.h(a) && !ViewCompat.h(view)) {
|
||||
ViewCompat.a(view, true);
|
||||
if (ViewCompat.h(view)) {
|
||||
view.requestLayout();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int size = View.MeasureSpec.getSize(i3);
|
||||
if (size == 0) {
|
||||
size = coordinatorLayout.getHeight();
|
||||
}
|
||||
coordinatorLayout.a(view, i, i2, View.MeasureSpec.makeMeasureSpec((size - a.getMeasuredHeight()) + c(a), i5 == -1 ? 1073741824 : Integer.MIN_VALUE), i4);
|
||||
return true;
|
||||
}
|
||||
|
||||
abstract float b(View view);
|
||||
|
||||
@Override // com.google.android.material.appbar.ViewOffsetBehavior
|
||||
protected void b(CoordinatorLayout coordinatorLayout, View view, int i) {
|
||||
View a = a(coordinatorLayout.b(view));
|
||||
if (a == null) {
|
||||
super.b(coordinatorLayout, (CoordinatorLayout) view, i);
|
||||
this.f = 0;
|
||||
return;
|
||||
}
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
Rect rect = this.d;
|
||||
rect.set(coordinatorLayout.getPaddingLeft() + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin, a.getBottom() + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin, (coordinatorLayout.getWidth() - coordinatorLayout.getPaddingRight()) - ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin, ((coordinatorLayout.getHeight() + a.getBottom()) - coordinatorLayout.getPaddingBottom()) - ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin);
|
||||
WindowInsetsCompat lastWindowInsets = coordinatorLayout.getLastWindowInsets();
|
||||
if (lastWindowInsets != null && ViewCompat.h(coordinatorLayout) && !ViewCompat.h(view)) {
|
||||
rect.left += lastWindowInsets.c();
|
||||
rect.right -= lastWindowInsets.d();
|
||||
}
|
||||
Rect rect2 = this.e;
|
||||
GravityCompat.a(c(layoutParams.c), view.getMeasuredWidth(), view.getMeasuredHeight(), rect, rect2, i);
|
||||
int a2 = a(a);
|
||||
view.layout(rect2.left, rect2.top - a2, rect2.right, rect2.bottom - a2);
|
||||
this.f = rect2.top - a.getBottom();
|
||||
}
|
||||
|
||||
int c(View view) {
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
|
||||
final int d() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public final int c() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public HeaderScrollingViewBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.d = new Rect();
|
||||
this.e = new Rect();
|
||||
this.f = 0;
|
||||
}
|
||||
|
||||
final int a(View view) {
|
||||
if (this.g == 0) {
|
||||
return 0;
|
||||
}
|
||||
float b = b(view);
|
||||
int i = this.g;
|
||||
return MathUtils.a((int) (b * i), 0, i);
|
||||
}
|
||||
|
||||
public final void b(int i) {
|
||||
this.g = i;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewOffsetBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
|
||||
private ViewOffsetHelper a;
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public ViewOffsetBehavior() {
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean a(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
b(coordinatorLayout, (CoordinatorLayout) v, i);
|
||||
if (this.a == null) {
|
||||
this.a = new ViewOffsetHelper(v);
|
||||
}
|
||||
this.a.c();
|
||||
int i2 = this.b;
|
||||
if (i2 != 0) {
|
||||
this.a.b(i2);
|
||||
this.b = 0;
|
||||
}
|
||||
int i3 = this.c;
|
||||
if (i3 == 0) {
|
||||
return true;
|
||||
}
|
||||
this.a.a(i3);
|
||||
this.c = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void b(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
coordinatorLayout.c(v, i);
|
||||
}
|
||||
|
||||
public int b() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.a;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.b();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ViewOffsetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.b = 0;
|
||||
this.c = 0;
|
||||
}
|
||||
|
||||
public boolean a(int i) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.a;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.b(i);
|
||||
}
|
||||
this.b = i;
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewOffsetHelper {
|
||||
private final View a;
|
||||
private int b;
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
|
||||
public ViewOffsetHelper(View view) {
|
||||
this.a = view;
|
||||
}
|
||||
|
||||
private void d() {
|
||||
View view = this.a;
|
||||
ViewCompat.d(view, this.d - (view.getTop() - this.b));
|
||||
View view2 = this.a;
|
||||
ViewCompat.c(view2, this.e - (view2.getLeft() - this.c));
|
||||
}
|
||||
|
||||
public boolean a(int i) {
|
||||
if (this.e == i) {
|
||||
return false;
|
||||
}
|
||||
this.e = i;
|
||||
d();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean b(int i) {
|
||||
if (this.d == i) {
|
||||
return false;
|
||||
}
|
||||
this.d = i;
|
||||
d();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.b = this.a.getTop();
|
||||
this.c = this.a.getLeft();
|
||||
d();
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.d;
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.R;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import com.google.android.material.R$attr;
|
||||
import com.google.android.material.R$integer;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewUtilsLollipop {
|
||||
private static final int[] a = {R.attr.stateListAnimator};
|
||||
|
||||
static void a(View view) {
|
||||
view.setOutlineProvider(ViewOutlineProvider.BOUNDS);
|
||||
}
|
||||
|
||||
static void a(View view, AttributeSet attributeSet, int i, int i2) {
|
||||
Context context = view.getContext();
|
||||
TypedArray c = ThemeEnforcement.c(context, attributeSet, a, i, i2, new int[0]);
|
||||
try {
|
||||
if (c.hasValue(0)) {
|
||||
view.setStateListAnimator(AnimatorInflater.loadStateListAnimator(context, c.getResourceId(0, 0)));
|
||||
}
|
||||
} finally {
|
||||
c.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
static void a(View view, float f) {
|
||||
int integer = view.getResources().getInteger(R$integer.app_bar_elevation_anim_duration);
|
||||
StateListAnimator stateListAnimator = new StateListAnimator();
|
||||
long j = integer;
|
||||
stateListAnimator.addState(new int[]{R.attr.enabled, R$attr.state_liftable, -R$attr.state_lifted}, ObjectAnimator.ofFloat(view, "elevation", 0.0f).setDuration(j));
|
||||
stateListAnimator.addState(new int[]{R.attr.enabled}, ObjectAnimator.ofFloat(view, "elevation", f).setDuration(j));
|
||||
stateListAnimator.addState(new int[0], ObjectAnimator.ofFloat(view, "elevation", 0.0f).setDuration(0L));
|
||||
view.setStateListAnimator(stateListAnimator);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user