package o; import android.content.Context; import android.content.res.TypedArray; import android.database.DataSetObserver; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.LinearLayout; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.PopupWindow; import androidx.appcompat.widget.DropDownListView; import androidx.core.view.ViewCompat; import java.lang.reflect.Method; import o.SYO; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* renamed from: o.jAy, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public class C15846jAy implements AZJ { private static Method d; private static Method e; private boolean A; private boolean B; private View C; private int D; private final Rect E; private Runnable F; private final jbe H; private final Sts I; final Handler a; DropDownListView b; int c; public PopupWindow f; private boolean g; private ListAdapter h; private Context i; final ZqN j; private View k; private int l; private int m; private int n; /* renamed from: o, reason: collision with root package name */ private Drawable f9179o; private int p; private Rect q; private int r; private boolean s; private int t; private AdapterView.OnItemClickListener u; private boolean v; private final RVV w; private AdapterView.OnItemSelectedListener x; private boolean y; private DataSetObserver z; static { if (Build.VERSION.SDK_INT <= 28) { try { d = PopupWindow.class.getDeclaredMethod("setClipToScreenEnabled", Boolean.TYPE); } catch (NoSuchMethodException unused) { } try { e = PopupWindow.class.getDeclaredMethod("setEpicenterBounds", Rect.class); } catch (NoSuchMethodException unused2) { } } } public C15846jAy(Context context) { this(context, null, SYO.IeS.listPopupWindowStyle); } public C15846jAy(Context context, AttributeSet attributeSet) { this(context, attributeSet, SYO.IeS.listPopupWindowStyle); } public C15846jAy(Context context, AttributeSet attributeSet, int i) { this(context, attributeSet, i, 0); } public C15846jAy(Context context, AttributeSet attributeSet, int i, int i2) { this.m = -2; this.r = -2; this.p = 1002; this.n = 0; this.g = false; this.v = false; this.c = Integer.MAX_VALUE; this.D = 0; this.j = new ZqN(this); this.H = new jbe(this); this.I = new Sts(this); this.w = new RVV(this); this.E = new Rect(); this.i = context; this.a = new Handler(context.getMainLooper()); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, SYO.ZqN.ListPopupWindow, i, i2); this.l = obtainStyledAttributes.getDimensionPixelOffset(SYO.ZqN.ListPopupWindow_android_dropDownHorizontalOffset, 0); int dimensionPixelOffset = obtainStyledAttributes.getDimensionPixelOffset(SYO.ZqN.ListPopupWindow_android_dropDownVerticalOffset, 0); this.t = dimensionPixelOffset; if (dimensionPixelOffset != 0) { this.s = true; } obtainStyledAttributes.recycle(); rZU rzu = new rZU(context, attributeSet, i, i2); this.f = rzu; rzu.setInputMethodMode(1); } public void iu_(ListAdapter listAdapter) { DataSetObserver dataSetObserver = this.z; if (dataSetObserver == null) { this.z = new LWm(this); } else { ListAdapter listAdapter2 = this.h; if (listAdapter2 != null) { listAdapter2.unregisterDataSetObserver(dataSetObserver); } } this.h = listAdapter; if (listAdapter != null) { listAdapter.registerDataSetObserver(this.z); } DropDownListView dropDownListView = this.b; if (dropDownListView != null) { dropDownListView.setAdapter(this.h); } } public void c(boolean z) { this.y = z; this.f.setFocusable(z); } public Drawable is_() { return this.f.getBackground(); } public void iv_(Drawable drawable) { this.f.setBackgroundDrawable(drawable); } public void d(int i) { this.f.setAnimationStyle(i); } public void iw_(Rect rect) { this.q = rect != null ? new Rect(rect) : null; } public void a(int i) { Drawable background = this.f.getBackground(); if (background != null) { background.getPadding(this.E); this.r = this.E.left + this.E.right + i; } else { g(i); } } @Override // o.AZJ public void h() { int c = c(); boolean p = p(); C16030kbh.vJ_(this.f, this.p); boolean z = false; if (this.f.isShowing()) { if (ViewCompat.H(m())) { int i = this.r; if (i == -1) { i = -1; } else if (i == -2) { i = m().getWidth(); } int i2 = this.m; if (i2 == -1) { if (!p) { c = -1; } if (p) { this.f.setWidth(this.r == -1 ? -1 : 0); this.f.setHeight(0); } else { this.f.setWidth(this.r == -1 ? -1 : 0); this.f.setHeight(-1); } } else if (i2 != -2) { c = i2; } PopupWindow popupWindow = this.f; if (!this.v && !this.g) { z = true; } popupWindow.setOutsideTouchable(z); this.f.update(m(), this.l, this.t, i < 0 ? -1 : i, c < 0 ? -1 : c); return; } return; } int i3 = this.r; if (i3 == -1) { i3 = -1; } else if (i3 == -2) { i3 = m().getWidth(); } int i4 = this.m; if (i4 == -1) { c = -1; } else if (i4 != -2) { c = i4; } this.f.setWidth(i3); this.f.setHeight(c); b(true); this.f.setOutsideTouchable((this.v || this.g) ? false : true); this.f.setTouchInterceptor(this.H); if (this.B) { C16030kbh.vI_(this.f, this.A); } if (Build.VERSION.SDK_INT <= 28) { Method method = e; if (method != null) { try { method.invoke(this.f, this.q); } catch (Exception unused) { } } } else { HBt.iB_(this.f, this.q); } C16030kbh.vK_(this.f, m(), this.l, this.t, this.n); this.b.setSelection(-1); if (!this.y || this.b.isInTouchMode()) { i(); } if (this.y) { return; } this.a.post(this.w); } @Override // o.AZJ public void b() { this.f.dismiss(); g(); this.f.setContentView(null); this.b = null; this.a.removeCallbacks(this.j); } public void ix_(PopupWindow.OnDismissListener onDismissListener) { this.f.setOnDismissListener(onDismissListener); } private void g() { View view = this.C; if (view != null) { ViewParent parent = view.getParent(); if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(this.C); } } } public void i(int i) { this.f.setInputMethodMode(i); } public void f(int i) { DropDownListView dropDownListView = this.b; if (!j() || dropDownListView == null) { return; } dropDownListView.e = false; dropDownListView.setSelection(i); if (dropDownListView.getChoiceMode() != 0) { dropDownListView.setItemChecked(i, true); } } @Override // o.AZJ public boolean j() { return this.f.isShowing(); } public boolean p() { return this.f.getInputMethodMode() == 2; } public Object o() { if (j()) { return this.b.getSelectedItem(); } return null; } public int n() { if (j()) { return this.b.getSelectedItemPosition(); } return -1; } public long l() { if (j()) { return this.b.getSelectedItemId(); } return Long.MIN_VALUE; } public View k() { if (j()) { return this.b.getSelectedView(); } return null; } protected DropDownListView e(Context context, boolean z) { return new DropDownListView(context, z); } private int c() { int i; int i2; int makeMeasureSpec; int i3; if (this.b == null) { Context context = this.i; this.F = new Runnable(this) { // from class: o.jAy.3 final C15846jAy c; { this.c = this; } @Override // java.lang.Runnable public final void run() { View m = this.c.m(); if (m == null || m.getWindowToken() == null) { return; } this.c.h(); } }; DropDownListView e2 = e(context, !this.y); this.b = e2; Drawable drawable = this.f9179o; if (drawable != null) { e2.setSelector(drawable); } this.b.setAdapter(this.h); this.b.setOnItemClickListener(this.u); this.b.setFocusable(true); this.b.setFocusableInTouchMode(true); this.b.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(this) { // from class: o.jAy.5 final C15846jAy d; @Override // android.widget.AdapterView.OnItemSelectedListener public final void onNothingSelected(AdapterView adapterView) { } { this.d = this; } @Override // android.widget.AdapterView.OnItemSelectedListener public final void onItemSelected(AdapterView adapterView, View view, int i4, long j) { DropDownListView dropDownListView; if (i4 == -1 || (dropDownListView = this.d.b) == null) { return; } dropDownListView.e = false; } }); this.b.setOnScrollListener(this.I); AdapterView.OnItemSelectedListener onItemSelectedListener = this.x; if (onItemSelectedListener != null) { this.b.setOnItemSelectedListener(onItemSelectedListener); } View view = this.b; View view2 = this.C; if (view2 != null) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(1); ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, 0, 1.0f); int i4 = this.D; if (i4 == 0) { linearLayout.addView(view2); linearLayout.addView(view, layoutParams); } else if (i4 == 1) { linearLayout.addView(view, layoutParams); linearLayout.addView(view2); } int i5 = this.r; if (i5 >= 0) { i3 = Integer.MIN_VALUE; } else { i5 = 0; i3 = 0; } view2.measure(View.MeasureSpec.makeMeasureSpec(i5, i3), 0); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) view2.getLayoutParams(); i = view2.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams2).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams2).bottomMargin; view = linearLayout; } else { i = 0; } this.f.setContentView(view); } else { View view3 = this.C; if (view3 != null) { LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) view3.getLayoutParams(); i = view3.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams3).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams3).bottomMargin; } else { i = 0; } } Drawable background = this.f.getBackground(); if (background != null) { background.getPadding(this.E); i2 = this.E.top + this.E.bottom; if (!this.s) { this.t = -this.E.top; } } else { this.E.setEmpty(); i2 = 0; } int c = c(m(), this.t, this.f.getInputMethodMode() == 2); if (this.g || this.m == -1) { return c + i2; } int i6 = this.r; if (i6 == -2) { makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(this.i.getResources().getDisplayMetrics().widthPixels - (this.E.left + this.E.right), PKIFailureInfo.systemUnavail); } else if (i6 == -1) { makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(this.i.getResources().getDisplayMetrics().widthPixels - (this.E.left + this.E.right), 1073741824); } else { makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i6, 1073741824); } int e3 = this.b.e(makeMeasureSpec, 0, -1, c - i, -1); if (e3 > 0) { i += i2 + this.b.getPaddingTop() + this.b.getPaddingBottom(); } return e3 + i; } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$LWm */ /* loaded from: classes.dex */ public class LWm extends DataSetObserver { final C15846jAy c; LWm(C15846jAy c15846jAy) { this.c = c15846jAy; } @Override // android.database.DataSetObserver public final void onChanged() { if (this.c.j()) { this.c.h(); } } @Override // android.database.DataSetObserver public final void onInvalidated() { this.c.b(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$RVV */ /* loaded from: classes.dex */ public class RVV implements Runnable { final C15846jAy c; RVV(C15846jAy c15846jAy) { this.c = c15846jAy; } @Override // java.lang.Runnable public final void run() { this.c.i(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$ZqN */ /* loaded from: classes.dex */ public class ZqN implements Runnable { final C15846jAy a; ZqN(C15846jAy c15846jAy) { this.a = c15846jAy; } @Override // java.lang.Runnable public final void run() { if (this.a.b == null || !ViewCompat.H(this.a.b) || this.a.b.getCount() <= this.a.b.getChildCount() || this.a.b.getChildCount() > this.a.c) { return; } this.a.f.setInputMethodMode(2); this.a.h(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$jbe */ /* loaded from: classes.dex */ public class jbe implements View.OnTouchListener { final C15846jAy c; jbe(C15846jAy c15846jAy) { this.c = c15846jAy; } @Override // android.view.View.OnTouchListener public final boolean onTouch(View view, MotionEvent motionEvent) { int action = motionEvent.getAction(); int x = (int) motionEvent.getX(); int y = (int) motionEvent.getY(); if (action == 0 && this.c.f != null && this.c.f.isShowing() && x >= 0 && x < this.c.f.getWidth() && y >= 0 && y < this.c.f.getHeight()) { this.c.a.postDelayed(this.c.j, 250L); return false; } if (action != 1) { return false; } this.c.a.removeCallbacks(this.c.j); return false; } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$Sts */ /* loaded from: classes.dex */ public class Sts implements AbsListView.OnScrollListener { final C15846jAy b; @Override // android.widget.AbsListView.OnScrollListener public final void onScroll(AbsListView absListView, int i, int i2, int i3) { } Sts(C15846jAy c15846jAy) { this.b = c15846jAy; } @Override // android.widget.AbsListView.OnScrollListener public final void onScrollStateChanged(AbsListView absListView, int i) { if (i != 1 || this.b.p() || this.b.f.getContentView() == null) { return; } this.b.a.removeCallbacks(this.b.j); this.b.j.run(); } } private void b(boolean z) { if (Build.VERSION.SDK_INT > 28) { HBt.iC_(this.f, z); return; } Method method = d; if (method != null) { try { method.invoke(this.f, Boolean.valueOf(z)); } catch (Exception unused) { } } } private int c(View view, int i, boolean z) { return IeS.iA_(this.f, view, i, z); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$HBt */ /* loaded from: classes.dex */ public static class HBt { static void iB_(PopupWindow popupWindow, Rect rect) { popupWindow.setEpicenterBounds(rect); } static void iC_(PopupWindow popupWindow, boolean z) { popupWindow.setIsClippedToScreen(z); } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.jAy$IeS */ /* loaded from: classes.dex */ public static class IeS { static int iA_(PopupWindow popupWindow, View view, int i, boolean z) { return popupWindow.getMaxAvailableHeight(view, i, z); } } public void i() { DropDownListView dropDownListView = this.b; if (dropDownListView != null) { dropDownListView.e = true; dropDownListView.requestLayout(); } } public void g(int i) { this.r = i; } public void c(int i) { this.t = i; this.s = true; } public void j(int i) { this.D = i; } public void e(boolean z) { this.B = true; this.A = z; } public void iz_(AdapterView.OnItemSelectedListener onItemSelectedListener) { this.x = onItemSelectedListener; } public void iy_(AdapterView.OnItemClickListener onItemClickListener) { this.u = onItemClickListener; } public void e(int i) { this.l = i; } public void h(int i) { this.n = i; } public void e(View view) { this.k = view; } public boolean t() { return this.y; } public int s() { return this.r; } public int e() { if (this.s) { return this.t; } return 0; } @Override // o.AZJ public ListView it_() { return this.b; } public int d() { return this.l; } public View m() { return this.k; } }