- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
973 lines
38 KiB
Java
973 lines
38 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.R;
|
|
import android.annotation.SuppressLint;
|
|
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.util.Log;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewTreeObserver;
|
|
import android.view.inspector.PropertyMapper;
|
|
import android.view.inspector.PropertyReader;
|
|
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 androidx.annotation.DoNotInline;
|
|
import androidx.annotation.DrawableRes;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.StyleableRes;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import androidx.appcompat.content.res.AppCompatResources;
|
|
import androidx.core.util.ObjectsCompat;
|
|
import androidx.core.view.TintableBackgroundView;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class AppCompatSpinner extends Spinner implements TintableBackgroundView {
|
|
|
|
@SuppressLint({"ResourceType"})
|
|
@StyleableRes
|
|
private static final int[] ATTRS_ANDROID_SPINNERMODE = {R.attr.spinnerMode};
|
|
private static final int MAX_ITEMS_MEASURED = 15;
|
|
private static final int MODE_DIALOG = 0;
|
|
private static final int MODE_DROPDOWN = 1;
|
|
private static final int MODE_THEME = -1;
|
|
private static final String TAG = "AppCompatSpinner";
|
|
private final AppCompatBackgroundHelper mBackgroundTintHelper;
|
|
int mDropDownWidth;
|
|
private ForwardingListener mForwardingListener;
|
|
private SpinnerPopup mPopup;
|
|
private final Context mPopupContext;
|
|
private final boolean mPopupSet;
|
|
private SpinnerAdapter mTempAdapter;
|
|
final Rect mTempRect;
|
|
|
|
@VisibleForTesting
|
|
public interface SpinnerPopup {
|
|
void dismiss();
|
|
|
|
Drawable getBackground();
|
|
|
|
CharSequence getHintText();
|
|
|
|
int getHorizontalOffset();
|
|
|
|
int getHorizontalOriginalOffset();
|
|
|
|
int getVerticalOffset();
|
|
|
|
boolean isShowing();
|
|
|
|
void setAdapter(ListAdapter listAdapter);
|
|
|
|
void setBackgroundDrawable(Drawable drawable);
|
|
|
|
void setHorizontalOffset(int i);
|
|
|
|
void setHorizontalOriginalOffset(int i);
|
|
|
|
void setPromptText(CharSequence charSequence);
|
|
|
|
void setVerticalOffset(int i);
|
|
|
|
void show(int i, int i2);
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public final SpinnerPopup getInternalPopup() {
|
|
return this.mPopup;
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public Context getPopupContext() {
|
|
return this.mPopupContext;
|
|
}
|
|
|
|
@RequiresApi(29)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
public final class InspectionCompanion implements android.view.inspector.InspectionCompanion {
|
|
private int mBackgroundTintId;
|
|
private int mBackgroundTintModeId;
|
|
private boolean mPropertiesMapped = false;
|
|
|
|
public void mapProperties(@NonNull PropertyMapper propertyMapper) {
|
|
int mapObject;
|
|
int mapObject2;
|
|
mapObject = propertyMapper.mapObject("backgroundTint", androidx.appcompat.R.attr.backgroundTint);
|
|
this.mBackgroundTintId = mapObject;
|
|
mapObject2 = propertyMapper.mapObject("backgroundTintMode", androidx.appcompat.R.attr.backgroundTintMode);
|
|
this.mBackgroundTintModeId = mapObject2;
|
|
this.mPropertiesMapped = true;
|
|
}
|
|
|
|
public void readProperties(@NonNull AppCompatSpinner appCompatSpinner, @NonNull PropertyReader propertyReader) {
|
|
if (!this.mPropertiesMapped) {
|
|
throw AppCompatAutoCompleteTextView$InspectionCompanion$$ExternalSyntheticApiModelOutline2.m();
|
|
}
|
|
propertyReader.readObject(this.mBackgroundTintId, appCompatSpinner.getBackgroundTintList());
|
|
propertyReader.readObject(this.mBackgroundTintModeId, appCompatSpinner.getBackgroundTintMode());
|
|
}
|
|
}
|
|
|
|
public AppCompatSpinner(@NonNull Context context) {
|
|
this(context, (AttributeSet) null);
|
|
}
|
|
|
|
public AppCompatSpinner(@NonNull Context context, int i) {
|
|
this(context, null, androidx.appcompat.R.attr.spinnerStyle, i);
|
|
}
|
|
|
|
public AppCompatSpinner(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
|
this(context, attributeSet, androidx.appcompat.R.attr.spinnerStyle);
|
|
}
|
|
|
|
public AppCompatSpinner(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
|
|
this(context, attributeSet, i, -1);
|
|
}
|
|
|
|
public AppCompatSpinner(@NonNull Context context, @Nullable AttributeSet attributeSet, int i, int i2) {
|
|
this(context, attributeSet, i, i2, null);
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:29:0x0061, code lost:
|
|
|
|
if (r10 == null) goto L27;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public AppCompatSpinner(@androidx.annotation.NonNull android.content.Context r6, @androidx.annotation.Nullable android.util.AttributeSet r7, int r8, int r9, android.content.res.Resources.Theme r10) {
|
|
/*
|
|
r5 = this;
|
|
r5.<init>(r6, r7, r8)
|
|
android.graphics.Rect r0 = new android.graphics.Rect
|
|
r0.<init>()
|
|
r5.mTempRect = r0
|
|
android.content.Context r0 = r5.getContext()
|
|
androidx.appcompat.widget.ThemeUtils.checkAppCompatTheme(r5, r0)
|
|
int[] r0 = androidx.appcompat.R.styleable.Spinner
|
|
r1 = 0
|
|
androidx.appcompat.widget.TintTypedArray r0 = androidx.appcompat.widget.TintTypedArray.obtainStyledAttributes(r6, r7, r0, r8, r1)
|
|
androidx.appcompat.widget.AppCompatBackgroundHelper r2 = new androidx.appcompat.widget.AppCompatBackgroundHelper
|
|
r2.<init>(r5)
|
|
r5.mBackgroundTintHelper = r2
|
|
if (r10 == 0) goto L29
|
|
androidx.appcompat.view.ContextThemeWrapper r2 = new androidx.appcompat.view.ContextThemeWrapper
|
|
r2.<init>(r6, r10)
|
|
r5.mPopupContext = r2
|
|
goto L3b
|
|
L29:
|
|
int r10 = androidx.appcompat.R.styleable.Spinner_popupTheme
|
|
int r10 = r0.getResourceId(r10, r1)
|
|
if (r10 == 0) goto L39
|
|
androidx.appcompat.view.ContextThemeWrapper r2 = new androidx.appcompat.view.ContextThemeWrapper
|
|
r2.<init>(r6, r10)
|
|
r5.mPopupContext = r2
|
|
goto L3b
|
|
L39:
|
|
r5.mPopupContext = r6
|
|
L3b:
|
|
r10 = -1
|
|
r2 = 0
|
|
if (r9 != r10) goto L64
|
|
int[] r10 = androidx.appcompat.widget.AppCompatSpinner.ATTRS_ANDROID_SPINNERMODE // Catch: java.lang.Throwable -> L57 java.lang.Exception -> L59
|
|
android.content.res.TypedArray r10 = r6.obtainStyledAttributes(r7, r10, r8, r1) // Catch: java.lang.Throwable -> L57 java.lang.Exception -> L59
|
|
boolean r3 = r10.hasValue(r1) // Catch: java.lang.Throwable -> L50 java.lang.Exception -> L61
|
|
if (r3 == 0) goto L53
|
|
int r9 = r10.getInt(r1, r1) // Catch: java.lang.Throwable -> L50 java.lang.Exception -> L61
|
|
goto L53
|
|
L50:
|
|
r6 = move-exception
|
|
r2 = r10
|
|
goto L5b
|
|
L53:
|
|
r10.recycle()
|
|
goto L64
|
|
L57:
|
|
r6 = move-exception
|
|
goto L5b
|
|
L59:
|
|
r10 = r2
|
|
goto L61
|
|
L5b:
|
|
if (r2 == 0) goto L60
|
|
r2.recycle()
|
|
L60:
|
|
throw r6
|
|
L61:
|
|
if (r10 == 0) goto L64
|
|
goto L53
|
|
L64:
|
|
r10 = 1
|
|
if (r9 == 0) goto La1
|
|
if (r9 == r10) goto L6a
|
|
goto Lb1
|
|
L6a:
|
|
androidx.appcompat.widget.AppCompatSpinner$DropdownPopup r9 = new androidx.appcompat.widget.AppCompatSpinner$DropdownPopup
|
|
android.content.Context r3 = r5.mPopupContext
|
|
r9.<init>(r3, r7, r8)
|
|
android.content.Context r3 = r5.mPopupContext
|
|
int[] r4 = androidx.appcompat.R.styleable.Spinner
|
|
androidx.appcompat.widget.TintTypedArray r1 = androidx.appcompat.widget.TintTypedArray.obtainStyledAttributes(r3, r7, r4, r8, r1)
|
|
int r3 = androidx.appcompat.R.styleable.Spinner_android_dropDownWidth
|
|
r4 = -2
|
|
int r3 = r1.getLayoutDimension(r3, r4)
|
|
r5.mDropDownWidth = r3
|
|
int r3 = androidx.appcompat.R.styleable.Spinner_android_popupBackground
|
|
android.graphics.drawable.Drawable r3 = r1.getDrawable(r3)
|
|
r9.setBackgroundDrawable(r3)
|
|
int r3 = androidx.appcompat.R.styleable.Spinner_android_prompt
|
|
java.lang.String r3 = r0.getString(r3)
|
|
r9.setPromptText(r3)
|
|
r1.recycle()
|
|
r5.mPopup = r9
|
|
androidx.appcompat.widget.AppCompatSpinner$1 r1 = new androidx.appcompat.widget.AppCompatSpinner$1
|
|
r1.<init>(r5)
|
|
r5.mForwardingListener = r1
|
|
goto Lb1
|
|
La1:
|
|
androidx.appcompat.widget.AppCompatSpinner$DialogPopup r9 = new androidx.appcompat.widget.AppCompatSpinner$DialogPopup
|
|
r9.<init>()
|
|
r5.mPopup = r9
|
|
int r1 = androidx.appcompat.R.styleable.Spinner_android_prompt
|
|
java.lang.String r1 = r0.getString(r1)
|
|
r9.setPromptText(r1)
|
|
Lb1:
|
|
int r9 = androidx.appcompat.R.styleable.Spinner_android_entries
|
|
java.lang.CharSequence[] r9 = r0.getTextArray(r9)
|
|
if (r9 == 0) goto Lc9
|
|
android.widget.ArrayAdapter r1 = new android.widget.ArrayAdapter
|
|
r3 = 17367048(0x1090008, float:2.5162948E-38)
|
|
r1.<init>(r6, r3, r9)
|
|
int r6 = androidx.appcompat.R.layout.support_simple_spinner_dropdown_item
|
|
r1.setDropDownViewResource(r6)
|
|
r5.setAdapter(r1)
|
|
Lc9:
|
|
r0.recycle()
|
|
r5.mPopupSet = r10
|
|
android.widget.SpinnerAdapter r6 = r5.mTempAdapter
|
|
if (r6 == 0) goto Ld7
|
|
r5.setAdapter(r6)
|
|
r5.mTempAdapter = r2
|
|
Ld7:
|
|
androidx.appcompat.widget.AppCompatBackgroundHelper r6 = r5.mBackgroundTintHelper
|
|
r6.loadFromAttributes(r7, r8)
|
|
return
|
|
*/
|
|
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) {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
spinnerPopup.setBackgroundDrawable(drawable);
|
|
} else {
|
|
super.setPopupBackgroundDrawable(drawable);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public void setPopupBackgroundResource(@DrawableRes int i) {
|
|
setPopupBackgroundDrawable(AppCompatResources.getDrawable(getPopupContext(), i));
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public Drawable getPopupBackground() {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
return spinnerPopup.getBackground();
|
|
}
|
|
return super.getPopupBackground();
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public void setDropDownVerticalOffset(int i) {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
spinnerPopup.setVerticalOffset(i);
|
|
} else {
|
|
super.setDropDownVerticalOffset(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public int getDropDownVerticalOffset() {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
return spinnerPopup.getVerticalOffset();
|
|
}
|
|
return super.getDropDownVerticalOffset();
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public void setDropDownHorizontalOffset(int i) {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
spinnerPopup.setHorizontalOriginalOffset(i);
|
|
this.mPopup.setHorizontalOffset(i);
|
|
} else {
|
|
super.setDropDownHorizontalOffset(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public int getDropDownHorizontalOffset() {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
return spinnerPopup.getHorizontalOffset();
|
|
}
|
|
return super.getDropDownHorizontalOffset();
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public void setDropDownWidth(int i) {
|
|
if (this.mPopup != null) {
|
|
this.mDropDownWidth = i;
|
|
} else {
|
|
super.setDropDownWidth(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public int getDropDownWidth() {
|
|
return this.mPopup != null ? this.mDropDownWidth : super.getDropDownWidth();
|
|
}
|
|
|
|
@Override // android.widget.AdapterView
|
|
public void setAdapter(SpinnerAdapter spinnerAdapter) {
|
|
if (!this.mPopupSet) {
|
|
this.mTempAdapter = spinnerAdapter;
|
|
return;
|
|
}
|
|
super.setAdapter(spinnerAdapter);
|
|
if (this.mPopup != null) {
|
|
Context context = this.mPopupContext;
|
|
if (context == null) {
|
|
context = getContext();
|
|
}
|
|
this.mPopup.setAdapter(new DropDownAdapter(spinnerAdapter, context.getTheme()));
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Spinner, android.widget.AdapterView, android.view.ViewGroup, android.view.View
|
|
public void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup == null || !spinnerPopup.isShowing()) {
|
|
return;
|
|
}
|
|
this.mPopup.dismiss();
|
|
}
|
|
|
|
@Override // android.widget.Spinner, android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
ForwardingListener forwardingListener = this.mForwardingListener;
|
|
if (forwardingListener == null || !forwardingListener.onTouch(this, motionEvent)) {
|
|
return super.onTouchEvent(motionEvent);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
|
|
public void onMeasure(int i, int i2) {
|
|
super.onMeasure(i, i2);
|
|
if (this.mPopup == null || View.MeasureSpec.getMode(i) != Integer.MIN_VALUE) {
|
|
return;
|
|
}
|
|
setMeasuredDimension(Math.min(Math.max(getMeasuredWidth(), compatMeasureContentWidth(getAdapter(), getBackground())), View.MeasureSpec.getSize(i)), getMeasuredHeight());
|
|
}
|
|
|
|
@Override // android.widget.Spinner, android.view.View
|
|
public boolean performClick() {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
if (spinnerPopup.isShowing()) {
|
|
return true;
|
|
}
|
|
showPopup();
|
|
return true;
|
|
}
|
|
return super.performClick();
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public void setPrompt(CharSequence charSequence) {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
if (spinnerPopup != null) {
|
|
spinnerPopup.setPromptText(charSequence);
|
|
} else {
|
|
super.setPrompt(charSequence);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Spinner
|
|
public CharSequence getPrompt() {
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
return spinnerPopup != null ? spinnerPopup.getHintText() : super.getPrompt();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setBackgroundResource(@DrawableRes int i) {
|
|
super.setBackgroundResource(i);
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.onSetBackgroundResource(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setBackgroundDrawable(@Nullable Drawable drawable) {
|
|
super.setBackgroundDrawable(drawable);
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.onSetBackgroundDrawable(drawable);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void setSupportBackgroundTintList(@Nullable ColorStateList colorStateList) {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.setSupportBackgroundTintList(colorStateList);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
@Nullable
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public ColorStateList getSupportBackgroundTintList() {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
return appCompatBackgroundHelper.getSupportBackgroundTintList();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode mode) {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.setSupportBackgroundTintMode(mode);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
@Nullable
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public PorterDuff.Mode getSupportBackgroundTintMode() {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
return appCompatBackgroundHelper.getSupportBackgroundTintMode();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void drawableStateChanged() {
|
|
super.drawableStateChanged();
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.applySupportBackgroundTint();
|
|
}
|
|
}
|
|
|
|
public int compatMeasureContentWidth(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 != i) {
|
|
view = null;
|
|
i = itemViewType;
|
|
}
|
|
view = spinnerAdapter.getView(max2, view, this);
|
|
if (view.getLayoutParams() == null) {
|
|
view.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
|
|
}
|
|
view.measure(makeMeasureSpec, makeMeasureSpec2);
|
|
i2 = Math.max(i2, view.getMeasuredWidth());
|
|
}
|
|
if (drawable == null) {
|
|
return i2;
|
|
}
|
|
drawable.getPadding(this.mTempRect);
|
|
Rect rect = this.mTempRect;
|
|
return i2 + rect.left + rect.right;
|
|
}
|
|
|
|
public void showPopup() {
|
|
this.mPopup.show(getTextDirection(), getTextAlignment());
|
|
}
|
|
|
|
@Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
|
|
public Parcelable onSaveInstanceState() {
|
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
|
SpinnerPopup spinnerPopup = this.mPopup;
|
|
savedState.mShowDropdown = spinnerPopup != null && spinnerPopup.isShowing();
|
|
return savedState;
|
|
}
|
|
|
|
@Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
|
|
public void onRestoreInstanceState(Parcelable parcelable) {
|
|
ViewTreeObserver viewTreeObserver;
|
|
SavedState savedState = (SavedState) parcelable;
|
|
super.onRestoreInstanceState(savedState.getSuperState());
|
|
if (!savedState.mShowDropdown || (viewTreeObserver = getViewTreeObserver()) == null) {
|
|
return;
|
|
}
|
|
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // from class: androidx.appcompat.widget.AppCompatSpinner.2
|
|
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
|
|
public void onGlobalLayout() {
|
|
if (!AppCompatSpinner.this.getInternalPopup().isShowing()) {
|
|
AppCompatSpinner.this.showPopup();
|
|
}
|
|
ViewTreeObserver viewTreeObserver2 = AppCompatSpinner.this.getViewTreeObserver();
|
|
if (viewTreeObserver2 != null) {
|
|
viewTreeObserver2.removeOnGlobalLayoutListener(this);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public static class SavedState extends View.BaseSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { // from class: androidx.appcompat.widget.AppCompatSpinner.SavedState.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
};
|
|
boolean mShowDropdown;
|
|
|
|
public SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
|
|
public SavedState(Parcel parcel) {
|
|
super(parcel);
|
|
this.mShowDropdown = 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.mShowDropdown ? (byte) 1 : (byte) 0);
|
|
}
|
|
}
|
|
|
|
public static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
|
|
private SpinnerAdapter mAdapter;
|
|
private ListAdapter mListAdapter;
|
|
|
|
@Override // android.widget.Adapter
|
|
public int getItemViewType(int i) {
|
|
return 0;
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public int getViewTypeCount() {
|
|
return 1;
|
|
}
|
|
|
|
public DropDownAdapter(@Nullable SpinnerAdapter spinnerAdapter, @Nullable Resources.Theme theme) {
|
|
this.mAdapter = spinnerAdapter;
|
|
if (spinnerAdapter instanceof ListAdapter) {
|
|
this.mListAdapter = (ListAdapter) spinnerAdapter;
|
|
}
|
|
if (theme != null) {
|
|
if (spinnerAdapter instanceof android.widget.ThemedSpinnerAdapter) {
|
|
Api23Impl.setDropDownViewTheme((android.widget.ThemedSpinnerAdapter) spinnerAdapter, theme);
|
|
} else if (spinnerAdapter instanceof ThemedSpinnerAdapter) {
|
|
ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
|
|
if (themedSpinnerAdapter.getDropDownViewTheme() == null) {
|
|
themedSpinnerAdapter.setDropDownViewTheme(theme);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public int getCount() {
|
|
SpinnerAdapter spinnerAdapter = this.mAdapter;
|
|
if (spinnerAdapter == null) {
|
|
return 0;
|
|
}
|
|
return spinnerAdapter.getCount();
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public Object getItem(int i) {
|
|
SpinnerAdapter spinnerAdapter = this.mAdapter;
|
|
if (spinnerAdapter == null) {
|
|
return null;
|
|
}
|
|
return spinnerAdapter.getItem(i);
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public long getItemId(int i) {
|
|
SpinnerAdapter spinnerAdapter = this.mAdapter;
|
|
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.mAdapter;
|
|
if (spinnerAdapter == null) {
|
|
return null;
|
|
}
|
|
return spinnerAdapter.getDropDownView(i, view, viewGroup);
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public boolean hasStableIds() {
|
|
SpinnerAdapter spinnerAdapter = this.mAdapter;
|
|
return spinnerAdapter != null && spinnerAdapter.hasStableIds();
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public void registerDataSetObserver(DataSetObserver dataSetObserver) {
|
|
SpinnerAdapter spinnerAdapter = this.mAdapter;
|
|
if (spinnerAdapter != null) {
|
|
spinnerAdapter.registerDataSetObserver(dataSetObserver);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
|
|
SpinnerAdapter spinnerAdapter = this.mAdapter;
|
|
if (spinnerAdapter != null) {
|
|
spinnerAdapter.unregisterDataSetObserver(dataSetObserver);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.ListAdapter
|
|
public boolean areAllItemsEnabled() {
|
|
ListAdapter listAdapter = this.mListAdapter;
|
|
if (listAdapter != null) {
|
|
return listAdapter.areAllItemsEnabled();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // android.widget.ListAdapter
|
|
public boolean isEnabled(int i) {
|
|
ListAdapter listAdapter = this.mListAdapter;
|
|
if (listAdapter != null) {
|
|
return listAdapter.isEnabled(i);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public boolean isEmpty() {
|
|
return getCount() == 0;
|
|
}
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener {
|
|
private ListAdapter mListAdapter;
|
|
|
|
@VisibleForTesting
|
|
AlertDialog mPopup;
|
|
private CharSequence mPrompt;
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public Drawable getBackground() {
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public CharSequence getHintText() {
|
|
return this.mPrompt;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public int getHorizontalOffset() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public int getHorizontalOriginalOffset() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public int getVerticalOffset() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setAdapter(ListAdapter listAdapter) {
|
|
this.mListAdapter = listAdapter;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setPromptText(CharSequence charSequence) {
|
|
this.mPrompt = charSequence;
|
|
}
|
|
|
|
public DialogPopup() {
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void dismiss() {
|
|
AlertDialog alertDialog = this.mPopup;
|
|
if (alertDialog != null) {
|
|
alertDialog.dismiss();
|
|
this.mPopup = null;
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public boolean isShowing() {
|
|
AlertDialog alertDialog = this.mPopup;
|
|
if (alertDialog != null) {
|
|
return alertDialog.isShowing();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void show(int i, int i2) {
|
|
if (this.mListAdapter == null) {
|
|
return;
|
|
}
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(AppCompatSpinner.this.getPopupContext());
|
|
CharSequence charSequence = this.mPrompt;
|
|
if (charSequence != null) {
|
|
builder.setTitle(charSequence);
|
|
}
|
|
AlertDialog create = builder.setSingleChoiceItems(this.mListAdapter, AppCompatSpinner.this.getSelectedItemPosition(), this).create();
|
|
this.mPopup = create;
|
|
ListView listView = create.getListView();
|
|
listView.setTextDirection(i);
|
|
listView.setTextAlignment(i2);
|
|
this.mPopup.show();
|
|
}
|
|
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
AppCompatSpinner.this.setSelection(i);
|
|
if (AppCompatSpinner.this.getOnItemClickListener() != null) {
|
|
AppCompatSpinner.this.performItemClick(null, i, this.mListAdapter.getItemId(i));
|
|
}
|
|
dismiss();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setBackgroundDrawable(Drawable drawable) {
|
|
Log.e(AppCompatSpinner.TAG, "Cannot set popup background for MODE_DIALOG, ignoring");
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setVerticalOffset(int i) {
|
|
Log.e(AppCompatSpinner.TAG, "Cannot set vertical offset for MODE_DIALOG, ignoring");
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setHorizontalOffset(int i) {
|
|
Log.e(AppCompatSpinner.TAG, "Cannot set horizontal offset for MODE_DIALOG, ignoring");
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setHorizontalOriginalOffset(int i) {
|
|
Log.e(AppCompatSpinner.TAG, "Cannot set horizontal (original) offset for MODE_DIALOG, ignoring");
|
|
}
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public class DropdownPopup extends ListPopupWindow implements SpinnerPopup {
|
|
ListAdapter mAdapter;
|
|
private CharSequence mHintText;
|
|
private int mOriginalHorizontalOffset;
|
|
private final Rect mVisibleRect;
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public CharSequence getHintText() {
|
|
return this.mHintText;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public int getHorizontalOriginalOffset() {
|
|
return this.mOriginalHorizontalOffset;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setHorizontalOriginalOffset(int i) {
|
|
this.mOriginalHorizontalOffset = i;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setPromptText(CharSequence charSequence) {
|
|
this.mHintText = charSequence;
|
|
}
|
|
|
|
public DropdownPopup(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.mVisibleRect = new Rect();
|
|
setAnchorView(AppCompatSpinner.this);
|
|
setModal(true);
|
|
setPromptPosition(0);
|
|
setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: androidx.appcompat.widget.AppCompatSpinner.DropdownPopup.1
|
|
@Override // android.widget.AdapterView.OnItemClickListener
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i2, long j) {
|
|
AppCompatSpinner.this.setSelection(i2);
|
|
if (AppCompatSpinner.this.getOnItemClickListener() != null) {
|
|
DropdownPopup dropdownPopup = DropdownPopup.this;
|
|
AppCompatSpinner.this.performItemClick(view, i2, dropdownPopup.mAdapter.getItemId(i2));
|
|
}
|
|
DropdownPopup.this.dismiss();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.ListPopupWindow, androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void setAdapter(ListAdapter listAdapter) {
|
|
super.setAdapter(listAdapter);
|
|
this.mAdapter = listAdapter;
|
|
}
|
|
|
|
public void computeContentWidth() {
|
|
int i;
|
|
int horizontalOriginalOffset;
|
|
Drawable background = getBackground();
|
|
if (background != null) {
|
|
background.getPadding(AppCompatSpinner.this.mTempRect);
|
|
i = ViewUtils.isLayoutRtl(AppCompatSpinner.this) ? AppCompatSpinner.this.mTempRect.right : -AppCompatSpinner.this.mTempRect.left;
|
|
} else {
|
|
Rect rect = AppCompatSpinner.this.mTempRect;
|
|
rect.right = 0;
|
|
rect.left = 0;
|
|
i = 0;
|
|
}
|
|
int paddingLeft = AppCompatSpinner.this.getPaddingLeft();
|
|
int paddingRight = AppCompatSpinner.this.getPaddingRight();
|
|
int width = AppCompatSpinner.this.getWidth();
|
|
AppCompatSpinner appCompatSpinner = AppCompatSpinner.this;
|
|
int i2 = appCompatSpinner.mDropDownWidth;
|
|
if (i2 == -2) {
|
|
int compatMeasureContentWidth = appCompatSpinner.compatMeasureContentWidth((SpinnerAdapter) this.mAdapter, getBackground());
|
|
int i3 = AppCompatSpinner.this.getContext().getResources().getDisplayMetrics().widthPixels;
|
|
Rect rect2 = AppCompatSpinner.this.mTempRect;
|
|
int i4 = (i3 - rect2.left) - rect2.right;
|
|
if (compatMeasureContentWidth > i4) {
|
|
compatMeasureContentWidth = i4;
|
|
}
|
|
setContentWidth(Math.max(compatMeasureContentWidth, (width - paddingLeft) - paddingRight));
|
|
} else if (i2 == -1) {
|
|
setContentWidth((width - paddingLeft) - paddingRight);
|
|
} else {
|
|
setContentWidth(i2);
|
|
}
|
|
if (ViewUtils.isLayoutRtl(AppCompatSpinner.this)) {
|
|
horizontalOriginalOffset = i + (((width - paddingRight) - getWidth()) - getHorizontalOriginalOffset());
|
|
} else {
|
|
horizontalOriginalOffset = i + paddingLeft + getHorizontalOriginalOffset();
|
|
}
|
|
setHorizontalOffset(horizontalOriginalOffset);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatSpinner.SpinnerPopup
|
|
public void show(int i, int i2) {
|
|
ViewTreeObserver viewTreeObserver;
|
|
boolean isShowing = isShowing();
|
|
computeContentWidth();
|
|
setInputMethodMode(2);
|
|
super.show();
|
|
ListView listView = getListView();
|
|
listView.setChoiceMode(1);
|
|
listView.setTextDirection(i);
|
|
listView.setTextAlignment(i2);
|
|
setSelection(AppCompatSpinner.this.getSelectedItemPosition());
|
|
if (isShowing || (viewTreeObserver = AppCompatSpinner.this.getViewTreeObserver()) == null) {
|
|
return;
|
|
}
|
|
final ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { // from class: androidx.appcompat.widget.AppCompatSpinner.DropdownPopup.2
|
|
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
|
|
public void onGlobalLayout() {
|
|
DropdownPopup dropdownPopup = DropdownPopup.this;
|
|
if (!dropdownPopup.isVisibleToUser(AppCompatSpinner.this)) {
|
|
DropdownPopup.this.dismiss();
|
|
} else {
|
|
DropdownPopup.this.computeContentWidth();
|
|
DropdownPopup.super.show();
|
|
}
|
|
}
|
|
};
|
|
viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
setOnDismissListener(new PopupWindow.OnDismissListener() { // from class: androidx.appcompat.widget.AppCompatSpinner.DropdownPopup.3
|
|
@Override // android.widget.PopupWindow.OnDismissListener
|
|
public void onDismiss() {
|
|
ViewTreeObserver viewTreeObserver2 = AppCompatSpinner.this.getViewTreeObserver();
|
|
if (viewTreeObserver2 != null) {
|
|
viewTreeObserver2.removeGlobalOnLayoutListener(onGlobalLayoutListener);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public boolean isVisibleToUser(View view) {
|
|
return view.isAttachedToWindow() && view.getGlobalVisibleRect(this.mVisibleRect);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public static final class Api23Impl {
|
|
private Api23Impl() {
|
|
}
|
|
|
|
@DoNotInline
|
|
public static void setDropDownViewTheme(@NonNull android.widget.ThemedSpinnerAdapter themedSpinnerAdapter, @Nullable Resources.Theme theme) {
|
|
if (ObjectsCompat.equals(themedSpinnerAdapter.getDropDownViewTheme(), theme)) {
|
|
return;
|
|
}
|
|
themedSpinnerAdapter.setDropDownViewTheme(theme);
|
|
}
|
|
}
|
|
}
|