Skip to content

Commit

Permalink
hashir review
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed Sep 12, 2024
1 parent 62c95ff commit c8349f4
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/android/FileTransferBackground.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,31 +411,28 @@ private void acknowledgeEvent(String eventId, CallbackContext context) {
*/
private void handleAck(final Data ackData) {
if (!ackData.getBoolean(UploadTask.KEY_OUTPUT_IS_ERROR, false)) {
sendError(
ackData.getString(UploadTask.KEY_OUTPUT_ID),
ackData.getString(UploadTask.KEY_OUTPUT_FAILURE_REASON),
ackData.getBoolean(UploadTask.KEY_OUTPUT_FAILURE_CANCELED, false)
);
} else {
String response = null;
if (ackData.getString(UploadTask.KEY_OUTPUT_RESPONSE_FILE) != null) {
response = readFileToStringNoThrow(ackData.getString(UploadTask.KEY_OUTPUT_RESPONSE_FILE));
}

long startUploadTime = ackData.getLong("output_upload_start_time", 0);
long finishUploadTime = ackData.getLong("output_upload_finish_time", 0);
long startUploadTime = ackData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_START_TIME, 0);
long finishUploadTime = ackData.getLong(UploadTask.KEY_OUTPUT_UPLOAD_FINISH_TIME, 0);
long uploadDuration = finishUploadTime - startUploadTime;

HashMap<String, Object> uploadData = new HashMap<>();
uploadData.put("outputId", ackData.getString(UploadTask.KEY_OUTPUT_ID));
uploadData.put("response", response);
uploadData.put("statusCode", ackData.getInt(UploadTask.KEY_OUTPUT_STATUS_CODE, -1));

if (uploadDuration > 0) {
uploadData.put("uploadDuration", uploadDuration);
uploadData.put("finishUploadTime", finishUploadTime);
}
uploadData.put("uploadDuration", uploadDuration);
uploadData.put("finishUploadTime", finishUploadTime);
sendSuccess(uploadData);
} else {
sendError(
ackData.getString(UploadTask.KEY_OUTPUT_ID),
ackData.getString(UploadTask.KEY_OUTPUT_FAILURE_REASON),
ackData.getBoolean(UploadTask.KEY_OUTPUT_FAILURE_CANCELED, false)
);
}
}

Expand Down

0 comments on commit c8349f4

Please sign in to comment.