41
41
public class RNDocumentPickerModule extends NativeDocumentPickerSpec {
42
42
private final Executor executor = Executors .newSingleThreadExecutor ();
43
43
private final Handler handler = new Handler (Looper .getMainLooper ());
44
+ private final ReactApplicationContext reactContext ;
44
45
public static final String NAME = "RNDocumentPicker" ;
45
46
private static final int READ_REQUEST_CODE = 41 ;
46
47
private static final int PICK_DIR_REQUEST_CODE = 42 ;
@@ -69,6 +70,7 @@ public class RNDocumentPickerModule extends NativeDocumentPickerSpec {
69
70
70
71
public RNDocumentPickerModule (ReactApplicationContext reactContext ) {
71
72
super (reactContext );
73
+ this .reactContext = reactContext ;
72
74
reactContext .addActivityEventListener (activityEventListener );
73
75
}
74
76
@@ -227,9 +229,9 @@ public void onShowActivityResult(int resultCode, Intent data, Promise promise) {
227
229
}
228
230
executor .execute (() -> {
229
231
try {
230
- ReadableMap data = processData (uris , copyTo );
232
+ ReadableArray result = processData (uris );
231
233
handler .post (() -> {
232
- promise .resolve (data );
234
+ promise .resolve (result );
233
235
});
234
236
} catch (IOException e ) {
235
237
handler .post (() -> {
@@ -242,7 +244,7 @@ public void onShowActivityResult(int resultCode, Intent data, Promise promise) {
242
244
}
243
245
}
244
246
245
- private ReadableMap processData (List <Uri > uris , String copyTo ) throws IOException {
247
+ private ReadableArray processData (List <Uri > uris ) throws IOException {
246
248
WritableArray results = Arguments .createArray ();
247
249
for (Uri uri : uris ) {
248
250
results .pushMap (getMetadata (uri ));
@@ -251,7 +253,7 @@ private ReadableMap processData(List<Uri> uris, String copyTo) throws IOExceptio
251
253
}
252
254
253
255
private WritableMap getMetadata (Uri uri ) {
254
- Context context = weakContext . get () ;
256
+ Context context = reactContext ;
255
257
if (context == null ) {
256
258
return Arguments .createMap ();
257
259
}
@@ -350,4 +352,4 @@ private void sendError(String code, String message, Exception e) {
350
352
temp .reject (code , message , e );
351
353
}
352
354
}
353
- }
355
+ }
0 commit comments