package xj; import android.animation.Animator; import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; import android.util.DisplayMetrics; import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.WindowManager; import android.view.animation.LinearInterpolator; import com.google.android.gms.common.GoogleApiAvailabilityLight; import com.xingin.alioth.R$anim; import com.xingin.utils.async.run.task.XYRunnable; import java.util.Objects; import kotlin.Metadata; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import t10.m0; import wj.m; @Metadata(bv = {}, d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\u0007\n\u0002\b\u0007\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\f\u0018\u00002\u00020\u0001:\u0004\u001f !\"B\u000f\u0012\u0006\u0010\u001c\u001a\u00020\u0011¢\u0006\u0004\b\u001d\u0010\u001eJ\b\u0010\u0003\u001a\u00020\u0002H\u0002J\b\u0010\u0004\u001a\u00020\u0002H\u0002J\b\u0010\u0005\u001a\u00020\u0002H\u0002J\u0010\u0010\b\u001a\u00020\u00022\u0006\u0010\u0007\u001a\u00020\u0006H\u0002J\b\u0010\t\u001a\u00020\u0002H\u0002J\u0018\u0010\f\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u0006H\u0002J\b\u0010\r\u001a\u00020\u0002H\u0002J\u0010\u0010\u0010\u001a\u00020\u00022\u0006\u0010\u000f\u001a\u00020\u000eH\u0002J\u0010\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u0012\u001a\u00020\u0011H\u0002J\u000e\u0010\u0018\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u0015R\u0014\u0010\u001b\u001a\u00020\u00178BX\u0004¢\u0006\u0006\u001a\u0004\b\u0019\u0010\u001a¨\u0006#"}, d2 = {"Lxj/e0;", "", "", GoogleApiAvailabilityLight.TRACKING_SOURCE_NOTIFICATION, "y", "o", "", "currentY", com.igexin.push.core.d.c.f25536c, "v", "transX", "transY", "z", "w", "", "msg", "u", "Landroid/content/Context;", "context", "", "r", "Landroid/view/MotionEvent;", "event", "", "s", "t", "()Z", "isInvalidTouch", "mContext", "<init>", "(Landroid/content/Context;)V", "a", "b", "c", "d", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public final class e0 { public static final b A = new b(null); /* renamed from: a reason: collision with root package name */ public final Context f154799a; /* renamed from: b reason: collision with root package name */ public final ViewConfiguration f154800b; /* renamed from: c reason: collision with root package name */ public int f154801c = 500; /* renamed from: d reason: collision with root package name */ public float f154802d = 0.4f; /* renamed from: e reason: collision with root package name */ public boolean f154803e; /* renamed from: f reason: collision with root package name */ public float f154804f = -1.0f; /* renamed from: g reason: collision with root package name */ public float f154805g = -1.0f; /* renamed from: h reason: collision with root package name */ public float f154806h = -1.0f; /* renamed from: i reason: collision with root package name */ public float f154807i = -1.0f; /* renamed from: j reason: collision with root package name */ public int f154808j; /* renamed from: k reason: collision with root package name */ public float f154809k; /* renamed from: l reason: collision with root package name */ public float f154810l; /* renamed from: m reason: collision with root package name */ public float f154811m; /* renamed from: n reason: collision with root package name */ public float f154812n; /* renamed from: o reason: collision with root package name */ public boolean f154813o; /* renamed from: p reason: collision with root package name */ public boolean f154814p; /* renamed from: q reason: collision with root package name */ public final int f154815q; /* renamed from: r reason: collision with root package name */ public final int f154816r; /* renamed from: s reason: collision with root package name */ public View f154817s; /* renamed from: t reason: collision with root package name */ public View f154818t; /* renamed from: u reason: collision with root package name */ public c f154819u; /* renamed from: v reason: collision with root package name */ public a f154820v; /* renamed from: w reason: collision with root package name */ public boolean f154821w; /* renamed from: x reason: collision with root package name */ public boolean f154822x; /* renamed from: y reason: collision with root package name */ public boolean f154823y; /* renamed from: z reason: collision with root package name */ public d f154824z; @Metadata(bv = {}, d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\bf\u0018\u00002\u00020\u0001J\u001a\u0010\u0007\u001a\u00020\u00062\b\u0010\u0003\u001a\u0004\u0018\u00010\u00022\u0006\u0010\u0005\u001a\u00020\u0004H&¨\u0006\b"}, d2 = {"Lxj/e0$a;", "", "Landroid/view/View;", qo2.a.COPY_LINK_TYPE_VIEW, "", "isLongClick", "", "a", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public interface a { void a(View view, boolean z14); } @Metadata(bv = {}, d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0002\b\u0005\b\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u000b\u0010\fR\u0014\u0010\u0003\u001a\u00020\u00028\u0002XT¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004R\u0014\u0010\u0006\u001a\u00020\u00058\u0002XT¢\u0006\u0006\n\u0004\b\u0006\u0010\u0007R\u0014\u0010\t\u001a\u00020\b8\u0002XT¢\u0006\u0006\n\u0004\b\t\u0010\n¨\u0006\r"}, d2 = {"Lxj/e0$b;", "", "", "DURATION", "J", "", "MAX_EXIT_Y", "I", "", "MIN_SCALE", "F", "<init>", "()V", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public static final class b { public b() { } public /* synthetic */ b(DefaultConstructorMarker defaultConstructorMarker) { this(); } } @Metadata(bv = {}, d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0007\n\u0002\b\u0006\bf\u0018\u00002\u00020\u0001J\b\u0010\u0003\u001a\u00020\u0002H&J\b\u0010\u0005\u001a\u00020\u0004H&J\u0010\u0010\b\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u0006H&J\b\u0010\t\u001a\u00020\u0004H&J\u0010\u0010\u000b\u001a\u00020\u00042\u0006\u0010\n\u001a\u00020\u0002H&¨\u0006\f"}, d2 = {"Lxj/e0$c;", "", "", "c", "", "a", "", "percent", "d", "b", "isShareElementMode", "e", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public interface c { void a(); void b(); boolean c(); void d(float f14); void e(boolean z14); } @Metadata(bv = {}, d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0004\b\u0004\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0004\u0010\u0005J\b\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\u0006"}, d2 = {"Lxj/e0$d;", "Lcom/xingin/utils/async/run/task/XYRunnable;", "", "execute", "<init>", "(Lxj/e0;)V", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public final class d extends XYRunnable { /* JADX WARN: Incorrect args count in method signature: ()V */ public d() { super("DragHelper", null, 2, null); } @Override // com.xingin.utils.async.run.task.XYRunnable public void execute() { if (e0.this.f154822x && e0.this.f154820v != null) { a aVar = e0.this.f154820v; if (aVar != null) { aVar.a(e0.this.f154818t, true); } e0.this.f154823y = true; } } } @Metadata(bv = {}, d1 = {"\u0000\u0017\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0005*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\u0006\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\u0007\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\b\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\t"}, d2 = {"xj/e0$e", "Landroid/animation/Animator$AnimatorListener;", "Landroid/animation/Animator;", "animation", "", "onAnimationStart", "onAnimationEnd", "onAnimationCancel", "onAnimationRepeat", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public static final class e implements Animator.AnimatorListener { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ e0 f154826a; public e(e0 e0Var) { this.f154826a = e0Var; } public void onAnimationCancel(Animator animator) { Intrinsics.checkNotNullParameter(animator, "animation"); } public void onAnimationEnd(Animator animator) { c cVar; Intrinsics.checkNotNullParameter(animator, "animation"); if (!(this.f154826a.f154819u == null || (cVar = this.f154826a.f154819u) == null)) { cVar.e(false); } ((Activity) this.f154826a.f154799a).finish(); ((Activity) this.f154826a.f154799a).overridePendingTransition(R$anim.f38136alioth_anim_empty, R$anim.f38135alioth_anim_alpha_out_long_time); } public void onAnimationRepeat(Animator animator) { Intrinsics.checkNotNullParameter(animator, "animation"); } public void onAnimationStart(Animator animator) { Intrinsics.checkNotNullParameter(animator, "animation"); } } @Metadata(bv = {}, d1 = {"\u0000\u0017\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0005*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\u0006\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\u0007\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\b\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\t"}, d2 = {"xj/e0$f", "Landroid/animation/Animator$AnimatorListener;", "Landroid/animation/Animator;", "animation", "", "onAnimationStart", "onAnimationEnd", "onAnimationCancel", "onAnimationRepeat", "alioth_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: DragCloseHelper.kt */ public static final class f implements Animator.AnimatorListener { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ e0 f154827a; public f(e0 e0Var) { this.f154827a = e0Var; } public void onAnimationCancel(Animator animator) { Intrinsics.checkNotNullParameter(animator, "animation"); } public void onAnimationEnd(Animator animator) { c cVar; Drawable background; Intrinsics.checkNotNullParameter(animator, "animation"); if (this.f154827a.f154813o) { View view = this.f154827a.f154817s; Drawable mutate = (view == null || (background = view.getBackground()) == null) ? null : background.mutate(); if (mutate != null) { mutate.setAlpha(255); } this.f154827a.f154809k = 0.0f; this.f154827a.f154810l = 0.0f; this.f154827a.f154813o = false; if (this.f154827a.f154819u != null && (cVar = this.f154827a.f154819u) != null) { cVar.b(); } } } public void onAnimationRepeat(Animator animator) { Intrinsics.checkNotNullParameter(animator, "animation"); } public void onAnimationStart(Animator animator) { Intrinsics.checkNotNullParameter(animator, "animation"); this.f154827a.f154813o = true; } } public e0(Context context) { Intrinsics.checkNotNullParameter(context, "mContext"); this.f154799a = context; ViewConfiguration viewConfiguration = ViewConfiguration.get(context); Intrinsics.checkNotNullExpressionValue(viewConfiguration, "get(mContext)"); this.f154800b = viewConfiguration; this.f154815q = m0.f132115a.p(context); this.f154816r = r(context); } public static final void q(e0 e0Var, ValueAnimator valueAnimator) { Intrinsics.checkNotNullParameter(e0Var, "this$0"); Intrinsics.checkNotNullParameter(valueAnimator, "animation"); float f14 = e0Var.f154810l; Object animatedValue = valueAnimator.getAnimatedValue(); Objects.requireNonNull(animatedValue, "null cannot be cast to non-null type kotlin.Float"); e0Var.z(f14, ((Float) animatedValue).floatValue()); } public static final void x(e0 e0Var, float f14, ValueAnimator valueAnimator) { Intrinsics.checkNotNullParameter(e0Var, "this$0"); Intrinsics.checkNotNullParameter(valueAnimator, "valueAnimator"); if (e0Var.f154813o) { Object animatedValue = valueAnimator.getAnimatedValue(); Objects.requireNonNull(animatedValue, "null cannot be cast to non-null type kotlin.Float"); float floatValue = ((Float) animatedValue).floatValue(); e0Var.f154809k = floatValue; float f15 = f14 * floatValue; e0Var.f154810l = f15; e0Var.f154811m = floatValue; e0Var.f154812n = f15; e0Var.z(f15, floatValue); } } public final void n() { this.f154823y = false; if (this.f154824z == null) { this.f154824z = new d(); } View view = this.f154817s; if (view != null) { view.postDelayed(this.f154824z, (long) ViewConfiguration.getLongPressTimeout()); } } public final void o() { if (this.f154822x) { if (!this.f154823y) { View view = this.f154817s; if (view != null) { view.removeCallbacks(this.f154824z); } a aVar = this.f154820v; if (!(aVar == null || aVar == null)) { aVar.a(this.f154818t, false); } } this.f154822x = false; } } public final void p(float f14) { int i10; if (f14 > 0.0f) { View view = this.f154818t; i10 = view != null ? view.getHeight() : 0; } else { View view2 = this.f154818t; i10 = -(view2 != null ? view2.getHeight() : 0); } ValueAnimator ofFloat = ValueAnimator.ofFloat(this.f154809k, (float) i10); ofFloat.addUpdateListener(new c0(this)); ofFloat.addListener(new e(this)); ofFloat.setDuration(100L); ofFloat.setInterpolator(new LinearInterpolator()); ofFloat.start(); } public final int r(Context context) { Object systemService = context.getSystemService("window"); Objects.requireNonNull(systemService, "null cannot be cast to non-null type android.view.WindowManager"); Display defaultDisplay = ((WindowManager) systemService).getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); try { Class<?> cls = Class.forName("android.view.Display"); Intrinsics.checkNotNullExpressionValue(cls, "forName(\"android.view.Display\")"); cls.getMethod("getRealMetrics", DisplayMetrics.class).invoke(defaultDisplay, displayMetrics); return displayMetrics.heightPixels; } catch (Exception e14) { e14.printStackTrace(); return 0; } } public final boolean s(MotionEvent motionEvent) { Drawable background; Intrinsics.checkNotNullParameter(motionEvent, "event"); int i10 = 0; if (motionEvent.getPointerCount() <= 1) { c cVar = this.f154819u; if (cVar != null) { if (cVar != null && cVar.c()) { u("action dispatch--->"); if (this.f154820v != null) { int action = motionEvent.getAction(); if (action == 0) { this.f154822x = true; n(); } else if (action == 1) { o(); } else if (action == 3) { y(); } } this.f154803e = false; return false; } } if (motionEvent.getAction() == 0) { u("action down--->"); v(); this.f154804f = motionEvent.getY(); this.f154806h = motionEvent.getX(); this.f154805g = motionEvent.getRawY(); this.f154807i = motionEvent.getRawX(); if (t()) { return true; } this.f154822x = true; n(); this.f154808j = motionEvent.getPointerId(0); } else if (motionEvent.getAction() == 2) { boolean z14 = this.f154803e; float f14 = this.f154805g; boolean t14 = t(); u("action move--->" + z14 + "---" + f14 + "---" + t14); if (t()) { return true; } if (this.f154805g == -1.0f) { return true; } if (this.f154808j != motionEvent.getPointerId(0)) { if (this.f154803e) { w(); } v(); return true; } float y14 = motionEvent.getY(); float x14 = motionEvent.getX(); if (this.f154803e || (Math.abs(y14 - this.f154804f) > ((float) (this.f154800b.getScaledTouchSlop() * 2)) && ((double) Math.abs(y14 - this.f154804f)) > ((double) Math.abs(x14 - this.f154806h)) * 1.5d)) { this.f154804f = y14; this.f154806h = x14; u("action move---> start close"); y(); float rawY = motionEvent.getRawY(); float rawX = motionEvent.getRawX(); if (!this.f154803e) { this.f154803e = true; c cVar2 = this.f154819u; if (!(cVar2 == null || cVar2 == null)) { cVar2.a(); } } float f15 = (rawY - this.f154805g) + this.f154811m; this.f154809k = f15; this.f154810l = (rawX - this.f154807i) + this.f154812n; float f16 = (float) 1; View view = this.f154818t; float abs = f16 - Math.abs(f15 / ((float) (view != null ? view.getHeight() : 0))); if (abs > 1.0f) { abs = 1.0f; } else if (abs < 0.0f) { abs = 0.0f; } View view2 = this.f154817s; Drawable mutate = (view2 == null || (background = view2.getBackground()) == null) ? null : background.mutate(); if (mutate != null) { mutate.setAlpha((int) (((float) 255) * abs)); } c cVar3 = this.f154819u; if (!(cVar3 == null || cVar3 == null)) { cVar3.d(abs); } float f17 = this.f154802d; if (abs < f17) { abs = f17; } float f18 = this.f154809k; if (f18 > 0.0f) { View view3 = this.f154818t; if (view3 != null) { if (view3 != null) { i10 = view3.getHeight(); } view3.setTranslationY(f18 - ((((float) (i10 - this.f154801c)) * (f16 - abs)) / ((float) 2))); } } else { View view4 = this.f154818t; if (view4 != null) { if (view4 != null) { i10 = view4.getHeight(); } view4.setTranslationY(f18 + ((((float) (i10 - this.f154801c)) * (f16 - abs)) / ((float) 2))); } } View view5 = this.f154818t; if (view5 != null) { view5.setTranslationX(this.f154810l); } View view6 = this.f154818t; if (view6 != null) { view6.setScaleX(abs); } View view7 = this.f154818t; if (view7 != null) { view7.setScaleY(abs); } return true; } } else if (motionEvent.getAction() == 1) { boolean z15 = this.f154803e; u("action up--->" + z15); if (t()) { return true; } this.f154805g = -1.0f; o(); if (this.f154803e) { float f19 = this.f154809k; if (f19 <= ((float) this.f154801c)) { w(); } else if (this.f154814p) { c cVar4 = this.f154819u; if (!(cVar4 == null || cVar4 == null)) { cVar4.e(true); } } else { p(f19); } this.f154803e = false; return true; } } else if (motionEvent.getAction() == 3) { y(); this.f154805g = -1.0f; if (this.f154803e) { w(); this.f154803e = false; return true; } } return false; } else if (this.f154803e) { this.f154803e = false; w(); return true; } else { v(); y(); return false; } } public final boolean t() { float f14 = this.f154805g; int i10 = this.f154815q; return f14 < ((float) i10) || f14 > ((float) (this.f154816r - (i10 * 2))); } public final void u(String str) { if (this.f154821w) { String name = e0.class.getName(); Intrinsics.checkNotNullExpressionValue(name, "javaClass.name"); m.b(name, str); } } public final void v() { this.f154803e = false; this.f154804f = -1.0f; this.f154806h = -1.0f; this.f154805g = -1.0f; this.f154807i = -1.0f; this.f154811m = 0.0f; this.f154812n = 0.0f; } public final void w() { if (!this.f154813o) { float f14 = this.f154809k; if (!(f14 == 0.0f)) { float f15 = this.f154810l / f14; ValueAnimator ofFloat = ValueAnimator.ofFloat(f14, 0.0f); ofFloat.addUpdateListener(new d0(this, f15)); ofFloat.addListener(new f(this)); ofFloat.setDuration(100L).start(); } } } public final void y() { View view = this.f154817s; if (view != null) { view.removeCallbacks(this.f154824z); } this.f154822x = false; this.f154823y = false; } public final void z(float f14, float f15) { View view = this.f154818t; int i10 = 0; float f16 = (float) 1; float abs = f16 - Math.abs(f15 / ((float) (view != null ? view.getHeight() : 0))); float f17 = this.f154802d; if (abs < f17) { abs = f17; } if (f15 > 0.0f) { View view2 = this.f154818t; if (view2 != null) { if (view2 != null) { i10 = view2.getHeight(); } view2.setTranslationY(f15 - ((((float) (i10 - this.f154801c)) * (f16 - abs)) / ((float) 2))); } } else { View view3 = this.f154818t; if (view3 != null) { if (view3 != null) { i10 = view3.getHeight(); } view3.setTranslationY(f15 + ((((float) (i10 - this.f154801c)) * (f16 - abs)) / ((float) 2))); } } View view4 = this.f154818t; if (view4 != null) { view4.setTranslationX(f14); } View view5 = this.f154818t; if (view5 != null) { view5.setScaleX(abs); } View view6 = this.f154818t; if (view6 != null) { view6.setScaleY(abs); } } }