@@ -117,16 +117,16 @@ public void dismiss(Promise promise) {
117
117
* dismiss, year, month and date are undefined.
118
118
*/
119
119
@ ReactMethod
120
- public void open (@ Nullable final ReadableMap options , Promise promise ) {
120
+ public void open (@ Nullable final ReadableMap options , final Promise promise ) {
121
121
FragmentActivity activity = (FragmentActivity ) getCurrentActivity ();
122
122
if (activity == null ) {
123
123
promise .reject (
124
- RNConstants .ERROR_NO_ACTIVITY ,
125
- "Tried to open a DatePicker dialog while not attached to an Activity" );
124
+ RNConstants .ERROR_NO_ACTIVITY ,
125
+ "Tried to open a DatePicker dialog while not attached to an Activity" );
126
126
return ;
127
127
}
128
128
129
- FragmentManager fragmentManager = activity .getSupportFragmentManager ();
129
+ final FragmentManager fragmentManager = activity .getSupportFragmentManager ();
130
130
final RNDatePickerDialogFragment oldFragment = (RNDatePickerDialogFragment ) fragmentManager .findFragmentByTag (FRAGMENT_TAG );
131
131
132
132
if (oldFragment != null && options != null ) {
@@ -140,17 +140,22 @@ public void run() {
140
140
return ;
141
141
}
142
142
143
- RNDatePickerDialogFragment fragment = new RNDatePickerDialogFragment ();
143
+ UiThreadUtil .runOnUiThread (new Runnable () {
144
+ @ Override
145
+ public void run () {
146
+ RNDatePickerDialogFragment fragment = new RNDatePickerDialogFragment ();
144
147
145
- if (options != null ) {
146
- fragment .setArguments (createFragmentArguments (options ));
147
- }
148
+ if (options != null ) {
149
+ fragment .setArguments (createFragmentArguments (options ));
150
+ }
148
151
149
- final DatePickerDialogListener listener = new DatePickerDialogListener (promise );
150
- fragment .setOnDismissListener (listener );
151
- fragment .setOnDateSetListener (listener );
152
- fragment .setOnNeutralButtonActionListener (listener );
153
- fragment .show (fragmentManager , FRAGMENT_TAG );
152
+ final DatePickerDialogListener listener = new DatePickerDialogListener (promise );
153
+ fragment .setOnDismissListener (listener );
154
+ fragment .setOnDateSetListener (listener );
155
+ fragment .setOnNeutralButtonActionListener (listener );
156
+ fragment .show (fragmentManager , FRAGMENT_TAG );
157
+ }
158
+ });
154
159
}
155
160
156
161
private Bundle createFragmentArguments (ReadableMap options ) {
0 commit comments