what-the-bank/sources/androidx/core/view/WindowInsetsAnimationCompat...

530 lines
20 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.core.view;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Insets;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowInsetsAnimation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import androidx.core.view.WindowInsetsCompat;
import com.airbnb.deeplinkdispatch.UrlTreeKt;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import o.KtR;
import o.Rmc;
import o.ViewTreeObserverOnPreDrawListenerC17759zYL;
/* loaded from: classes.dex */
public final class WindowInsetsAnimationCompat {
private IeS b;
public WindowInsetsAnimationCompat(int i, Interpolator interpolator, long j) {
if (Build.VERSION.SDK_INT >= 30) {
this.b = new RVV(i, interpolator, j);
} else {
this.b = new LWm(i, interpolator, j);
}
}
private WindowInsetsAnimationCompat(WindowInsetsAnimation windowInsetsAnimation) {
this(0, null, 0L);
if (Build.VERSION.SDK_INT >= 30) {
this.b = new RVV(windowInsetsAnimation);
}
}
public final int d() {
return this.b.a();
}
public final float a() {
return this.b.c();
}
public final long c() {
return this.b.b();
}
public final void e(float f) {
this.b.c(f);
}
/* loaded from: classes.dex */
public static final class HBt {
private final Rmc b;
private final Rmc d;
public HBt(Rmc rmc, Rmc rmc2) {
this.b = rmc;
this.d = rmc2;
}
private HBt(WindowInsetsAnimation.Bounds bounds) {
this.b = RVV.tE_(bounds);
this.d = RVV.tD_(bounds);
}
public final String toString() {
StringBuilder sb = new StringBuilder("Bounds{lower=");
sb.append(this.b);
sb.append(" upper=");
sb.append(this.d);
sb.append(UrlTreeKt.componentParamSuffix);
return sb.toString();
}
public final WindowInsetsAnimation.Bounds ty_() {
return RVV.tC_(this);
}
public static HBt tx_(WindowInsetsAnimation.Bounds bounds) {
return new HBt(bounds);
}
public final Rmc c() {
return this.d;
}
public final Rmc b() {
return this.b;
}
}
static WindowInsetsAnimationCompat tw_(WindowInsetsAnimation windowInsetsAnimation) {
return new WindowInsetsAnimationCompat(windowInsetsAnimation);
}
/* loaded from: classes.dex */
public static abstract class Callback {
private final int a;
WindowInsets d;
public void a(WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
}
public HBt b(WindowInsetsAnimationCompat windowInsetsAnimationCompat, HBt hBt) {
return hBt;
}
public void c(WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
}
public abstract WindowInsetsCompat e(WindowInsetsCompat windowInsetsCompat, List<WindowInsetsAnimationCompat> list);
public Callback(int i) {
this.a = i;
}
public final int c() {
return this.a;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static void b(View view, Callback callback) {
if (Build.VERSION.SDK_INT >= 30) {
RVV.e(view, callback);
} else {
LWm.b(view, callback);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class IeS {
private final long a;
private final int b;
private final Interpolator c;
private float d;
IeS(int i, Interpolator interpolator, long j) {
this.b = i;
this.c = interpolator;
this.a = j;
}
public float c() {
Interpolator interpolator = this.c;
return interpolator != null ? interpolator.getInterpolation(this.d) : this.d;
}
public void c(float f) {
this.d = f;
}
public int a() {
return this.b;
}
public long b() {
return this.a;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class LWm extends IeS {
LWm(int i, Interpolator interpolator, long j) {
super(i, interpolator, j);
}
static void b(View view, Callback callback) {
Object tag = view.getTag(KtR.Sts.tag_on_apply_window_listener);
if (callback == null) {
view.setTag(KtR.Sts.tag_window_insets_animation_callback, null);
if (tag == null) {
view.setOnApplyWindowInsetsListener(null);
return;
}
return;
}
View.OnApplyWindowInsetsListener tz_ = tz_(view, callback);
view.setTag(KtR.Sts.tag_window_insets_animation_callback, tz_);
if (tag == null) {
view.setOnApplyWindowInsetsListener(tz_);
}
}
private static View.OnApplyWindowInsetsListener tz_(View view, Callback callback) {
return new Sts(view, callback);
}
static HBt d(WindowInsetsCompat windowInsetsCompat, WindowInsetsCompat windowInsetsCompat2, int i) {
Rmc c = windowInsetsCompat.c(i);
Rmc c2 = windowInsetsCompat2.c(i);
return new HBt(Rmc.e(Math.min(c.a, c2.a), Math.min(c.b, c2.b), Math.min(c.d, c2.d), Math.min(c.e, c2.e)), Rmc.e(Math.max(c.a, c2.a), Math.max(c.b, c2.b), Math.max(c.d, c2.d), Math.max(c.e, c2.e)));
}
static int b(WindowInsetsCompat windowInsetsCompat, WindowInsetsCompat windowInsetsCompat2) {
int i = 0;
for (int i2 = 1; i2 <= 256; i2 <<= 1) {
if (!windowInsetsCompat.c(i2).equals(windowInsetsCompat2.c(i2))) {
i |= i2;
}
}
return i;
}
static WindowInsetsCompat c(WindowInsetsCompat windowInsetsCompat, WindowInsetsCompat windowInsetsCompat2, float f, int i) {
WindowInsetsCompat.Sts sts = new WindowInsetsCompat.Sts(windowInsetsCompat);
for (int i2 = 1; i2 <= 256; i2 <<= 1) {
if ((i & i2) == 0) {
sts.c(i2, windowInsetsCompat.c(i2));
} else {
Rmc c = windowInsetsCompat.c(i2);
Rmc c2 = windowInsetsCompat2.c(i2);
float f2 = 1.0f - f;
sts.c(i2, WindowInsetsCompat.b(c, (int) (((c.a - c2.a) * f2) + 0.5d), (int) (((c.b - c2.b) * f2) + 0.5d), (int) (((c.d - c2.d) * f2) + 0.5d), (int) (((c.e - c2.e) * f2) + 0.5d)));
}
}
return sts.a();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class Sts implements View.OnApplyWindowInsetsListener {
final Callback b;
private WindowInsetsCompat d;
Sts(View view, Callback callback) {
this.b = callback;
WindowInsetsCompat t = ViewCompat.t(view);
this.d = t != null ? new WindowInsetsCompat.Sts(t).a() : null;
}
@Override // android.view.View.OnApplyWindowInsetsListener
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
if (!view.isLaidOut()) {
this.d = WindowInsetsCompat.tH_(windowInsets, view);
return LWm.tB_(view, windowInsets);
}
WindowInsetsCompat tH_ = WindowInsetsCompat.tH_(windowInsets, view);
if (this.d == null) {
this.d = ViewCompat.t(view);
}
if (this.d == null) {
this.d = tH_;
return LWm.tB_(view, windowInsets);
}
Callback c = LWm.c(view);
if (c != null && Objects.equals(c.d, windowInsets)) {
return LWm.tB_(view, windowInsets);
}
int b = LWm.b(tH_, this.d);
if (b == 0) {
return LWm.tB_(view, windowInsets);
}
WindowInsetsCompat windowInsetsCompat = this.d;
WindowInsetsAnimationCompat windowInsetsAnimationCompat = new WindowInsetsAnimationCompat(b, new DecelerateInterpolator(), 160L);
windowInsetsAnimationCompat.e(BitmapDescriptorFactory.HUE_RED);
ValueAnimator duration = ValueAnimator.ofFloat(BitmapDescriptorFactory.HUE_RED, 1.0f).setDuration(windowInsetsAnimationCompat.c());
HBt d = LWm.d(tH_, windowInsetsCompat, b);
LWm.tA_(view, windowInsetsAnimationCompat, windowInsets, false);
duration.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(this, windowInsetsAnimationCompat, tH_, windowInsetsCompat, b, view) { // from class: androidx.core.view.WindowInsetsAnimationCompat.LWm.Sts.3
final int a;
final WindowInsetsAnimationCompat b;
final WindowInsetsCompat c;
final Sts d;
final WindowInsetsCompat e;
final View g;
{
this.d = this;
this.b = windowInsetsAnimationCompat;
this.e = tH_;
this.c = windowInsetsCompat;
this.a = b;
this.g = view;
}
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
this.b.e(valueAnimator.getAnimatedFraction());
LWm.b(this.g, LWm.c(this.e, this.c, this.b.a(), this.a), Collections.singletonList(this.b));
}
});
duration.addListener(new AnimatorListenerAdapter(this, windowInsetsAnimationCompat, view) { // from class: androidx.core.view.WindowInsetsAnimationCompat.LWm.Sts.4
final Sts a;
final View d;
final WindowInsetsAnimationCompat e;
{
this.a = this;
this.e = windowInsetsAnimationCompat;
this.d = view;
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
this.e.e(1.0f);
LWm.b(this.d, this.e);
}
});
ViewTreeObserverOnPreDrawListenerC17759zYL.c(view, new Runnable(this, view, windowInsetsAnimationCompat, d, duration) { // from class: androidx.core.view.WindowInsetsAnimationCompat.LWm.Sts.2
final View a;
final ValueAnimator b;
final Sts c;
final HBt d;
final WindowInsetsAnimationCompat e;
{
this.c = this;
this.a = view;
this.e = windowInsetsAnimationCompat;
this.d = d;
this.b = duration;
}
@Override // java.lang.Runnable
public void run() {
LWm.e(this.a, this.e, this.d);
this.b.start();
}
});
this.d = tH_;
return LWm.tB_(view, windowInsets);
}
}
static WindowInsets tB_(View view, WindowInsets windowInsets) {
return view.getTag(KtR.Sts.tag_on_apply_window_listener) != null ? windowInsets : view.onApplyWindowInsets(windowInsets);
}
static void tA_(View view, WindowInsetsAnimationCompat windowInsetsAnimationCompat, WindowInsets windowInsets, boolean z) {
Callback c = c(view);
if (c != null) {
c.d = windowInsets;
if (!z) {
c.c(windowInsetsAnimationCompat);
z = c.c() == 0;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
tA_(viewGroup.getChildAt(i), windowInsetsAnimationCompat, windowInsets, z);
}
}
}
static void e(View view, WindowInsetsAnimationCompat windowInsetsAnimationCompat, HBt hBt) {
Callback c = c(view);
if (c != null) {
c.b(windowInsetsAnimationCompat, hBt);
if (c.c() == 0) {
return;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
e(viewGroup.getChildAt(i), windowInsetsAnimationCompat, hBt);
}
}
}
static void b(View view, WindowInsetsCompat windowInsetsCompat, List<WindowInsetsAnimationCompat> list) {
Callback c = c(view);
if (c != null) {
windowInsetsCompat = c.e(windowInsetsCompat, list);
if (c.c() == 0) {
return;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
b(viewGroup.getChildAt(i), windowInsetsCompat, list);
}
}
}
static void b(View view, WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
Callback c = c(view);
if (c != null) {
c.a(windowInsetsAnimationCompat);
if (c.c() == 0) {
return;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
b(viewGroup.getChildAt(i), windowInsetsAnimationCompat);
}
}
}
static Callback c(View view) {
Object tag = view.getTag(KtR.Sts.tag_window_insets_animation_callback);
if (tag instanceof Sts) {
return ((Sts) tag).b;
}
return null;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class RVV extends IeS {
private final WindowInsetsAnimation a;
RVV(WindowInsetsAnimation windowInsetsAnimation) {
super(0, null, 0L);
this.a = windowInsetsAnimation;
}
RVV(int i, Interpolator interpolator, long j) {
this(new WindowInsetsAnimation(i, interpolator, j));
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.IeS
public int a() {
return this.a.getTypeMask();
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.IeS
public long b() {
return this.a.getDurationMillis();
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.IeS
public void c(float f) {
this.a.setFraction(f);
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.IeS
public float c() {
return this.a.getInterpolatedFraction();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class IeS extends WindowInsetsAnimation.Callback {
private final Callback a;
private List<WindowInsetsAnimationCompat> b;
private ArrayList<WindowInsetsAnimationCompat> c;
private final HashMap<WindowInsetsAnimation, WindowInsetsAnimationCompat> e;
IeS(Callback callback) {
super(callback.c());
this.e = new HashMap<>();
this.a = callback;
}
private WindowInsetsAnimationCompat tF_(WindowInsetsAnimation windowInsetsAnimation) {
WindowInsetsAnimationCompat windowInsetsAnimationCompat = this.e.get(windowInsetsAnimation);
if (windowInsetsAnimationCompat != null) {
return windowInsetsAnimationCompat;
}
WindowInsetsAnimationCompat tw_ = WindowInsetsAnimationCompat.tw_(windowInsetsAnimation);
this.e.put(windowInsetsAnimation, tw_);
return tw_;
}
@Override // android.view.WindowInsetsAnimation.Callback
public void onPrepare(WindowInsetsAnimation windowInsetsAnimation) {
this.a.c(tF_(windowInsetsAnimation));
}
@Override // android.view.WindowInsetsAnimation.Callback
public WindowInsetsAnimation.Bounds onStart(WindowInsetsAnimation windowInsetsAnimation, WindowInsetsAnimation.Bounds bounds) {
return this.a.b(tF_(windowInsetsAnimation), HBt.tx_(bounds)).ty_();
}
@Override // android.view.WindowInsetsAnimation.Callback
public WindowInsets onProgress(WindowInsets windowInsets, List<WindowInsetsAnimation> list) {
ArrayList<WindowInsetsAnimationCompat> arrayList = this.c;
if (arrayList == null) {
ArrayList<WindowInsetsAnimationCompat> arrayList2 = new ArrayList<>(list.size());
this.c = arrayList2;
this.b = Collections.unmodifiableList(arrayList2);
} else {
arrayList.clear();
}
for (int size = list.size() - 1; size >= 0; size--) {
WindowInsetsAnimation windowInsetsAnimation = list.get(size);
WindowInsetsAnimationCompat tF_ = tF_(windowInsetsAnimation);
tF_.e(windowInsetsAnimation.getFraction());
this.c.add(tF_);
}
return this.a.e(WindowInsetsCompat.tG_(windowInsets), this.b).tI_();
}
@Override // android.view.WindowInsetsAnimation.Callback
public void onEnd(WindowInsetsAnimation windowInsetsAnimation) {
this.a.a(tF_(windowInsetsAnimation));
this.e.remove(windowInsetsAnimation);
}
}
public static void e(View view, Callback callback) {
view.setWindowInsetsAnimationCallback(callback != null ? new IeS(callback) : null);
}
public static WindowInsetsAnimation.Bounds tC_(HBt hBt) {
Rmc b = hBt.b();
Insets oD_ = Rmc.IeS.oD_(b.a, b.b, b.d, b.e);
Rmc c = hBt.c();
return new WindowInsetsAnimation.Bounds(oD_, Rmc.IeS.oD_(c.a, c.b, c.d, c.e));
}
public static Rmc tE_(WindowInsetsAnimation.Bounds bounds) {
return Rmc.oC_(bounds.getLowerBound());
}
public static Rmc tD_(WindowInsetsAnimation.Bounds bounds) {
return Rmc.oC_(bounds.getUpperBound());
}
}
}