1095 lines
41 KiB
Java
1095 lines
41 KiB
Java
package com.google.android.material.appbar;
|
|
|
|
import android.animation.ValueAnimator;
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Rect;
|
|
import android.os.Build;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.animation.Interpolator;
|
|
import android.widget.LinearLayout;
|
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
import androidx.core.math.MathUtils;
|
|
import androidx.core.util.ObjectsCompat;
|
|
import androidx.core.view.NestedScrollingChild;
|
|
import androidx.core.view.OnApplyWindowInsetsListener;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.WindowInsetsCompat;
|
|
import androidx.customview.view.AbsSavedState;
|
|
import com.google.android.material.R$attr;
|
|
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.internal.ThemeEnforcement;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@CoordinatorLayout.DefaultBehavior(Behavior.class)
|
|
/* loaded from: classes.dex */
|
|
public class AppBarLayout extends LinearLayout {
|
|
private int a;
|
|
private int b;
|
|
private int c;
|
|
private boolean d;
|
|
private int e;
|
|
private WindowInsetsCompat f;
|
|
private List<BaseOnOffsetChangedListener> g;
|
|
private boolean h;
|
|
private boolean i;
|
|
private boolean j;
|
|
private boolean k;
|
|
private int[] l;
|
|
|
|
protected static class BaseBehavior<T extends AppBarLayout> extends HeaderBehavior<T> {
|
|
private int k;
|
|
private int l;
|
|
private ValueAnimator m;
|
|
private int n;
|
|
private boolean o;
|
|
private float p;
|
|
private WeakReference<View> q;
|
|
private BaseDragCallback r;
|
|
|
|
public static abstract class BaseDragCallback<T extends AppBarLayout> {
|
|
public abstract boolean a(T t);
|
|
}
|
|
|
|
public BaseBehavior() {
|
|
this.n = -1;
|
|
}
|
|
|
|
private static boolean a(int i, int i2) {
|
|
return (i & i2) == i2;
|
|
}
|
|
|
|
private void d(CoordinatorLayout coordinatorLayout, T t) {
|
|
int c = c();
|
|
int b = b((BaseBehavior<T>) t, c);
|
|
if (b >= 0) {
|
|
View childAt = t.getChildAt(b);
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
int a = layoutParams.a();
|
|
if ((a & 17) == 17) {
|
|
int i = -childAt.getTop();
|
|
int i2 = -childAt.getBottom();
|
|
if (b == t.getChildCount() - 1) {
|
|
i2 += t.getTopInset();
|
|
}
|
|
if (a(a, 2)) {
|
|
i2 += ViewCompat.l(childAt);
|
|
} else if (a(a, 5)) {
|
|
int l = ViewCompat.l(childAt) + i2;
|
|
if (c < l) {
|
|
i = l;
|
|
} else {
|
|
i2 = l;
|
|
}
|
|
}
|
|
if (a(a, 32)) {
|
|
i += ((LinearLayout.LayoutParams) layoutParams).topMargin;
|
|
i2 -= ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
|
|
}
|
|
if (c < (i2 + i) / 2) {
|
|
i = i2;
|
|
}
|
|
a(coordinatorLayout, (CoordinatorLayout) t, MathUtils.a(i, -t.getTotalScrollRange(), 0), 0.0f);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.android.material.appbar.HeaderBehavior
|
|
public int c(T t) {
|
|
return t.getTotalScrollRange();
|
|
}
|
|
|
|
public BaseBehavior(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.n = -1;
|
|
}
|
|
|
|
private int c(T t, int i) {
|
|
int abs = Math.abs(i);
|
|
int childCount = t.getChildCount();
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
while (true) {
|
|
if (i3 >= childCount) {
|
|
break;
|
|
}
|
|
View childAt = t.getChildAt(i3);
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
Interpolator b = layoutParams.b();
|
|
if (abs < childAt.getTop() || abs > childAt.getBottom()) {
|
|
i3++;
|
|
} else if (b != null) {
|
|
int a = layoutParams.a();
|
|
if ((a & 1) != 0) {
|
|
i2 = 0 + childAt.getHeight() + ((LinearLayout.LayoutParams) layoutParams).topMargin + ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
|
|
if ((a & 2) != 0) {
|
|
i2 -= ViewCompat.l(childAt);
|
|
}
|
|
}
|
|
if (ViewCompat.h(childAt)) {
|
|
i2 -= t.getTopInset();
|
|
}
|
|
if (i2 > 0) {
|
|
float f = i2;
|
|
return Integer.signum(i) * (childAt.getTop() + Math.round(f * b.getInterpolation((abs - childAt.getTop()) / f)));
|
|
}
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
protected static class SavedState extends AbsSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: com.google.android.material.appbar.AppBarLayout.BaseBehavior.SavedState.1
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.ClassLoaderCreator
|
|
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
|
|
return new SavedState(parcel, classLoader);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel, null);
|
|
}
|
|
};
|
|
boolean firstVisibleChildAtMinimumHeight;
|
|
int firstVisibleChildIndex;
|
|
float firstVisibleChildPercentageShown;
|
|
|
|
public SavedState(Parcel parcel, ClassLoader classLoader) {
|
|
super(parcel, classLoader);
|
|
this.firstVisibleChildIndex = parcel.readInt();
|
|
this.firstVisibleChildPercentageShown = parcel.readFloat();
|
|
this.firstVisibleChildAtMinimumHeight = parcel.readByte() != 0;
|
|
}
|
|
|
|
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
super.writeToParcel(parcel, i);
|
|
parcel.writeInt(this.firstVisibleChildIndex);
|
|
parcel.writeFloat(this.firstVisibleChildPercentageShown);
|
|
parcel.writeByte(this.firstVisibleChildAtMinimumHeight ? (byte) 1 : (byte) 0);
|
|
}
|
|
|
|
public SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
}
|
|
|
|
private int b(T t, int i) {
|
|
int childCount = t.getChildCount();
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt = t.getChildAt(i2);
|
|
int top = childAt.getTop();
|
|
int bottom = childAt.getBottom();
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
if (a(layoutParams.a(), 32)) {
|
|
top -= ((LinearLayout.LayoutParams) layoutParams).topMargin;
|
|
bottom += ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
|
|
}
|
|
int i3 = -i;
|
|
if (top <= i3 && bottom >= i3) {
|
|
return i2;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public boolean b(CoordinatorLayout coordinatorLayout, T t, View view, View view2, int i, int i2) {
|
|
ValueAnimator valueAnimator;
|
|
boolean z = (i & 2) != 0 && (t.c() || a(coordinatorLayout, (CoordinatorLayout) t, view));
|
|
if (z && (valueAnimator = this.m) != null) {
|
|
valueAnimator.cancel();
|
|
}
|
|
this.q = null;
|
|
this.l = i2;
|
|
return z;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.android.material.appbar.HeaderBehavior
|
|
public int b(T t) {
|
|
return -t.getDownNestedScrollRange();
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
/* renamed from: b, reason: merged with bridge method [inline-methods] */
|
|
public Parcelable d(CoordinatorLayout coordinatorLayout, T t) {
|
|
Parcelable d = super.d(coordinatorLayout, (CoordinatorLayout) t);
|
|
int b = b();
|
|
int childCount = t.getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = t.getChildAt(i);
|
|
int bottom = childAt.getBottom() + b;
|
|
if (childAt.getTop() + b <= 0 && bottom >= 0) {
|
|
SavedState savedState = new SavedState(d);
|
|
savedState.firstVisibleChildIndex = i;
|
|
savedState.firstVisibleChildAtMinimumHeight = bottom == ViewCompat.l(childAt) + t.getTopInset();
|
|
savedState.firstVisibleChildPercentageShown = bottom / childAt.getHeight();
|
|
return savedState;
|
|
}
|
|
}
|
|
return d;
|
|
}
|
|
|
|
private boolean a(CoordinatorLayout coordinatorLayout, T t, View view) {
|
|
return t.b() && coordinatorLayout.getHeight() - view.getHeight() <= t.getHeight();
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public void a(CoordinatorLayout coordinatorLayout, T t, View view, int i, int i2, int[] iArr, int i3) {
|
|
int i4;
|
|
int i5;
|
|
if (i2 != 0) {
|
|
if (i2 < 0) {
|
|
int i6 = -t.getTotalScrollRange();
|
|
i4 = i6;
|
|
i5 = t.getDownNestedPreScrollRange() + i6;
|
|
} else {
|
|
i4 = -t.getUpNestedPreScrollRange();
|
|
i5 = 0;
|
|
}
|
|
if (i4 != i5) {
|
|
iArr[1] = a(coordinatorLayout, (CoordinatorLayout) t, i2, i4, i5);
|
|
a(i2, (int) t, view, i3);
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean c(CoordinatorLayout coordinatorLayout, T t) {
|
|
List<View> c = coordinatorLayout.c(t);
|
|
int size = c.size();
|
|
for (int i = 0; i < size; i++) {
|
|
CoordinatorLayout.Behavior d = ((CoordinatorLayout.LayoutParams) c.get(i).getLayoutParams()).d();
|
|
if (d instanceof ScrollingViewBehavior) {
|
|
return ((ScrollingViewBehavior) d).c() != 0;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public void a(CoordinatorLayout coordinatorLayout, T t, View view, int i, int i2, int i3, int i4, int i5) {
|
|
if (i4 < 0) {
|
|
a(coordinatorLayout, (CoordinatorLayout) t, i4, -t.getDownNestedScrollRange(), 0);
|
|
a(i4, (int) t, view, i5);
|
|
}
|
|
if (t.c()) {
|
|
t.a(view.getScrollY() > 0);
|
|
}
|
|
}
|
|
|
|
private void a(int i, T t, View view, int i2) {
|
|
if (i2 == 1) {
|
|
int c = c();
|
|
if ((i >= 0 || c != 0) && (i <= 0 || c != (-t.getDownNestedScrollRange()))) {
|
|
return;
|
|
}
|
|
ViewCompat.h(view, 1);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.material.appbar.HeaderBehavior
|
|
int c() {
|
|
return b() + this.k;
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public void a(CoordinatorLayout coordinatorLayout, T t, View view, int i) {
|
|
if (this.l == 0 || i == 1) {
|
|
d(coordinatorLayout, (CoordinatorLayout) t);
|
|
}
|
|
this.q = new WeakReference<>(view);
|
|
}
|
|
|
|
private void a(CoordinatorLayout coordinatorLayout, T t, int i, float f) {
|
|
int height;
|
|
int abs = Math.abs(c() - i);
|
|
float abs2 = Math.abs(f);
|
|
if (abs2 > 0.0f) {
|
|
height = Math.round((abs / abs2) * 1000.0f) * 3;
|
|
} else {
|
|
height = (int) (((abs / t.getHeight()) + 1.0f) * 150.0f);
|
|
}
|
|
a(coordinatorLayout, (CoordinatorLayout) t, i, height);
|
|
}
|
|
|
|
private void a(final CoordinatorLayout coordinatorLayout, final T t, int i, int i2) {
|
|
int c = c();
|
|
if (c == i) {
|
|
ValueAnimator valueAnimator = this.m;
|
|
if (valueAnimator == null || !valueAnimator.isRunning()) {
|
|
return;
|
|
}
|
|
this.m.cancel();
|
|
return;
|
|
}
|
|
ValueAnimator valueAnimator2 = this.m;
|
|
if (valueAnimator2 == null) {
|
|
this.m = new ValueAnimator();
|
|
this.m.setInterpolator(AnimationUtils.e);
|
|
this.m.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.appbar.AppBarLayout.BaseBehavior.1
|
|
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
|
public void onAnimationUpdate(ValueAnimator valueAnimator3) {
|
|
BaseBehavior.this.c(coordinatorLayout, (CoordinatorLayout) t, ((Integer) valueAnimator3.getAnimatedValue()).intValue());
|
|
}
|
|
});
|
|
} else {
|
|
valueAnimator2.cancel();
|
|
}
|
|
this.m.setDuration(Math.min(i2, 600));
|
|
this.m.setIntValues(c, i);
|
|
this.m.start();
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public boolean a(CoordinatorLayout coordinatorLayout, T t, int i, int i2, int i3, int i4) {
|
|
if (((ViewGroup.MarginLayoutParams) ((CoordinatorLayout.LayoutParams) t.getLayoutParams())).height == -2) {
|
|
coordinatorLayout.a(t, i, i2, View.MeasureSpec.makeMeasureSpec(0, 0), i4);
|
|
return true;
|
|
}
|
|
return super.a(coordinatorLayout, (CoordinatorLayout) t, i, i2, i3, i4);
|
|
}
|
|
|
|
@Override // com.google.android.material.appbar.ViewOffsetBehavior, androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public boolean a(CoordinatorLayout coordinatorLayout, T t, int i) {
|
|
int round;
|
|
boolean a = super.a(coordinatorLayout, (CoordinatorLayout) t, i);
|
|
int pendingAction = t.getPendingAction();
|
|
int i2 = this.n;
|
|
if (i2 >= 0 && (pendingAction & 8) == 0) {
|
|
View childAt = t.getChildAt(i2);
|
|
int i3 = -childAt.getBottom();
|
|
if (this.o) {
|
|
round = ViewCompat.l(childAt) + t.getTopInset();
|
|
} else {
|
|
round = Math.round(childAt.getHeight() * this.p);
|
|
}
|
|
c(coordinatorLayout, (CoordinatorLayout) t, i3 + round);
|
|
} else if (pendingAction != 0) {
|
|
boolean z = (pendingAction & 4) != 0;
|
|
if ((pendingAction & 2) != 0) {
|
|
int i4 = -t.getUpNestedPreScrollRange();
|
|
if (z) {
|
|
a(coordinatorLayout, (CoordinatorLayout) t, i4, 0.0f);
|
|
} else {
|
|
c(coordinatorLayout, (CoordinatorLayout) t, i4);
|
|
}
|
|
} else if ((pendingAction & 1) != 0) {
|
|
if (z) {
|
|
a(coordinatorLayout, (CoordinatorLayout) t, 0, 0.0f);
|
|
} else {
|
|
c(coordinatorLayout, (CoordinatorLayout) t, 0);
|
|
}
|
|
}
|
|
}
|
|
t.d();
|
|
this.n = -1;
|
|
a(MathUtils.a(b(), -t.getTotalScrollRange(), 0));
|
|
a(coordinatorLayout, (CoordinatorLayout) t, b(), 0, true);
|
|
t.a(b());
|
|
return a;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.android.material.appbar.HeaderBehavior
|
|
public boolean a(T t) {
|
|
BaseDragCallback baseDragCallback = this.r;
|
|
if (baseDragCallback != null) {
|
|
return baseDragCallback.a(t);
|
|
}
|
|
WeakReference<View> weakReference = this.q;
|
|
if (weakReference == null) {
|
|
return true;
|
|
}
|
|
View view = weakReference.get();
|
|
return (view == null || !view.isShown() || view.canScrollVertically(-1)) ? false : true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.android.material.appbar.HeaderBehavior
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void e(CoordinatorLayout coordinatorLayout, T t) {
|
|
d(coordinatorLayout, (CoordinatorLayout) t);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.android.material.appbar.HeaderBehavior
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public int b(CoordinatorLayout coordinatorLayout, T t, int i, int i2, int i3) {
|
|
int c = c();
|
|
int i4 = 0;
|
|
if (i2 != 0 && c >= i2 && c <= i3) {
|
|
int a = MathUtils.a(i, i2, i3);
|
|
if (c != a) {
|
|
int c2 = t.a() ? c((BaseBehavior<T>) t, a) : a;
|
|
boolean a2 = a(c2);
|
|
i4 = c - a;
|
|
this.k = a - c2;
|
|
if (!a2 && t.a()) {
|
|
coordinatorLayout.a(t);
|
|
}
|
|
t.a(b());
|
|
a(coordinatorLayout, (CoordinatorLayout) t, a, a < c ? -1 : 1, false);
|
|
}
|
|
} else {
|
|
this.k = 0;
|
|
}
|
|
return i4;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:18:0x0054 */
|
|
/* JADX WARN: Removed duplicated region for block: B:19:0x0056 */
|
|
/* JADX WARN: Removed duplicated region for block: B:22:0x0061 */
|
|
/* JADX WARN: Removed duplicated region for block: B:31:? A[RETURN, SYNTHETIC] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
private void a(androidx.coordinatorlayout.widget.CoordinatorLayout r6, T r7, int r8, int r9, boolean r10) {
|
|
/*
|
|
r5 = this;
|
|
android.view.View r0 = a(r7, r8)
|
|
if (r0 == 0) goto L6e
|
|
android.view.ViewGroup$LayoutParams r1 = r0.getLayoutParams()
|
|
com.google.android.material.appbar.AppBarLayout$LayoutParams r1 = (com.google.android.material.appbar.AppBarLayout.LayoutParams) r1
|
|
int r1 = r1.a()
|
|
r2 = r1 & 1
|
|
r3 = 1
|
|
r4 = 0
|
|
if (r2 == 0) goto L41
|
|
int r2 = androidx.core.view.ViewCompat.l(r0)
|
|
if (r9 <= 0) goto L2f
|
|
r9 = r1 & 12
|
|
if (r9 == 0) goto L2f
|
|
int r8 = -r8
|
|
int r9 = r0.getBottom()
|
|
int r9 = r9 - r2
|
|
int r0 = r7.getTopInset()
|
|
int r9 = r9 - r0
|
|
if (r8 < r9) goto L41
|
|
L2d:
|
|
r8 = 1
|
|
goto L42
|
|
L2f:
|
|
r9 = r1 & 2
|
|
if (r9 == 0) goto L41
|
|
int r8 = -r8
|
|
int r9 = r0.getBottom()
|
|
int r9 = r9 - r2
|
|
int r0 = r7.getTopInset()
|
|
int r9 = r9 - r0
|
|
if (r8 < r9) goto L41
|
|
goto L2d
|
|
L41:
|
|
r8 = 0
|
|
L42:
|
|
boolean r9 = r7.c()
|
|
if (r9 == 0) goto L57
|
|
android.view.View r9 = r5.a(r6)
|
|
if (r9 == 0) goto L57
|
|
int r8 = r9.getScrollY()
|
|
if (r8 <= 0) goto L56
|
|
r8 = 1
|
|
goto L57
|
|
L56:
|
|
r8 = 0
|
|
L57:
|
|
boolean r8 = r7.a(r8)
|
|
int r9 = android.os.Build.VERSION.SDK_INT
|
|
r0 = 11
|
|
if (r9 < r0) goto L6e
|
|
if (r10 != 0) goto L6b
|
|
if (r8 == 0) goto L6e
|
|
boolean r6 = r5.c(r6, r7)
|
|
if (r6 == 0) goto L6e
|
|
L6b:
|
|
r7.jumpDrawablesToCurrentState()
|
|
L6e:
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.AppBarLayout.BaseBehavior.a(androidx.coordinatorlayout.widget.CoordinatorLayout, com.google.android.material.appbar.AppBarLayout, int, int, boolean):void");
|
|
}
|
|
|
|
private static View a(AppBarLayout appBarLayout, int i) {
|
|
int abs = Math.abs(i);
|
|
int childCount = appBarLayout.getChildCount();
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt = appBarLayout.getChildAt(i2);
|
|
if (abs >= childAt.getTop() && abs <= childAt.getBottom()) {
|
|
return childAt;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private View a(CoordinatorLayout coordinatorLayout) {
|
|
int childCount = coordinatorLayout.getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = coordinatorLayout.getChildAt(i);
|
|
if (childAt instanceof NestedScrollingChild) {
|
|
return childAt;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public void a(CoordinatorLayout coordinatorLayout, T t, Parcelable parcelable) {
|
|
if (parcelable instanceof SavedState) {
|
|
SavedState savedState = (SavedState) parcelable;
|
|
super.a(coordinatorLayout, (CoordinatorLayout) t, savedState.getSuperState());
|
|
this.n = savedState.firstVisibleChildIndex;
|
|
this.p = savedState.firstVisibleChildPercentageShown;
|
|
this.o = savedState.firstVisibleChildAtMinimumHeight;
|
|
return;
|
|
}
|
|
super.a(coordinatorLayout, (CoordinatorLayout) t, parcelable);
|
|
this.n = -1;
|
|
}
|
|
}
|
|
|
|
public interface BaseOnOffsetChangedListener<T extends AppBarLayout> {
|
|
void a(T t, int i);
|
|
}
|
|
|
|
public static class Behavior extends BaseBehavior<AppBarLayout> {
|
|
public Behavior() {
|
|
}
|
|
|
|
public Behavior(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
}
|
|
}
|
|
|
|
public interface OnOffsetChangedListener extends BaseOnOffsetChangedListener<AppBarLayout> {
|
|
}
|
|
|
|
public static class ScrollingViewBehavior extends HeaderScrollingViewBehavior {
|
|
public ScrollingViewBehavior() {
|
|
}
|
|
|
|
@Override // com.google.android.material.appbar.HeaderScrollingViewBehavior
|
|
/* bridge */ /* synthetic */ View a(List list) {
|
|
return a((List<View>) list);
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public boolean b(CoordinatorLayout coordinatorLayout, View view, View view2) {
|
|
a(view, view2);
|
|
b(view, view2);
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.android.material.appbar.HeaderScrollingViewBehavior
|
|
int c(View view) {
|
|
return view instanceof AppBarLayout ? ((AppBarLayout) view).getTotalScrollRange() : super.c(view);
|
|
}
|
|
|
|
public ScrollingViewBehavior(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.ScrollingViewBehavior_Layout);
|
|
b(obtainStyledAttributes.getDimensionPixelSize(R$styleable.ScrollingViewBehavior_Layout_behavior_overlapTop, 0));
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
|
|
@Override // com.google.android.material.appbar.HeaderScrollingViewBehavior
|
|
float b(View view) {
|
|
int i;
|
|
if (view instanceof AppBarLayout) {
|
|
AppBarLayout appBarLayout = (AppBarLayout) view;
|
|
int totalScrollRange = appBarLayout.getTotalScrollRange();
|
|
int downNestedPreScrollRange = appBarLayout.getDownNestedPreScrollRange();
|
|
int a = a(appBarLayout);
|
|
if ((downNestedPreScrollRange == 0 || totalScrollRange + a > downNestedPreScrollRange) && (i = totalScrollRange - downNestedPreScrollRange) != 0) {
|
|
return (a / i) + 1.0f;
|
|
}
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public boolean a(CoordinatorLayout coordinatorLayout, View view, View view2) {
|
|
return view2 instanceof AppBarLayout;
|
|
}
|
|
|
|
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
|
public boolean a(CoordinatorLayout coordinatorLayout, View view, Rect rect, boolean z) {
|
|
AppBarLayout a = a(coordinatorLayout.b(view));
|
|
if (a != null) {
|
|
rect.offset(view.getLeft(), view.getTop());
|
|
Rect rect2 = this.d;
|
|
rect2.set(0, 0, coordinatorLayout.getWidth(), coordinatorLayout.getHeight());
|
|
if (!rect2.contains(rect)) {
|
|
a.a(false, !z);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void b(View view, View view2) {
|
|
if (view2 instanceof AppBarLayout) {
|
|
AppBarLayout appBarLayout = (AppBarLayout) view2;
|
|
if (appBarLayout.c()) {
|
|
appBarLayout.a(view.getScrollY() > 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(View view, View view2) {
|
|
CoordinatorLayout.Behavior d = ((CoordinatorLayout.LayoutParams) view2.getLayoutParams()).d();
|
|
if (d instanceof BaseBehavior) {
|
|
ViewCompat.d(view, (((view2.getBottom() - view.getTop()) + ((BaseBehavior) d).k) + d()) - a(view2));
|
|
}
|
|
}
|
|
|
|
private static int a(AppBarLayout appBarLayout) {
|
|
CoordinatorLayout.Behavior d = ((CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams()).d();
|
|
if (d instanceof BaseBehavior) {
|
|
return ((BaseBehavior) d).c();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override // com.google.android.material.appbar.HeaderScrollingViewBehavior
|
|
AppBarLayout a(List<View> list) {
|
|
int size = list.size();
|
|
for (int i = 0; i < size; i++) {
|
|
View view = list.get(i);
|
|
if (view instanceof AppBarLayout) {
|
|
return (AppBarLayout) view;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public AppBarLayout(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private boolean e() {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
if (((LayoutParams) getChildAt(i).getLayoutParams()).c()) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void f() {
|
|
this.a = -1;
|
|
this.b = -1;
|
|
this.c = -1;
|
|
}
|
|
|
|
public void a(BaseOnOffsetChangedListener baseOnOffsetChangedListener) {
|
|
if (this.g == null) {
|
|
this.g = new ArrayList();
|
|
}
|
|
if (baseOnOffsetChangedListener == null || this.g.contains(baseOnOffsetChangedListener)) {
|
|
return;
|
|
}
|
|
this.g.add(baseOnOffsetChangedListener);
|
|
}
|
|
|
|
public void b(BaseOnOffsetChangedListener baseOnOffsetChangedListener) {
|
|
List<BaseOnOffsetChangedListener> list = this.g;
|
|
if (list == null || baseOnOffsetChangedListener == null) {
|
|
return;
|
|
}
|
|
list.remove(baseOnOffsetChangedListener);
|
|
}
|
|
|
|
public boolean c() {
|
|
return this.k;
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.ViewGroup
|
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return layoutParams instanceof LayoutParams;
|
|
}
|
|
|
|
void d() {
|
|
this.e = 0;
|
|
}
|
|
|
|
int getDownNestedPreScrollRange() {
|
|
int i = this.b;
|
|
if (i != -1) {
|
|
return i;
|
|
}
|
|
int i2 = 0;
|
|
for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
|
|
View childAt = getChildAt(childCount);
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
int measuredHeight = childAt.getMeasuredHeight();
|
|
int i3 = layoutParams.a;
|
|
if ((i3 & 5) != 5) {
|
|
if (i2 > 0) {
|
|
break;
|
|
}
|
|
} else {
|
|
int i4 = i2 + ((LinearLayout.LayoutParams) layoutParams).topMargin + ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
|
|
i2 = (i3 & 8) != 0 ? i4 + ViewCompat.l(childAt) : i4 + (measuredHeight - ((i3 & 2) != 0 ? ViewCompat.l(childAt) : getTopInset()));
|
|
}
|
|
}
|
|
int max = Math.max(0, i2);
|
|
this.b = max;
|
|
return max;
|
|
}
|
|
|
|
int getDownNestedScrollRange() {
|
|
int i = this.c;
|
|
if (i != -1) {
|
|
return i;
|
|
}
|
|
int childCount = getChildCount();
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
while (true) {
|
|
if (i2 >= childCount) {
|
|
break;
|
|
}
|
|
View childAt = getChildAt(i2);
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
int measuredHeight = childAt.getMeasuredHeight() + ((LinearLayout.LayoutParams) layoutParams).topMargin + ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
|
|
int i4 = layoutParams.a;
|
|
if ((i4 & 1) == 0) {
|
|
break;
|
|
}
|
|
i3 += measuredHeight;
|
|
if ((i4 & 2) != 0) {
|
|
i3 -= ViewCompat.l(childAt) + getTopInset();
|
|
break;
|
|
}
|
|
i2++;
|
|
}
|
|
int max = Math.max(0, i3);
|
|
this.c = max;
|
|
return max;
|
|
}
|
|
|
|
public final int getMinimumHeightForVisibleOverlappingContent() {
|
|
int topInset = getTopInset();
|
|
int l = ViewCompat.l(this);
|
|
if (l == 0) {
|
|
int childCount = getChildCount();
|
|
l = childCount >= 1 ? ViewCompat.l(getChildAt(childCount - 1)) : 0;
|
|
if (l == 0) {
|
|
return getHeight() / 3;
|
|
}
|
|
}
|
|
return (l * 2) + topInset;
|
|
}
|
|
|
|
int getPendingAction() {
|
|
return this.e;
|
|
}
|
|
|
|
@Deprecated
|
|
public float getTargetElevation() {
|
|
return 0.0f;
|
|
}
|
|
|
|
final int getTopInset() {
|
|
WindowInsetsCompat windowInsetsCompat = this.f;
|
|
if (windowInsetsCompat != null) {
|
|
return windowInsetsCompat.e();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public final int getTotalScrollRange() {
|
|
int i = this.a;
|
|
if (i != -1) {
|
|
return i;
|
|
}
|
|
int childCount = getChildCount();
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
while (true) {
|
|
if (i2 >= childCount) {
|
|
break;
|
|
}
|
|
View childAt = getChildAt(i2);
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
int measuredHeight = childAt.getMeasuredHeight();
|
|
int i4 = layoutParams.a;
|
|
if ((i4 & 1) == 0) {
|
|
break;
|
|
}
|
|
i3 += measuredHeight + ((LinearLayout.LayoutParams) layoutParams).topMargin + ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
|
|
if ((i4 & 2) != 0) {
|
|
i3 -= ViewCompat.l(childAt);
|
|
break;
|
|
}
|
|
i2++;
|
|
}
|
|
int max = Math.max(0, i3 - getTopInset());
|
|
this.a = max;
|
|
return max;
|
|
}
|
|
|
|
int getUpNestedPreScrollRange() {
|
|
return getTotalScrollRange();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected int[] onCreateDrawableState(int i) {
|
|
if (this.l == null) {
|
|
this.l = new int[4];
|
|
}
|
|
int[] iArr = this.l;
|
|
int[] onCreateDrawableState = super.onCreateDrawableState(i + iArr.length);
|
|
iArr[0] = this.i ? R$attr.state_liftable : -R$attr.state_liftable;
|
|
iArr[1] = (this.i && this.j) ? R$attr.state_lifted : -R$attr.state_lifted;
|
|
iArr[2] = this.i ? R$attr.state_collapsible : -R$attr.state_collapsible;
|
|
iArr[3] = (this.i && this.j) ? R$attr.state_collapsed : -R$attr.state_collapsed;
|
|
return LinearLayout.mergeDrawableStates(onCreateDrawableState, iArr);
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, 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);
|
|
f();
|
|
this.d = false;
|
|
int childCount = getChildCount();
|
|
int i5 = 0;
|
|
while (true) {
|
|
if (i5 >= childCount) {
|
|
break;
|
|
}
|
|
if (((LayoutParams) getChildAt(i5).getLayoutParams()).b() != null) {
|
|
this.d = true;
|
|
break;
|
|
}
|
|
i5++;
|
|
}
|
|
if (this.h) {
|
|
return;
|
|
}
|
|
b(this.k || e());
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
super.onMeasure(i, i2);
|
|
f();
|
|
}
|
|
|
|
public void setExpanded(boolean z) {
|
|
a(z, ViewCompat.x(this));
|
|
}
|
|
|
|
public void setLiftOnScroll(boolean z) {
|
|
this.k = z;
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout
|
|
public void setOrientation(int i) {
|
|
if (i != 1) {
|
|
throw new IllegalArgumentException("AppBarLayout is always vertical and does not support horizontal orientation");
|
|
}
|
|
super.setOrientation(i);
|
|
}
|
|
|
|
@Deprecated
|
|
public void setTargetElevation(float f) {
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
ViewUtilsLollipop.a(this, f);
|
|
}
|
|
}
|
|
|
|
public AppBarLayout(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.a = -1;
|
|
this.b = -1;
|
|
this.c = -1;
|
|
this.e = 0;
|
|
setOrientation(1);
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
ViewUtilsLollipop.a(this);
|
|
ViewUtilsLollipop.a(this, attributeSet, 0, R$style.Widget_Design_AppBarLayout);
|
|
}
|
|
TypedArray c = ThemeEnforcement.c(context, attributeSet, R$styleable.AppBarLayout, 0, R$style.Widget_Design_AppBarLayout, new int[0]);
|
|
ViewCompat.a(this, c.getDrawable(R$styleable.AppBarLayout_android_background));
|
|
if (c.hasValue(R$styleable.AppBarLayout_expanded)) {
|
|
a(c.getBoolean(R$styleable.AppBarLayout_expanded, false), false, false);
|
|
}
|
|
if (Build.VERSION.SDK_INT >= 21 && c.hasValue(R$styleable.AppBarLayout_elevation)) {
|
|
ViewUtilsLollipop.a(this, c.getDimensionPixelSize(R$styleable.AppBarLayout_elevation, 0));
|
|
}
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
if (c.hasValue(R$styleable.AppBarLayout_android_keyboardNavigationCluster)) {
|
|
setKeyboardNavigationCluster(c.getBoolean(R$styleable.AppBarLayout_android_keyboardNavigationCluster, false));
|
|
}
|
|
if (c.hasValue(R$styleable.AppBarLayout_android_touchscreenBlocksFocus)) {
|
|
setTouchscreenBlocksFocus(c.getBoolean(R$styleable.AppBarLayout_android_touchscreenBlocksFocus, false));
|
|
}
|
|
}
|
|
this.k = c.getBoolean(R$styleable.AppBarLayout_liftOnScroll, false);
|
|
c.recycle();
|
|
ViewCompat.a(this, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.appbar.AppBarLayout.1
|
|
@Override // androidx.core.view.OnApplyWindowInsetsListener
|
|
public WindowInsetsCompat a(View view, WindowInsetsCompat windowInsetsCompat) {
|
|
return AppBarLayout.this.a(windowInsetsCompat);
|
|
}
|
|
});
|
|
}
|
|
|
|
public void b(OnOffsetChangedListener onOffsetChangedListener) {
|
|
b((BaseOnOffsetChangedListener) onOffsetChangedListener);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // android.widget.LinearLayout, android.view.ViewGroup
|
|
public LayoutParams generateDefaultLayoutParams() {
|
|
return new LayoutParams(-1, -2);
|
|
}
|
|
|
|
boolean b() {
|
|
return getTotalScrollRange() != 0;
|
|
}
|
|
|
|
private boolean b(boolean z) {
|
|
if (this.i == z) {
|
|
return false;
|
|
}
|
|
this.i = z;
|
|
refreshDrawableState();
|
|
return true;
|
|
}
|
|
|
|
public void a(OnOffsetChangedListener onOffsetChangedListener) {
|
|
a((BaseOnOffsetChangedListener) onOffsetChangedListener);
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.ViewGroup
|
|
public LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
|
return new LayoutParams(getContext(), attributeSet);
|
|
}
|
|
|
|
public void a(boolean z, boolean z2) {
|
|
a(z, z2, true);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // android.widget.LinearLayout, android.view.ViewGroup
|
|
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
if (Build.VERSION.SDK_INT >= 19 && (layoutParams instanceof LinearLayout.LayoutParams)) {
|
|
return new LayoutParams((LinearLayout.LayoutParams) layoutParams);
|
|
}
|
|
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
|
|
return new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams);
|
|
}
|
|
return new LayoutParams(layoutParams);
|
|
}
|
|
|
|
private void a(boolean z, boolean z2, boolean z3) {
|
|
this.e = (z ? 1 : 2) | (z2 ? 4 : 0) | (z3 ? 8 : 0);
|
|
requestLayout();
|
|
}
|
|
|
|
public static class LayoutParams extends LinearLayout.LayoutParams {
|
|
int a;
|
|
Interpolator b;
|
|
|
|
public LayoutParams(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.a = 1;
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.AppBarLayout_Layout);
|
|
this.a = obtainStyledAttributes.getInt(R$styleable.AppBarLayout_Layout_layout_scrollFlags, 0);
|
|
if (obtainStyledAttributes.hasValue(R$styleable.AppBarLayout_Layout_layout_scrollInterpolator)) {
|
|
this.b = android.view.animation.AnimationUtils.loadInterpolator(context, obtainStyledAttributes.getResourceId(R$styleable.AppBarLayout_Layout_layout_scrollInterpolator, 0));
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
|
|
public int a() {
|
|
return this.a;
|
|
}
|
|
|
|
public Interpolator b() {
|
|
return this.b;
|
|
}
|
|
|
|
boolean c() {
|
|
int i = this.a;
|
|
return (i & 1) == 1 && (i & 10) != 0;
|
|
}
|
|
|
|
public LayoutParams(int i, int i2) {
|
|
super(i, i2);
|
|
this.a = 1;
|
|
}
|
|
|
|
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
super(layoutParams);
|
|
this.a = 1;
|
|
}
|
|
|
|
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
|
super(marginLayoutParams);
|
|
this.a = 1;
|
|
}
|
|
|
|
public LayoutParams(LinearLayout.LayoutParams layoutParams) {
|
|
super(layoutParams);
|
|
this.a = 1;
|
|
}
|
|
}
|
|
|
|
boolean a() {
|
|
return this.d;
|
|
}
|
|
|
|
void a(int i) {
|
|
List<BaseOnOffsetChangedListener> list = this.g;
|
|
if (list != null) {
|
|
int size = list.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
BaseOnOffsetChangedListener baseOnOffsetChangedListener = this.g.get(i2);
|
|
if (baseOnOffsetChangedListener != null) {
|
|
baseOnOffsetChangedListener.a(this, i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean a(boolean z) {
|
|
if (this.j == z) {
|
|
return false;
|
|
}
|
|
this.j = z;
|
|
refreshDrawableState();
|
|
return true;
|
|
}
|
|
|
|
WindowInsetsCompat a(WindowInsetsCompat windowInsetsCompat) {
|
|
WindowInsetsCompat windowInsetsCompat2 = ViewCompat.h(this) ? windowInsetsCompat : null;
|
|
if (!ObjectsCompat.a(this.f, windowInsetsCompat2)) {
|
|
this.f = windowInsetsCompat2;
|
|
f();
|
|
}
|
|
return windowInsetsCompat;
|
|
}
|
|
}
|