Merge "Fix for potential race condition in Spinners Added measure to try & ensure popups have time to collapse before trying to send TYPE_VIEW_SELECTED"
This commit is contained in:
@@ -3274,6 +3274,7 @@ package android.widget {
|
||||
|
||||
public class Spinner extends android.widget.AbsSpinner implements android.content.DialogInterface.OnClickListener {
|
||||
method public boolean isPopupShowing();
|
||||
method public void onClick(int);
|
||||
}
|
||||
|
||||
@android.widget.RemoteViews.RemoteView public class TextClock extends android.widget.TextView {
|
||||
|
||||
@@ -968,7 +968,8 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
||||
final int position = getSelectedItemPosition();
|
||||
if (position >= 0) {
|
||||
// we fire selection events here not in View
|
||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
|
||||
// posting the event should delay it long enough for UI changes to take effect.
|
||||
post(() -> sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -802,6 +802,21 @@ public class Spinner extends AbsSpinner implements OnClickListener {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets selection and dismisses the spinner's popup if it can be dismissed.
|
||||
* For ease of use in tests, where publicly obtaining the spinner's popup is difficult.
|
||||
*
|
||||
* @param which index of the item to be selected.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public void onClick(int which) {
|
||||
setSelection(which);
|
||||
if (mPopup != null && mPopup.isShowing()) {
|
||||
mPopup.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getAccessibilityClassName() {
|
||||
return Spinner.class.getName();
|
||||
|
||||
Reference in New Issue
Block a user