File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed
ReactAndroid/src/main/java/com/facebook/react/modules Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 7
7
8
8
package com .facebook .react .modules .datepicker ;
9
9
10
-
10
+ import android . app . Activity ;
11
11
import android .app .DatePickerDialog .OnDateSetListener ;
12
12
import android .content .DialogInterface ;
13
13
import android .content .DialogInterface .OnDismissListener ;
@@ -112,14 +112,16 @@ public void onDismiss(DialogInterface dialog) {
112
112
*/
113
113
@ ReactMethod
114
114
public void open (@ Nullable final ReadableMap options , Promise promise ) {
115
- FragmentActivity activity = ( FragmentActivity ) getCurrentActivity ();
116
- if (activity == null ) {
115
+ Activity raw_activity = getCurrentActivity ();
116
+ if (raw_activity == null || !( raw_activity instanceof FragmentActivity ) ) {
117
117
promise .reject (
118
118
ERROR_NO_ACTIVITY ,
119
- "Tried to open a DatePicker dialog while not attached to an Activity " );
119
+ "Tried to open a DatePicker dialog while not attached to a FragmentActivity " );
120
120
return ;
121
121
}
122
122
123
+ FragmentActivity activity = (FragmentActivity ) raw_activity ;
124
+
123
125
FragmentManager fragmentManager = activity .getSupportFragmentManager ();
124
126
DialogFragment oldFragment = (DialogFragment ) fragmentManager .findFragmentByTag (FRAGMENT_TAG );
125
127
if (oldFragment != null ) {
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ public void run() {
239
239
*/
240
240
private @ Nullable FragmentManagerHelper getFragmentManagerHelper () {
241
241
Activity activity = getCurrentActivity ();
242
- if (activity == null ) {
242
+ if (activity == null || !( activity instanceof FragmentActivity ) ) {
243
243
return null ;
244
244
}
245
245
return new FragmentManagerHelper (((FragmentActivity ) activity ).getSupportFragmentManager ());
Original file line number Diff line number Diff line change 7
7
8
8
package com .facebook .react .modules .timepicker ;
9
9
10
+ import android .app .Activity ;
10
11
import android .app .TimePickerDialog .OnTimeSetListener ;
11
12
import android .content .DialogInterface ;
12
13
import android .content .DialogInterface .OnDismissListener ;
@@ -92,13 +93,16 @@ public void onDismiss(DialogInterface dialog) {
92
93
@ ReactMethod
93
94
public void open (@ Nullable final ReadableMap options , Promise promise ) {
94
95
95
- FragmentActivity activity = ( FragmentActivity ) getCurrentActivity ();
96
- if (activity == null ) {
96
+ Activity raw_activity = getCurrentActivity ();
97
+ if (raw_activity == null || !( raw_activity instanceof FragmentActivity ) ) {
97
98
promise .reject (
98
- ERROR_NO_ACTIVITY ,
99
- "Tried to open a TimePicker dialog while not attached to an Activity " );
99
+ ERROR_NO_ACTIVITY ,
100
+ "Tried to open a DatePicker dialog while not attached to a FragmentActivity " );
100
101
return ;
101
102
}
103
+
104
+ FragmentActivity activity = (FragmentActivity ) raw_activity ;
105
+
102
106
// We want to support both android.app.Activity and the pre-Honeycomb FragmentActivity
103
107
// (for apps that use it for legacy reasons). This unfortunately leads to some code duplication.
104
108
FragmentManager fragmentManager = activity .getSupportFragmentManager ();
You can’t perform that action at this time.
0 commit comments