package com.google.android.material.behavior; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.n0; import d0.c; /* loaded from: classes2.dex */ public class SwipeDismissBehavior extends CoordinatorLayout.b { /* renamed from: a, reason: collision with root package name */ c f4304a; /* renamed from: b, reason: collision with root package name */ private boolean f4305b; /* renamed from: d, reason: collision with root package name */ private boolean f4307d; /* renamed from: c, reason: collision with root package name */ private float f4306c = 0.0f; /* renamed from: e, reason: collision with root package name */ int f4308e = 2; /* renamed from: f, reason: collision with root package name */ float f4309f = 0.5f; /* renamed from: g, reason: collision with root package name */ float f4310g = 0.0f; /* renamed from: h, reason: collision with root package name */ float f4311h = 0.5f; /* renamed from: i, reason: collision with root package name */ private final c.AbstractC0132c f4312i = new a(); class a extends c.AbstractC0132c { /* renamed from: a, reason: collision with root package name */ private int f4313a; /* renamed from: b, reason: collision with root package name */ private int f4314b = -1; a() { } private boolean n(View view, float f10) { if (f10 == 0.0f) { return Math.abs(view.getLeft() - this.f4313a) >= Math.round(((float) view.getWidth()) * SwipeDismissBehavior.this.f4309f); } boolean z10 = n0.B(view) == 1; int i10 = SwipeDismissBehavior.this.f4308e; if (i10 == 2) { return true; } if (i10 == 0) { if (z10) { if (f10 >= 0.0f) { return false; } } else if (f10 <= 0.0f) { return false; } return true; } if (i10 != 1) { return false; } if (z10) { if (f10 <= 0.0f) { return false; } } else if (f10 >= 0.0f) { return false; } return true; } @Override // d0.c.AbstractC0132c public int a(View view, int i10, int i11) { int width; int width2; int width3; boolean z10 = n0.B(view) == 1; int i12 = SwipeDismissBehavior.this.f4308e; if (i12 == 0) { if (z10) { width = this.f4313a - view.getWidth(); width2 = this.f4313a; } else { width = this.f4313a; width3 = view.getWidth(); width2 = width3 + width; } } else if (i12 != 1) { width = this.f4313a - view.getWidth(); width2 = view.getWidth() + this.f4313a; } else if (z10) { width = this.f4313a; width3 = view.getWidth(); width2 = width3 + width; } else { width = this.f4313a - view.getWidth(); width2 = this.f4313a; } return SwipeDismissBehavior.G(width, i10, width2); } @Override // d0.c.AbstractC0132c public int b(View view, int i10, int i11) { return view.getTop(); } @Override // d0.c.AbstractC0132c public int d(View view) { return view.getWidth(); } @Override // d0.c.AbstractC0132c public void i(View view, int i10) { this.f4314b = i10; this.f4313a = view.getLeft(); ViewParent parent = view.getParent(); if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); } } @Override // d0.c.AbstractC0132c public void j(int i10) { SwipeDismissBehavior.this.getClass(); } @Override // d0.c.AbstractC0132c public void k(View view, int i10, int i11, int i12, int i13) { float width = this.f4313a + (view.getWidth() * SwipeDismissBehavior.this.f4310g); float width2 = this.f4313a + (view.getWidth() * SwipeDismissBehavior.this.f4311h); float f10 = i10; if (f10 <= width) { view.setAlpha(1.0f); } else if (f10 >= width2) { view.setAlpha(0.0f); } else { view.setAlpha(SwipeDismissBehavior.F(0.0f, 1.0f - SwipeDismissBehavior.I(width, width2, f10), 1.0f)); } } @Override // d0.c.AbstractC0132c public void l(View view, float f10, float f11) { int i10; boolean z10; this.f4314b = -1; int width = view.getWidth(); if (n(view, f10)) { int left = view.getLeft(); int i11 = this.f4313a; i10 = left < i11 ? i11 - width : i11 + width; z10 = true; } else { i10 = this.f4313a; z10 = false; } if (SwipeDismissBehavior.this.f4304a.F(i10, view.getTop())) { n0.f0(view, new b(view, z10)); } else if (z10) { SwipeDismissBehavior.this.getClass(); } } @Override // d0.c.AbstractC0132c public boolean m(View view, int i10) { int i11 = this.f4314b; return (i11 == -1 || i11 == i10) && SwipeDismissBehavior.this.E(view); } } private class b implements Runnable { /* renamed from: a, reason: collision with root package name */ private final View f4316a; /* renamed from: b, reason: collision with root package name */ private final boolean f4317b; b(View view, boolean z10) { this.f4316a = view; this.f4317b = z10; } @Override // java.lang.Runnable public void run() { c cVar = SwipeDismissBehavior.this.f4304a; if (cVar != null && cVar.k(true)) { n0.f0(this.f4316a, this); } else if (this.f4317b) { SwipeDismissBehavior.this.getClass(); } } } static float F(float f10, float f11, float f12) { return Math.min(Math.max(f10, f11), f12); } static int G(int i10, int i11, int i12) { return Math.min(Math.max(i10, i11), i12); } private void H(ViewGroup viewGroup) { if (this.f4304a == null) { this.f4304a = this.f4307d ? c.l(viewGroup, this.f4306c, this.f4312i) : c.m(viewGroup, this.f4312i); } } static float I(float f10, float f11, float f12) { return (f12 - f10) / (f11 - f10); } @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.b public boolean D(CoordinatorLayout coordinatorLayout, View view, MotionEvent motionEvent) { c cVar = this.f4304a; if (cVar == null) { return false; } cVar.z(motionEvent); return true; } public boolean E(View view) { return true; } public void J(float f10) { this.f4311h = F(0.0f, f10, 1.0f); } public void K(float f10) { this.f4310g = F(0.0f, f10, 1.0f); } public void L(int i10) { this.f4308e = i10; } @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.b public boolean k(CoordinatorLayout coordinatorLayout, View view, MotionEvent motionEvent) { boolean z10 = this.f4305b; int actionMasked = motionEvent.getActionMasked(); if (actionMasked == 0) { z10 = coordinatorLayout.z(view, (int) motionEvent.getX(), (int) motionEvent.getY()); this.f4305b = z10; } else if (actionMasked == 1 || actionMasked == 3) { this.f4305b = false; } if (!z10) { return false; } H(coordinatorLayout); return this.f4304a.G(motionEvent); } }