diff --git a/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java b/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java index d874b57c..40a38f66 100644 --- a/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java +++ b/android/src/main/java/com/henninghall/date_picker/DatePickerModuleImpl.java @@ -13,6 +13,8 @@ import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMapKeySetIterator; +import com.henninghall.date_picker.ui.SpinnerState; +import com.henninghall.date_picker.ui.SpinnerStateListener; import net.time4j.android.ApplicationStarter; @@ -126,9 +128,21 @@ private PickerView createPicker(ReadableMap props){ } } picker.update(); + + picker.addSpinnerStateListener(new SpinnerStateListener() { + @Override + public void onChange(SpinnerState state) { + setEnabledConfirmButton(state == SpinnerState.idle); + } + }); + return picker; } + private void setEnabledConfirmButton(boolean enabled) { + dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled); + } + private View withTopMargin(PickerView view) { LinearLayout linearLayout = new LinearLayout(DatePickerPackage.context); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(