Skip to content

Commit

Permalink
Merge pull request joltup#237 from ZaycevDmitriy/fix_bug_#179_Illegal…
Browse files Browse the repository at this point in the history
…_callback_invocation

Fix bug Illegal callback invocation from native module
  • Loading branch information
RonRadtke authored May 22, 2023
2 parents 132051c + 513696f commit f2d7d8f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ public void onReceive(Context context, Intent intent) {
Cursor c = dm.query(query);
// #236 unhandled null check for DownloadManager.query() return value
if (c == null) {
this.callback.invoke("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
this.invoke_callback("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
return;
}

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

} catch (Exception ex) {
ex.printStackTrace();
this.callback.invoke(ex.getLocalizedMessage(), null);
this.invoke_callback(ex.getLocalizedMessage(), null);
}
} else {
if (filePath == null)
this.callback.invoke("Download manager could not resolve downloaded file path.", ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, null);
this.invoke_callback("Download manager could not resolve downloaded file path.", ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, null);
else
this.callback.invoke(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, filePath);
this.invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, filePath);
}

}
Expand Down

0 comments on commit f2d7d8f

Please sign in to comment.