Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49bb84e8 authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge "Fix for potential race condition in Spinners Added measure to try &...

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"
parents c40ba07d 70fe4d60
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 {
+2 −1
Original line number Diff line number Diff line
@@ -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));
        }
    }

+15 −0
Original line number Diff line number Diff line
@@ -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();