Fix onItemSelected firing for ReactPicker on initial layout.

Reviewed By: AaaChiuuu

Differential Revision: D3732557

fbshipit-source-id: ed031dbf205996dab8cb0555af972e6f26c0d202
This commit is contained in:
Don Yu 2016-08-17 22:07:33 -07:00 committed by Facebook Github Bot 2
parent 50e0d8e171
commit a2a8d7f5da
1 changed files with 4 additions and 0 deletions

View File

@ -79,6 +79,10 @@ public class ReactPicker extends Spinner {
public void setOnSelectListener(@Nullable OnSelectListener onSelectListener) {
if (getOnItemSelectedListener() == null) {
// onItemSelected gets fired immediately after layout because checkSelectionChanged() in
// AdapterView updates the selection position from the default INVALID_POSITION. To match iOS
// behavior, we don't want the event emitter for onItemSelected to fire right after layout.
mSuppressNextEvent = true;
setOnItemSelectedListener(
new OnItemSelectedListener() {
@Override