Skip to content

Commit 513696f

Browse files
committed
fix: fix bug Illegal callback invocation from native module
1 parent 132051c commit 513696f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ public void onReceive(Context context, Intent intent) {
864864
Cursor c = dm.query(query);
865865
// #236 unhandled null check for DownloadManager.query() return value
866866
if (c == null) {
867-
this.callback.invoke("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
867+
this.invoke_callback("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
868868
return;
869869
}
870870

@@ -875,7 +875,7 @@ public void onReceive(Context context, Intent intent) {
875875
// #297 handle failed request
876876
int statusCode = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
877877
if (statusCode == DownloadManager.STATUS_FAILED) {
878-
this.callback.invoke("Download manager failed to download from " + this.url + ". Status Code = " + statusCode, null, null);
878+
this.invoke_callback("Download manager failed to download from " + this.url + ". Status Code = " + statusCode, null, null);
879879
return;
880880
}
881881
String contentUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
@@ -904,17 +904,17 @@ public void onReceive(Context context, Intent intent) {
904904
if (!exists)
905905
throw new Exception("Download manager download failed, the file does not downloaded to destination.");
906906
else
907-
this.callback.invoke(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, customDest);
907+
this.invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, customDest);
908908

909909
} catch (Exception ex) {
910910
ex.printStackTrace();
911-
this.callback.invoke(ex.getLocalizedMessage(), null);
911+
this.invoke_callback(ex.getLocalizedMessage(), null);
912912
}
913913
} else {
914914
if (filePath == null)
915-
this.callback.invoke("Download manager could not resolve downloaded file path.", ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, null);
915+
this.invoke_callback("Download manager could not resolve downloaded file path.", ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, null);
916916
else
917-
this.callback.invoke(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, filePath);
917+
this.invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, filePath);
918918
}
919919

920920
}

0 commit comments

Comments
 (0)