mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
809 lines
30 KiB
Java
809 lines
30 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
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.Handler;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.view.KeyEvent;
|
|
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.R;
|
|
import androidx.appcompat.view.menu.ShowableListMenu;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.widget.PopupWindowCompat;
|
|
import java.lang.reflect.Method;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ListPopupWindow implements ShowableListMenu {
|
|
private static final boolean DEBUG = false;
|
|
static final int EXPAND_LIST_TIMEOUT = 250;
|
|
public static final int INPUT_METHOD_FROM_FOCUSABLE = 0;
|
|
public static final int INPUT_METHOD_NEEDED = 1;
|
|
public static final int INPUT_METHOD_NOT_NEEDED = 2;
|
|
public static final int MATCH_PARENT = -1;
|
|
public static final int POSITION_PROMPT_ABOVE = 0;
|
|
public static final int POSITION_PROMPT_BELOW = 1;
|
|
private static final String TAG = "ListPopupWindow";
|
|
public static final int WRAP_CONTENT = -2;
|
|
private static Method sGetMaxAvailableHeightMethod;
|
|
private static Method sSetClipToWindowEnabledMethod;
|
|
private static Method sSetEpicenterBoundsMethod;
|
|
private ListAdapter mAdapter;
|
|
private Context mContext;
|
|
private boolean mDropDownAlwaysVisible;
|
|
private View mDropDownAnchorView;
|
|
private int mDropDownGravity;
|
|
private int mDropDownHeight;
|
|
private int mDropDownHorizontalOffset;
|
|
DropDownListView mDropDownList;
|
|
private Drawable mDropDownListHighlight;
|
|
private int mDropDownVerticalOffset;
|
|
private boolean mDropDownVerticalOffsetSet;
|
|
private int mDropDownWidth;
|
|
private int mDropDownWindowLayoutType;
|
|
private Rect mEpicenterBounds;
|
|
private boolean mForceIgnoreOutsideTouch;
|
|
final Handler mHandler;
|
|
private final ListSelectorHider mHideSelector;
|
|
private AdapterView.OnItemClickListener mItemClickListener;
|
|
private AdapterView.OnItemSelectedListener mItemSelectedListener;
|
|
int mListItemExpandMaximum;
|
|
private boolean mModal;
|
|
private DataSetObserver mObserver;
|
|
private boolean mOverlapAnchor;
|
|
private boolean mOverlapAnchorSet;
|
|
PopupWindow mPopup;
|
|
private int mPromptPosition;
|
|
private View mPromptView;
|
|
final ResizePopupRunnable mResizePopupRunnable;
|
|
private final PopupScrollListener mScrollListener;
|
|
private Runnable mShowDropDownRunnable;
|
|
private final Rect mTempRect;
|
|
private final PopupTouchInterceptor mTouchInterceptor;
|
|
|
|
private static boolean isConfirmKey(int i) {
|
|
return i == 66 || i == 23;
|
|
}
|
|
|
|
public View getAnchorView() {
|
|
return this.mDropDownAnchorView;
|
|
}
|
|
|
|
public int getHeight() {
|
|
return this.mDropDownHeight;
|
|
}
|
|
|
|
public int getHorizontalOffset() {
|
|
return this.mDropDownHorizontalOffset;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
|
public ListView getListView() {
|
|
return this.mDropDownList;
|
|
}
|
|
|
|
public int getPromptPosition() {
|
|
return this.mPromptPosition;
|
|
}
|
|
|
|
public int getVerticalOffset() {
|
|
if (this.mDropDownVerticalOffsetSet) {
|
|
return this.mDropDownVerticalOffset;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getWidth() {
|
|
return this.mDropDownWidth;
|
|
}
|
|
|
|
public boolean isDropDownAlwaysVisible() {
|
|
return this.mDropDownAlwaysVisible;
|
|
}
|
|
|
|
public boolean isModal() {
|
|
return this.mModal;
|
|
}
|
|
|
|
public void setAnchorView(View view) {
|
|
this.mDropDownAnchorView = view;
|
|
}
|
|
|
|
public void setDropDownAlwaysVisible(boolean z) {
|
|
this.mDropDownAlwaysVisible = z;
|
|
}
|
|
|
|
public void setDropDownGravity(int i) {
|
|
this.mDropDownGravity = i;
|
|
}
|
|
|
|
public void setForceIgnoreOutsideTouch(boolean z) {
|
|
this.mForceIgnoreOutsideTouch = z;
|
|
}
|
|
|
|
public void setHorizontalOffset(int i) {
|
|
this.mDropDownHorizontalOffset = i;
|
|
}
|
|
|
|
void setListItemExpandMax(int i) {
|
|
this.mListItemExpandMaximum = i;
|
|
}
|
|
|
|
public void setListSelector(Drawable drawable) {
|
|
this.mDropDownListHighlight = drawable;
|
|
}
|
|
|
|
public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
|
|
this.mItemClickListener = onItemClickListener;
|
|
}
|
|
|
|
public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener onItemSelectedListener) {
|
|
this.mItemSelectedListener = onItemSelectedListener;
|
|
}
|
|
|
|
public void setOverlapAnchor(boolean z) {
|
|
this.mOverlapAnchorSet = true;
|
|
this.mOverlapAnchor = z;
|
|
}
|
|
|
|
public void setPromptPosition(int i) {
|
|
this.mPromptPosition = i;
|
|
}
|
|
|
|
public void setVerticalOffset(int i) {
|
|
this.mDropDownVerticalOffset = i;
|
|
this.mDropDownVerticalOffsetSet = true;
|
|
}
|
|
|
|
public void setWidth(int i) {
|
|
this.mDropDownWidth = i;
|
|
}
|
|
|
|
public void setWindowLayoutType(int i) {
|
|
this.mDropDownWindowLayoutType = i;
|
|
}
|
|
|
|
public ListPopupWindow(Context context) {
|
|
this(context, null, R.attr.listPopupWindowStyle);
|
|
}
|
|
|
|
public ListPopupWindow(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, R.attr.listPopupWindowStyle);
|
|
}
|
|
|
|
public ListPopupWindow(Context context, AttributeSet attributeSet, int i) {
|
|
this(context, attributeSet, i, 0);
|
|
}
|
|
|
|
public ListPopupWindow(Context context, AttributeSet attributeSet, int i, int i2) {
|
|
this.mDropDownHeight = -2;
|
|
this.mDropDownWidth = -2;
|
|
this.mDropDownWindowLayoutType = 1002;
|
|
this.mDropDownGravity = 0;
|
|
this.mDropDownAlwaysVisible = false;
|
|
this.mForceIgnoreOutsideTouch = false;
|
|
this.mListItemExpandMaximum = Integer.MAX_VALUE;
|
|
this.mPromptPosition = 0;
|
|
this.mResizePopupRunnable = new ResizePopupRunnable();
|
|
this.mTouchInterceptor = new PopupTouchInterceptor();
|
|
this.mScrollListener = new PopupScrollListener();
|
|
this.mHideSelector = new ListSelectorHider();
|
|
this.mTempRect = new Rect();
|
|
this.mContext = context;
|
|
this.mHandler = new Handler(context.getMainLooper());
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ListPopupWindow, i, i2);
|
|
this.mDropDownHorizontalOffset = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
|
|
int dimensionPixelOffset = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
|
|
this.mDropDownVerticalOffset = dimensionPixelOffset;
|
|
if (dimensionPixelOffset != 0) {
|
|
this.mDropDownVerticalOffsetSet = true;
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
AppCompatPopupWindow appCompatPopupWindow = new AppCompatPopupWindow(context, attributeSet, i, i2);
|
|
this.mPopup = appCompatPopupWindow;
|
|
appCompatPopupWindow.setInputMethodMode(1);
|
|
}
|
|
|
|
public void setAdapter(ListAdapter listAdapter) {
|
|
DataSetObserver dataSetObserver = this.mObserver;
|
|
if (dataSetObserver == null) {
|
|
this.mObserver = new PopupDataSetObserver();
|
|
} else {
|
|
ListAdapter listAdapter2 = this.mAdapter;
|
|
if (listAdapter2 != null) {
|
|
listAdapter2.unregisterDataSetObserver(dataSetObserver);
|
|
}
|
|
}
|
|
this.mAdapter = listAdapter;
|
|
if (listAdapter != null) {
|
|
listAdapter.registerDataSetObserver(this.mObserver);
|
|
}
|
|
DropDownListView dropDownListView = this.mDropDownList;
|
|
if (dropDownListView != null) {
|
|
dropDownListView.setAdapter(this.mAdapter);
|
|
}
|
|
}
|
|
|
|
public void setModal(boolean z) {
|
|
this.mModal = z;
|
|
this.mPopup.setFocusable(z);
|
|
}
|
|
|
|
public void setSoftInputMode(int i) {
|
|
this.mPopup.setSoftInputMode(i);
|
|
}
|
|
|
|
public int getSoftInputMode() {
|
|
return this.mPopup.getSoftInputMode();
|
|
}
|
|
|
|
public Drawable getBackground() {
|
|
return this.mPopup.getBackground();
|
|
}
|
|
|
|
public void setBackgroundDrawable(Drawable drawable) {
|
|
this.mPopup.setBackgroundDrawable(drawable);
|
|
}
|
|
|
|
public void setAnimationStyle(int i) {
|
|
this.mPopup.setAnimationStyle(i);
|
|
}
|
|
|
|
public int getAnimationStyle() {
|
|
return this.mPopup.getAnimationStyle();
|
|
}
|
|
|
|
public void setEpicenterBounds(Rect rect) {
|
|
this.mEpicenterBounds = rect != null ? new Rect(rect) : null;
|
|
}
|
|
|
|
public Rect getEpicenterBounds() {
|
|
if (this.mEpicenterBounds != null) {
|
|
return new Rect(this.mEpicenterBounds);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void setContentWidth(int i) {
|
|
Drawable background = this.mPopup.getBackground();
|
|
if (background != null) {
|
|
background.getPadding(this.mTempRect);
|
|
this.mDropDownWidth = this.mTempRect.left + this.mTempRect.right + i;
|
|
} else {
|
|
setWidth(i);
|
|
}
|
|
}
|
|
|
|
public void setHeight(int i) {
|
|
if (i < 0 && -2 != i && -1 != i) {
|
|
throw new IllegalArgumentException("Invalid height. Must be a positive value, MATCH_PARENT, or WRAP_CONTENT.");
|
|
}
|
|
this.mDropDownHeight = i;
|
|
}
|
|
|
|
public void setPromptView(View view) {
|
|
boolean isShowing = isShowing();
|
|
if (isShowing) {
|
|
removePromptView();
|
|
}
|
|
this.mPromptView = view;
|
|
if (isShowing) {
|
|
show();
|
|
}
|
|
}
|
|
|
|
public void postShow() {
|
|
this.mHandler.post(this.mShowDropDownRunnable);
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
|
public void show() {
|
|
int buildDropDown = buildDropDown();
|
|
boolean isInputMethodNotNeeded = isInputMethodNotNeeded();
|
|
PopupWindowCompat.setWindowLayoutType(this.mPopup, this.mDropDownWindowLayoutType);
|
|
if (this.mPopup.isShowing()) {
|
|
if (ViewCompat.isAttachedToWindow(getAnchorView())) {
|
|
int i = this.mDropDownWidth;
|
|
if (i == -1) {
|
|
i = -1;
|
|
} else if (i == -2) {
|
|
i = getAnchorView().getWidth();
|
|
}
|
|
int i2 = this.mDropDownHeight;
|
|
if (i2 == -1) {
|
|
if (!isInputMethodNotNeeded) {
|
|
buildDropDown = -1;
|
|
}
|
|
if (isInputMethodNotNeeded) {
|
|
this.mPopup.setWidth(this.mDropDownWidth == -1 ? -1 : 0);
|
|
this.mPopup.setHeight(0);
|
|
} else {
|
|
this.mPopup.setWidth(this.mDropDownWidth == -1 ? -1 : 0);
|
|
this.mPopup.setHeight(-1);
|
|
}
|
|
} else if (i2 != -2) {
|
|
buildDropDown = i2;
|
|
}
|
|
this.mPopup.setOutsideTouchable((this.mForceIgnoreOutsideTouch || this.mDropDownAlwaysVisible) ? false : true);
|
|
this.mPopup.update(getAnchorView(), this.mDropDownHorizontalOffset, this.mDropDownVerticalOffset, i < 0 ? -1 : i, buildDropDown < 0 ? -1 : buildDropDown);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
int i3 = this.mDropDownWidth;
|
|
if (i3 == -1) {
|
|
i3 = -1;
|
|
} else if (i3 == -2) {
|
|
i3 = getAnchorView().getWidth();
|
|
}
|
|
int i4 = this.mDropDownHeight;
|
|
if (i4 == -1) {
|
|
buildDropDown = -1;
|
|
} else if (i4 != -2) {
|
|
buildDropDown = i4;
|
|
}
|
|
this.mPopup.setWidth(i3);
|
|
this.mPopup.setHeight(buildDropDown);
|
|
setPopupClipToScreenEnabled(true);
|
|
this.mPopup.setOutsideTouchable((this.mForceIgnoreOutsideTouch || this.mDropDownAlwaysVisible) ? false : true);
|
|
this.mPopup.setTouchInterceptor(this.mTouchInterceptor);
|
|
if (this.mOverlapAnchorSet) {
|
|
PopupWindowCompat.setOverlapAnchor(this.mPopup, this.mOverlapAnchor);
|
|
}
|
|
Api29Impl.setEpicenterBounds(this.mPopup, this.mEpicenterBounds);
|
|
PopupWindowCompat.showAsDropDown(this.mPopup, getAnchorView(), this.mDropDownHorizontalOffset, this.mDropDownVerticalOffset, this.mDropDownGravity);
|
|
this.mDropDownList.setSelection(-1);
|
|
if (!this.mModal || this.mDropDownList.isInTouchMode()) {
|
|
clearListSelection();
|
|
}
|
|
if (this.mModal) {
|
|
return;
|
|
}
|
|
this.mHandler.post(this.mHideSelector);
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
|
public void dismiss() {
|
|
this.mPopup.dismiss();
|
|
removePromptView();
|
|
this.mPopup.setContentView(null);
|
|
this.mDropDownList = null;
|
|
this.mHandler.removeCallbacks(this.mResizePopupRunnable);
|
|
}
|
|
|
|
public void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener) {
|
|
this.mPopup.setOnDismissListener(onDismissListener);
|
|
}
|
|
|
|
private void removePromptView() {
|
|
View view = this.mPromptView;
|
|
if (view != null) {
|
|
ViewParent parent = view.getParent();
|
|
if (parent instanceof ViewGroup) {
|
|
((ViewGroup) parent).removeView(this.mPromptView);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setInputMethodMode(int i) {
|
|
this.mPopup.setInputMethodMode(i);
|
|
}
|
|
|
|
public int getInputMethodMode() {
|
|
return this.mPopup.getInputMethodMode();
|
|
}
|
|
|
|
public void setSelection(int i) {
|
|
DropDownListView dropDownListView = this.mDropDownList;
|
|
if (!isShowing() || dropDownListView == null) {
|
|
return;
|
|
}
|
|
dropDownListView.setListSelectionHidden(false);
|
|
dropDownListView.setSelection(i);
|
|
if (dropDownListView.getChoiceMode() != 0) {
|
|
dropDownListView.setItemChecked(i, true);
|
|
}
|
|
}
|
|
|
|
public void clearListSelection() {
|
|
DropDownListView dropDownListView = this.mDropDownList;
|
|
if (dropDownListView != null) {
|
|
dropDownListView.setListSelectionHidden(true);
|
|
dropDownListView.requestLayout();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.ShowableListMenu
|
|
public boolean isShowing() {
|
|
return this.mPopup.isShowing();
|
|
}
|
|
|
|
public boolean isInputMethodNotNeeded() {
|
|
return this.mPopup.getInputMethodMode() == 2;
|
|
}
|
|
|
|
public boolean performItemClick(int i) {
|
|
if (!isShowing()) {
|
|
return false;
|
|
}
|
|
if (this.mItemClickListener == null) {
|
|
return true;
|
|
}
|
|
DropDownListView dropDownListView = this.mDropDownList;
|
|
this.mItemClickListener.onItemClick(dropDownListView, dropDownListView.getChildAt(i - dropDownListView.getFirstVisiblePosition()), i, dropDownListView.getAdapter().getItemId(i));
|
|
return true;
|
|
}
|
|
|
|
public Object getSelectedItem() {
|
|
if (isShowing()) {
|
|
return this.mDropDownList.getSelectedItem();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int getSelectedItemPosition() {
|
|
if (isShowing()) {
|
|
return this.mDropDownList.getSelectedItemPosition();
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public long getSelectedItemId() {
|
|
if (isShowing()) {
|
|
return this.mDropDownList.getSelectedItemId();
|
|
}
|
|
return Long.MIN_VALUE;
|
|
}
|
|
|
|
public View getSelectedView() {
|
|
if (isShowing()) {
|
|
return this.mDropDownList.getSelectedView();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
DropDownListView createDropDownListView(Context context, boolean z) {
|
|
return new DropDownListView(context, z);
|
|
}
|
|
|
|
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
|
int i2;
|
|
int i3;
|
|
if (isShowing() && i != 62 && (this.mDropDownList.getSelectedItemPosition() >= 0 || !isConfirmKey(i))) {
|
|
int selectedItemPosition = this.mDropDownList.getSelectedItemPosition();
|
|
boolean z = !this.mPopup.isAboveAnchor();
|
|
ListAdapter listAdapter = this.mAdapter;
|
|
if (listAdapter != null) {
|
|
boolean areAllItemsEnabled = listAdapter.areAllItemsEnabled();
|
|
i2 = areAllItemsEnabled ? 0 : this.mDropDownList.lookForSelectablePosition(0, true);
|
|
if (areAllItemsEnabled) {
|
|
i3 = listAdapter.getCount() - 1;
|
|
} else {
|
|
i3 = this.mDropDownList.lookForSelectablePosition(listAdapter.getCount() - 1, false);
|
|
}
|
|
} else {
|
|
i2 = Integer.MAX_VALUE;
|
|
i3 = Integer.MIN_VALUE;
|
|
}
|
|
if ((z && i == 19 && selectedItemPosition <= i2) || (!z && i == 20 && selectedItemPosition >= i3)) {
|
|
clearListSelection();
|
|
this.mPopup.setInputMethodMode(1);
|
|
show();
|
|
return true;
|
|
}
|
|
this.mDropDownList.setListSelectionHidden(false);
|
|
if (this.mDropDownList.onKeyDown(i, keyEvent)) {
|
|
this.mPopup.setInputMethodMode(2);
|
|
this.mDropDownList.requestFocusFromTouch();
|
|
show();
|
|
if (i == 19 || i == 20 || i == 23 || i == 66) {
|
|
return true;
|
|
}
|
|
} else if (z && i == 20) {
|
|
if (selectedItemPosition == i3) {
|
|
return true;
|
|
}
|
|
} else if (!z && i == 19 && selectedItemPosition == i2) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean onKeyUp(int i, KeyEvent keyEvent) {
|
|
if (!isShowing() || this.mDropDownList.getSelectedItemPosition() < 0) {
|
|
return false;
|
|
}
|
|
boolean onKeyUp = this.mDropDownList.onKeyUp(i, keyEvent);
|
|
if (onKeyUp && isConfirmKey(i)) {
|
|
dismiss();
|
|
}
|
|
return onKeyUp;
|
|
}
|
|
|
|
public boolean onKeyPreIme(int i, KeyEvent keyEvent) {
|
|
if (i != 4 || !isShowing()) {
|
|
return false;
|
|
}
|
|
View view = this.mDropDownAnchorView;
|
|
if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() == 0) {
|
|
KeyEvent.DispatcherState keyDispatcherState = view.getKeyDispatcherState();
|
|
if (keyDispatcherState != null) {
|
|
keyDispatcherState.startTracking(keyEvent, this);
|
|
}
|
|
return true;
|
|
}
|
|
if (keyEvent.getAction() != 1) {
|
|
return false;
|
|
}
|
|
KeyEvent.DispatcherState keyDispatcherState2 = view.getKeyDispatcherState();
|
|
if (keyDispatcherState2 != null) {
|
|
keyDispatcherState2.handleUpEvent(keyEvent);
|
|
}
|
|
if (!keyEvent.isTracking() || keyEvent.isCanceled()) {
|
|
return false;
|
|
}
|
|
dismiss();
|
|
return true;
|
|
}
|
|
|
|
public View.OnTouchListener createDragToOpenListener(View view) {
|
|
return new ForwardingListener(view) { // from class: androidx.appcompat.widget.ListPopupWindow.1
|
|
@Override // androidx.appcompat.widget.ForwardingListener
|
|
public ListPopupWindow getPopup() {
|
|
return ListPopupWindow.this;
|
|
}
|
|
};
|
|
}
|
|
|
|
private int buildDropDown() {
|
|
int i;
|
|
int i2;
|
|
int makeMeasureSpec;
|
|
int i3;
|
|
if (this.mDropDownList == null) {
|
|
Context context = this.mContext;
|
|
this.mShowDropDownRunnable = new Runnable() { // from class: androidx.appcompat.widget.ListPopupWindow.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
View anchorView = ListPopupWindow.this.getAnchorView();
|
|
if (anchorView == null || anchorView.getWindowToken() == null) {
|
|
return;
|
|
}
|
|
ListPopupWindow.this.show();
|
|
}
|
|
};
|
|
DropDownListView createDropDownListView = createDropDownListView(context, !this.mModal);
|
|
this.mDropDownList = createDropDownListView;
|
|
Drawable drawable = this.mDropDownListHighlight;
|
|
if (drawable != null) {
|
|
createDropDownListView.setSelector(drawable);
|
|
}
|
|
this.mDropDownList.setAdapter(this.mAdapter);
|
|
this.mDropDownList.setOnItemClickListener(this.mItemClickListener);
|
|
this.mDropDownList.setFocusable(true);
|
|
this.mDropDownList.setFocusableInTouchMode(true);
|
|
this.mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // from class: androidx.appcompat.widget.ListPopupWindow.3
|
|
@Override // android.widget.AdapterView.OnItemSelectedListener
|
|
public void onNothingSelected(AdapterView<?> adapterView) {
|
|
}
|
|
|
|
@Override // android.widget.AdapterView.OnItemSelectedListener
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i4, long j) {
|
|
DropDownListView dropDownListView;
|
|
if (i4 == -1 || (dropDownListView = ListPopupWindow.this.mDropDownList) == null) {
|
|
return;
|
|
}
|
|
dropDownListView.setListSelectionHidden(false);
|
|
}
|
|
});
|
|
this.mDropDownList.setOnScrollListener(this.mScrollListener);
|
|
AdapterView.OnItemSelectedListener onItemSelectedListener = this.mItemSelectedListener;
|
|
if (onItemSelectedListener != null) {
|
|
this.mDropDownList.setOnItemSelectedListener(onItemSelectedListener);
|
|
}
|
|
View view = this.mDropDownList;
|
|
View view2 = this.mPromptView;
|
|
if (view2 != null) {
|
|
LinearLayout linearLayout = new LinearLayout(context);
|
|
linearLayout.setOrientation(1);
|
|
ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, 0, 1.0f);
|
|
int i4 = this.mPromptPosition;
|
|
if (i4 == 0) {
|
|
linearLayout.addView(view2);
|
|
linearLayout.addView(view, layoutParams);
|
|
} else if (i4 == 1) {
|
|
linearLayout.addView(view, layoutParams);
|
|
linearLayout.addView(view2);
|
|
} else {
|
|
Log.e(TAG, "Invalid hint position " + this.mPromptPosition);
|
|
}
|
|
int i5 = this.mDropDownWidth;
|
|
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() + layoutParams2.topMargin + layoutParams2.bottomMargin;
|
|
view = linearLayout;
|
|
} else {
|
|
i = 0;
|
|
}
|
|
this.mPopup.setContentView(view);
|
|
} else {
|
|
View view3 = this.mPromptView;
|
|
if (view3 != null) {
|
|
LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) view3.getLayoutParams();
|
|
i = view3.getMeasuredHeight() + layoutParams3.topMargin + layoutParams3.bottomMargin;
|
|
} else {
|
|
i = 0;
|
|
}
|
|
}
|
|
Drawable background = this.mPopup.getBackground();
|
|
if (background != null) {
|
|
background.getPadding(this.mTempRect);
|
|
i2 = this.mTempRect.top + this.mTempRect.bottom;
|
|
if (!this.mDropDownVerticalOffsetSet) {
|
|
this.mDropDownVerticalOffset = -this.mTempRect.top;
|
|
}
|
|
} else {
|
|
this.mTempRect.setEmpty();
|
|
i2 = 0;
|
|
}
|
|
int maxAvailableHeight = getMaxAvailableHeight(getAnchorView(), this.mDropDownVerticalOffset, this.mPopup.getInputMethodMode() == 2);
|
|
if (this.mDropDownAlwaysVisible || this.mDropDownHeight == -1) {
|
|
return maxAvailableHeight + i2;
|
|
}
|
|
int i6 = this.mDropDownWidth;
|
|
if (i6 == -2) {
|
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(this.mContext.getResources().getDisplayMetrics().widthPixels - (this.mTempRect.left + this.mTempRect.right), Integer.MIN_VALUE);
|
|
} else if (i6 == -1) {
|
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(this.mContext.getResources().getDisplayMetrics().widthPixels - (this.mTempRect.left + this.mTempRect.right), 1073741824);
|
|
} else {
|
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i6, 1073741824);
|
|
}
|
|
int measureHeightOfChildrenCompat = this.mDropDownList.measureHeightOfChildrenCompat(makeMeasureSpec, 0, -1, maxAvailableHeight - i, -1);
|
|
if (measureHeightOfChildrenCompat > 0) {
|
|
i += i2 + this.mDropDownList.getPaddingTop() + this.mDropDownList.getPaddingBottom();
|
|
}
|
|
return measureHeightOfChildrenCompat + i;
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
private class PopupDataSetObserver extends DataSetObserver {
|
|
PopupDataSetObserver() {
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onChanged() {
|
|
if (ListPopupWindow.this.isShowing()) {
|
|
ListPopupWindow.this.show();
|
|
}
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onInvalidated() {
|
|
ListPopupWindow.this.dismiss();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes.dex */
|
|
public class ListSelectorHider implements Runnable {
|
|
ListSelectorHider() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ListPopupWindow.this.clearListSelection();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes.dex */
|
|
public class ResizePopupRunnable implements Runnable {
|
|
ResizePopupRunnable() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (ListPopupWindow.this.mDropDownList == null || !ViewCompat.isAttachedToWindow(ListPopupWindow.this.mDropDownList) || ListPopupWindow.this.mDropDownList.getCount() <= ListPopupWindow.this.mDropDownList.getChildCount() || ListPopupWindow.this.mDropDownList.getChildCount() > ListPopupWindow.this.mListItemExpandMaximum) {
|
|
return;
|
|
}
|
|
ListPopupWindow.this.mPopup.setInputMethodMode(2);
|
|
ListPopupWindow.this.show();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes.dex */
|
|
public class PopupTouchInterceptor implements View.OnTouchListener {
|
|
PopupTouchInterceptor() {
|
|
}
|
|
|
|
@Override // android.view.View.OnTouchListener
|
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
int action = motionEvent.getAction();
|
|
int x = (int) motionEvent.getX();
|
|
int y = (int) motionEvent.getY();
|
|
if (action == 0 && ListPopupWindow.this.mPopup != null && ListPopupWindow.this.mPopup.isShowing() && x >= 0 && x < ListPopupWindow.this.mPopup.getWidth() && y >= 0 && y < ListPopupWindow.this.mPopup.getHeight()) {
|
|
ListPopupWindow.this.mHandler.postDelayed(ListPopupWindow.this.mResizePopupRunnable, 250L);
|
|
return false;
|
|
}
|
|
if (action != 1) {
|
|
return false;
|
|
}
|
|
ListPopupWindow.this.mHandler.removeCallbacks(ListPopupWindow.this.mResizePopupRunnable);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes.dex */
|
|
public class PopupScrollListener implements AbsListView.OnScrollListener {
|
|
@Override // android.widget.AbsListView.OnScrollListener
|
|
public void onScroll(AbsListView absListView, int i, int i2, int i3) {
|
|
}
|
|
|
|
PopupScrollListener() {
|
|
}
|
|
|
|
@Override // android.widget.AbsListView.OnScrollListener
|
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
|
if (i != 1 || ListPopupWindow.this.isInputMethodNotNeeded() || ListPopupWindow.this.mPopup.getContentView() == null) {
|
|
return;
|
|
}
|
|
ListPopupWindow.this.mHandler.removeCallbacks(ListPopupWindow.this.mResizePopupRunnable);
|
|
ListPopupWindow.this.mResizePopupRunnable.run();
|
|
}
|
|
}
|
|
|
|
private void setPopupClipToScreenEnabled(boolean z) {
|
|
Api29Impl.setIsClippedToScreen(this.mPopup, z);
|
|
}
|
|
|
|
private int getMaxAvailableHeight(View view, int i, boolean z) {
|
|
return Api24Impl.getMaxAvailableHeight(this.mPopup, view, i, z);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class Api29Impl {
|
|
private Api29Impl() {
|
|
}
|
|
|
|
static void setEpicenterBounds(PopupWindow popupWindow, Rect rect) {
|
|
popupWindow.setEpicenterBounds(rect);
|
|
}
|
|
|
|
static void setIsClippedToScreen(PopupWindow popupWindow, boolean z) {
|
|
popupWindow.setIsClippedToScreen(z);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class Api24Impl {
|
|
private Api24Impl() {
|
|
}
|
|
|
|
static int getMaxAvailableHeight(PopupWindow popupWindow, View view, int i, boolean z) {
|
|
return popupWindow.getMaxAvailableHeight(view, i, z);
|
|
}
|
|
}
|
|
}
|