Cancel media uploads when closing ComposeActivity #838 (#1189)

* Cancel media uploads on remove the draft message

* Fix formatting
This commit is contained in:
pandasoft0 2019-04-12 23:10:52 +03:00 committed by Konrad Pozniak
parent 84f561af17
commit bc3ea2357b

View file

@ -1539,13 +1539,21 @@ public final class ComposeActivity
new AlertDialog.Builder(this)
.setMessage(R.string.compose_save_draft)
.setPositiveButton(R.string.action_save, (d, w) -> saveDraftAndFinish())
.setNegativeButton(R.string.action_delete, (d, w) -> finishWithoutSlideOutAnimation())
.setNegativeButton(R.string.action_delete, (d, w) -> deleteDraftAndFinish())
.show();
} else {
finishWithoutSlideOutAnimation();
}
}
private void deleteDraftAndFinish() {
for (QueuedMedia media : mediaQueued) {
if (media.uploadRequest != null)
media.uploadRequest.cancel();
}
finishWithoutSlideOutAnimation();
}
private void saveDraftAndFinish() {
ArrayList<String> mediaUris = new ArrayList<>();
ArrayList<String> mediaDescriptions = new ArrayList<>();