Skip to content

Commit

Permalink
code complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed Sep 10, 2024
1 parent 594f8bd commit fb8834c
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/android/FileTransferBackground.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,35 +410,35 @@ private void acknowledgeEvent(String eventId, CallbackContext context) {
* Handle ACK data and send it to the JS.
*/
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));
}
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 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);
}
long startUploadTime = ackData.getLong("output_upload_start_time", 0);
long finishUploadTime = ackData.getLong("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);
}

sendSuccess(uploadData);
sendSuccess(uploadData);
}
}
}

/**
* Cleanup response file and ACK entry.
Expand Down

0 comments on commit fb8834c

Please sign in to comment.