what-the-bank/sources/androidx/appcompat/widget/AppCompatSpinner.java

846 lines
27 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.appcompat.widget;
import android.R;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.database.DataSetObserver;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.ThemedSpinnerAdapter;
import androidx.core.view.ViewCompat;
import o.AgY;
import o.C15846jAy;
import o.DialogInterfaceC17187ufv;
import o.InterfaceC17151uNO;
import o.SYO;
import o.WpN;
import o.ZEY;
import o.mxt;
import o.nHL;
/* loaded from: classes.dex */
public class AppCompatSpinner extends Spinner {
private static final int[] b = {R.attr.spinnerMode};
private final WpN a;
private nHL c;
final Rect d;
int e;
private ojQ f;
private final Context g;
private final boolean h;
private SpinnerAdapter i;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public interface ojQ {
void b();
void b(int i);
CharSequence c();
void c(int i);
void c(int i, int i2);
int d();
int e();
void e(int i);
void e(CharSequence charSequence);
Drawable is_();
void iu_(ListAdapter listAdapter);
void iv_(Drawable drawable);
boolean j();
}
@Override // android.widget.AdapterView
public /* bridge */ /* synthetic */ void setAdapter(SpinnerAdapter spinnerAdapter) {
setAdapter(spinnerAdapter);
}
public AppCompatSpinner(Context context) {
this(context, null);
}
public AppCompatSpinner(Context context, AttributeSet attributeSet) {
this(context, attributeSet, SYO.IeS.spinnerStyle);
}
public AppCompatSpinner(Context context, AttributeSet attributeSet, int i) {
this(context, attributeSet, i, -1);
}
public AppCompatSpinner(Context context, AttributeSet attributeSet, int i, int i2) {
this(context, attributeSet, i, i2, null);
}
/* JADX WARN: Code restructure failed: missing block: B:27:0x0056, code lost:
if (r11 != null) goto L25;
*/
/* JADX WARN: Code restructure failed: missing block: B:28:0x0066, code lost:
r11.recycle();
*/
/* JADX WARN: Code restructure failed: missing block: B:30:0x0064, code lost:
if (r11 == null) goto L26;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public AppCompatSpinner(android.content.Context r7, android.util.AttributeSet r8, int r9, int r10, android.content.res.Resources.Theme r11) {
/*
Method dump skipped, instructions count: 242
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.AppCompatSpinner.<init>(android.content.Context, android.util.AttributeSet, int, int, android.content.res.Resources$Theme):void");
}
@Override // android.widget.Spinner
public void setPopupBackgroundDrawable(Drawable drawable) {
ojQ ojq = this.f;
if (ojq != null) {
ojq.iv_(drawable);
} else {
super.setPopupBackgroundDrawable(drawable);
}
}
@Override // android.widget.Spinner
public void setPopupBackgroundResource(int i) {
setPopupBackgroundDrawable(AgY.dT_(getPopupContext(), i));
}
@Override // android.widget.Spinner
public Drawable getPopupBackground() {
ojQ ojq = this.f;
if (ojq != null) {
return ojq.is_();
}
return super.getPopupBackground();
}
@Override // android.widget.Spinner
public void setDropDownVerticalOffset(int i) {
ojQ ojq = this.f;
if (ojq != null) {
ojq.c(i);
} else {
super.setDropDownVerticalOffset(i);
}
}
@Override // android.widget.Spinner
public int getDropDownVerticalOffset() {
ojQ ojq = this.f;
if (ojq != null) {
return ojq.e();
}
return super.getDropDownVerticalOffset();
}
@Override // android.widget.Spinner
public void setDropDownHorizontalOffset(int i) {
ojQ ojq = this.f;
if (ojq != null) {
ojq.b(i);
this.f.e(i);
} else {
super.setDropDownHorizontalOffset(i);
}
}
@Override // android.widget.Spinner
public int getDropDownHorizontalOffset() {
ojQ ojq = this.f;
if (ojq != null) {
return ojq.d();
}
return super.getDropDownHorizontalOffset();
}
@Override // android.widget.Spinner
public void setDropDownWidth(int i) {
if (this.f != null) {
this.e = i;
} else {
super.setDropDownWidth(i);
}
}
@Override // android.widget.Spinner
public int getDropDownWidth() {
return this.f != null ? this.e : super.getDropDownWidth();
}
@Override // android.widget.Spinner, android.widget.AbsSpinner
/* renamed from: setAdapter, reason: avoid collision after fix types in other method */
public void setAdapter2(SpinnerAdapter spinnerAdapter) {
if (!this.h) {
this.i = spinnerAdapter;
return;
}
super.setAdapter(spinnerAdapter);
if (this.f != null) {
Context context = this.g;
if (context == null) {
context = getContext();
}
this.f.iu_(new IeS(spinnerAdapter, context.getTheme()));
}
}
@Override // android.widget.Spinner, android.widget.AdapterView, android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
ojQ ojq = this.f;
if (ojq == null || !ojq.j()) {
return;
}
this.f.b();
}
@Override // android.widget.Spinner, android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
nHL nhl = this.c;
if (nhl == null || !nhl.onTouch(this, motionEvent)) {
return super.onTouchEvent(motionEvent);
}
return true;
}
@Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
if (this.f == null || View.MeasureSpec.getMode(i) != Integer.MIN_VALUE) {
return;
}
setMeasuredDimension(Math.min(Math.max(getMeasuredWidth(), gM_(getAdapter(), getBackground())), View.MeasureSpec.getSize(i)), getMeasuredHeight());
}
@Override // android.widget.Spinner, android.view.View
public boolean performClick() {
ojQ ojq = this.f;
if (ojq != null) {
if (ojq.j()) {
return true;
}
b();
return true;
}
return super.performClick();
}
@Override // android.widget.Spinner
public void setPrompt(CharSequence charSequence) {
ojQ ojq = this.f;
if (ojq != null) {
ojq.e(charSequence);
} else {
super.setPrompt(charSequence);
}
}
@Override // android.widget.Spinner
public CharSequence getPrompt() {
ojQ ojq = this.f;
return ojq != null ? ojq.c() : super.getPrompt();
}
@Override // android.view.View
public void setBackgroundResource(int i) {
super.setBackgroundResource(i);
WpN wpN = this.a;
if (wpN != null) {
wpN.c(i);
}
}
@Override // android.view.View
public void setBackgroundDrawable(Drawable drawable) {
super.setBackgroundDrawable(drawable);
WpN wpN = this.a;
if (wpN != null) {
wpN.fz_(drawable);
}
}
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
WpN wpN = this.a;
if (wpN != null) {
wpN.fB_(colorStateList);
}
}
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
WpN wpN = this.a;
if (wpN != null) {
wpN.fC_(mode);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
WpN wpN = this.a;
if (wpN != null) {
wpN.a();
}
}
int gM_(SpinnerAdapter spinnerAdapter, Drawable drawable) {
int i = 0;
if (spinnerAdapter == null) {
return 0;
}
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
int max = Math.max(0, getSelectedItemPosition());
int min = Math.min(spinnerAdapter.getCount(), max + 15);
View view = null;
int i2 = 0;
for (int max2 = Math.max(0, max - (15 - (min - max))); max2 < min; max2++) {
int itemViewType = spinnerAdapter.getItemViewType(max2);
if (itemViewType != i2) {
view = null;
i2 = itemViewType;
}
view = spinnerAdapter.getView(max2, view, this);
if (view.getLayoutParams() == null) {
view.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
}
view.measure(makeMeasureSpec, makeMeasureSpec2);
i = Math.max(i, view.getMeasuredWidth());
}
if (drawable == null) {
return i;
}
drawable.getPadding(this.d);
return i + this.d.left + this.d.right;
}
void b() {
this.f.c(LWm.b(this), LWm.e(this));
}
@Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
public Parcelable onSaveInstanceState() {
ZqN zqN = new ZqN(super.onSaveInstanceState());
ojQ ojq = this.f;
zqN.e = ojq != null && ojq.j();
return zqN;
}
@Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
public void onRestoreInstanceState(Parcelable parcelable) {
ViewTreeObserver viewTreeObserver;
ZqN zqN = (ZqN) parcelable;
super.onRestoreInstanceState(zqN.getSuperState());
if (!zqN.e || (viewTreeObserver = getViewTreeObserver()) == null) {
return;
}
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(this) { // from class: androidx.appcompat.widget.AppCompatSpinner.3
final AppCompatSpinner c;
{
this.c = this;
}
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
public void onGlobalLayout() {
if (!this.c.e().j()) {
this.c.b();
}
ViewTreeObserver viewTreeObserver2 = this.c.getViewTreeObserver();
if (viewTreeObserver2 != null) {
Sts.gN_(viewTreeObserver2, this);
}
}
});
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class ZqN extends View.BaseSavedState {
public static final Parcelable.Creator<ZqN> CREATOR = new Parcelable.Creator<ZqN>() { // from class: androidx.appcompat.widget.AppCompatSpinner.ZqN.3
@Override // android.os.Parcelable.Creator
/* renamed from: gT_, reason: merged with bridge method [inline-methods] */
public ZqN createFromParcel(Parcel parcel) {
return new ZqN(parcel);
}
@Override // android.os.Parcelable.Creator
/* renamed from: d, reason: merged with bridge method [inline-methods] */
public ZqN[] newArray(int i) {
return new ZqN[i];
}
};
boolean e;
ZqN(Parcelable parcelable) {
super(parcelable);
}
ZqN(Parcel parcel) {
super(parcel);
this.e = parcel.readByte() != 0;
}
@Override // android.view.View.BaseSavedState, android.view.AbsSavedState, android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeByte(this.e ? (byte) 1 : (byte) 0);
}
}
/* loaded from: classes.dex */
static class IeS implements ListAdapter, SpinnerAdapter {
private SpinnerAdapter a;
private ListAdapter d;
@Override // android.widget.Adapter
public int getItemViewType(int i) {
return 0;
}
@Override // android.widget.Adapter
public int getViewTypeCount() {
return 1;
}
public IeS(SpinnerAdapter spinnerAdapter, Resources.Theme theme) {
this.a = spinnerAdapter;
if (spinnerAdapter instanceof ListAdapter) {
this.d = (ListAdapter) spinnerAdapter;
}
if (theme != null) {
if (spinnerAdapter instanceof ThemedSpinnerAdapter) {
RVV.gO_((ThemedSpinnerAdapter) spinnerAdapter, theme);
} else if (spinnerAdapter instanceof InterfaceC17151uNO) {
}
}
}
@Override // android.widget.Adapter
public int getCount() {
SpinnerAdapter spinnerAdapter = this.a;
if (spinnerAdapter == null) {
return 0;
}
return spinnerAdapter.getCount();
}
@Override // android.widget.Adapter
public Object getItem(int i) {
SpinnerAdapter spinnerAdapter = this.a;
if (spinnerAdapter == null) {
return null;
}
return spinnerAdapter.getItem(i);
}
@Override // android.widget.Adapter
public long getItemId(int i) {
SpinnerAdapter spinnerAdapter = this.a;
if (spinnerAdapter == null) {
return -1L;
}
return spinnerAdapter.getItemId(i);
}
@Override // android.widget.Adapter
public View getView(int i, View view, ViewGroup viewGroup) {
return getDropDownView(i, view, viewGroup);
}
@Override // android.widget.SpinnerAdapter
public View getDropDownView(int i, View view, ViewGroup viewGroup) {
SpinnerAdapter spinnerAdapter = this.a;
if (spinnerAdapter == null) {
return null;
}
return spinnerAdapter.getDropDownView(i, view, viewGroup);
}
@Override // android.widget.Adapter
public boolean hasStableIds() {
SpinnerAdapter spinnerAdapter = this.a;
return spinnerAdapter != null && spinnerAdapter.hasStableIds();
}
@Override // android.widget.Adapter
public void registerDataSetObserver(DataSetObserver dataSetObserver) {
SpinnerAdapter spinnerAdapter = this.a;
if (spinnerAdapter != null) {
spinnerAdapter.registerDataSetObserver(dataSetObserver);
}
}
@Override // android.widget.Adapter
public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
SpinnerAdapter spinnerAdapter = this.a;
if (spinnerAdapter != null) {
spinnerAdapter.unregisterDataSetObserver(dataSetObserver);
}
}
@Override // android.widget.ListAdapter
public boolean areAllItemsEnabled() {
ListAdapter listAdapter = this.d;
if (listAdapter != null) {
return listAdapter.areAllItemsEnabled();
}
return true;
}
@Override // android.widget.ListAdapter
public boolean isEnabled(int i) {
ListAdapter listAdapter = this.d;
if (listAdapter != null) {
return listAdapter.isEnabled(i);
}
return true;
}
@Override // android.widget.Adapter
public boolean isEmpty() {
return getCount() == 0;
}
}
/* loaded from: classes.dex */
class HBt implements ojQ, DialogInterface.OnClickListener {
private CharSequence a;
final AppCompatSpinner b;
DialogInterfaceC17187ufv d;
private ListAdapter e;
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void b(int i) {
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void c(int i) {
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public int d() {
return 0;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public int e() {
return 0;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void e(int i) {
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public Drawable is_() {
return null;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void iv_(Drawable drawable) {
}
HBt(AppCompatSpinner appCompatSpinner) {
this.b = appCompatSpinner;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void b() {
DialogInterfaceC17187ufv dialogInterfaceC17187ufv = this.d;
if (dialogInterfaceC17187ufv != null) {
dialogInterfaceC17187ufv.dismiss();
this.d = null;
}
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public boolean j() {
DialogInterfaceC17187ufv dialogInterfaceC17187ufv = this.d;
if (dialogInterfaceC17187ufv != null) {
return dialogInterfaceC17187ufv.isShowing();
}
return false;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void c(int i, int i2) {
if (this.e == null) {
return;
}
DialogInterfaceC17187ufv.HBt hBt = new DialogInterfaceC17187ufv.HBt(this.b.getPopupContext());
CharSequence charSequence = this.a;
if (charSequence != null) {
hBt.b.C = charSequence;
}
ListAdapter listAdapter = this.e;
int selectedItemPosition = this.b.getSelectedItemPosition();
hBt.b.a = listAdapter;
hBt.b.x = this;
hBt.b.b = selectedItemPosition;
hBt.b.l = true;
DialogInterfaceC17187ufv b = hBt.b();
this.d = b;
ListView listView = b.a.z;
LWm.d(listView, i);
LWm.b(listView, i2);
this.d.show();
}
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
this.b.setSelection(i);
if (this.b.getOnItemClickListener() != null) {
this.b.performItemClick(null, i, this.e.getItemId(i));
}
b();
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void e(CharSequence charSequence) {
this.a = charSequence;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void iu_(ListAdapter listAdapter) {
this.e = listAdapter;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public CharSequence c() {
return this.a;
}
}
/* loaded from: classes.dex */
class tOB extends C15846jAy implements ojQ {
ListAdapter d;
final AppCompatSpinner e;
private final Rect g;
private int h;
private CharSequence i;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public tOB(AppCompatSpinner appCompatSpinner, Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.e = appCompatSpinner;
this.g = new Rect();
e(appCompatSpinner);
c(true);
j(0);
iy_(new AdapterView.OnItemClickListener(this, appCompatSpinner) { // from class: androidx.appcompat.widget.AppCompatSpinner.tOB.4
final AppCompatSpinner a;
final tOB c;
{
this.c = this;
this.a = appCompatSpinner;
}
@Override // android.widget.AdapterView.OnItemClickListener
public void onItemClick(AdapterView<?> adapterView, View view, int i2, long j) {
this.c.e.setSelection(i2);
if (this.c.e.getOnItemClickListener() != null) {
this.c.e.performItemClick(view, i2, this.c.d.getItemId(i2));
}
this.c.b();
}
});
}
@Override // o.C15846jAy, androidx.appcompat.widget.AppCompatSpinner.ojQ
public void iu_(ListAdapter listAdapter) {
super.iu_(listAdapter);
this.d = listAdapter;
}
void g() {
int i;
int f;
Drawable is_ = is_();
if (is_ != null) {
is_.getPadding(this.e.d);
i = mxt.b(this.e) ? this.e.d.right : -this.e.d.left;
} else {
Rect rect = this.e.d;
this.e.d.right = 0;
rect.left = 0;
i = 0;
}
int paddingLeft = this.e.getPaddingLeft();
int paddingRight = this.e.getPaddingRight();
int width = this.e.getWidth();
if (this.e.e == -2) {
int gM_ = this.e.gM_((SpinnerAdapter) this.d, is_());
int i2 = (this.e.getContext().getResources().getDisplayMetrics().widthPixels - this.e.d.left) - this.e.d.right;
if (gM_ > i2) {
gM_ = i2;
}
a(Math.max(gM_, (width - paddingLeft) - paddingRight));
} else if (this.e.e == -1) {
a((width - paddingLeft) - paddingRight);
} else {
a(this.e.e);
}
if (mxt.b(this.e)) {
f = i + (((width - paddingRight) - s()) - f());
} else {
f = i + paddingLeft + f();
}
e(f);
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void c(int i, int i2) {
ViewTreeObserver viewTreeObserver;
boolean j = j();
g();
i(2);
super.h();
ListView it_ = it_();
it_.setChoiceMode(1);
LWm.d(it_, i);
LWm.b(it_, i2);
f(this.e.getSelectedItemPosition());
if (j || (viewTreeObserver = this.e.getViewTreeObserver()) == null) {
return;
}
ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener(this) { // from class: androidx.appcompat.widget.AppCompatSpinner.tOB.5
final tOB b;
{
this.b = this;
}
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
public void onGlobalLayout() {
tOB tob = this.b;
if (!tob.d(tob.e)) {
this.b.b();
} else {
this.b.g();
tOB.super.h();
}
}
};
viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener);
ix_(new PopupWindow.OnDismissListener(this, onGlobalLayoutListener) { // from class: androidx.appcompat.widget.AppCompatSpinner.tOB.2
final ViewTreeObserver.OnGlobalLayoutListener d;
final tOB e;
{
this.e = this;
this.d = onGlobalLayoutListener;
}
@Override // android.widget.PopupWindow.OnDismissListener
public void onDismiss() {
ViewTreeObserver viewTreeObserver2 = this.e.e.getViewTreeObserver();
if (viewTreeObserver2 != null) {
viewTreeObserver2.removeGlobalOnLayoutListener(this.d);
}
}
});
}
boolean d(View view) {
return ViewCompat.H(view) && view.getGlobalVisibleRect(this.g);
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void e(CharSequence charSequence) {
this.i = charSequence;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public void b(int i) {
this.h = i;
}
public int f() {
return this.h;
}
@Override // androidx.appcompat.widget.AppCompatSpinner.ojQ
public CharSequence c() {
return this.i;
}
}
/* loaded from: classes.dex */
static final class RVV {
static void gO_(ThemedSpinnerAdapter themedSpinnerAdapter, Resources.Theme theme) {
if (ZEY.b(themedSpinnerAdapter.getDropDownViewTheme(), theme)) {
return;
}
themedSpinnerAdapter.setDropDownViewTheme(theme);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static final class LWm {
static int e(View view) {
return view.getTextAlignment();
}
static void b(View view, int i) {
view.setTextAlignment(i);
}
static int b(View view) {
return view.getTextDirection();
}
static void d(View view, int i) {
view.setTextDirection(i);
}
}
/* loaded from: classes.dex */
static final class Sts {
static void gN_(ViewTreeObserver viewTreeObserver, ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener);
}
}
@Override // android.widget.Spinner
public Context getPopupContext() {
return this.g;
}
final ojQ e() {
return this.f;
}
}