mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 17:08:25 +00:00
Utilise dialog dsl in DeleteMediaPreviewDialog
This commit is contained in:
parent
975f9fc4d1
commit
94b48d5fb9
@ -0,0 +1,19 @@
|
|||||||
|
package org.thoughtcrime.securesms
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import network.loki.messenger.R
|
||||||
|
|
||||||
|
class DeleteMediaPreviewDialog {
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun show(context: Context, doDelete: Runnable) {
|
||||||
|
context.showSessionDialog {
|
||||||
|
iconAttribute(R.attr.dialog_alert_icon)
|
||||||
|
title(R.string.MediaPreviewActivity_media_delete_confirmation_title)
|
||||||
|
text(R.string.MediaPreviewActivity_media_delete_confirmation_message)
|
||||||
|
button(R.string.delete) { doDelete.run() }
|
||||||
|
cancelButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -451,29 +451,20 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
DeleteMediaPreviewDialog.show(this, () -> {
|
||||||
builder.setIconAttribute(R.attr.dialog_alert_icon);
|
new AsyncTask<Void, Void, Void>() {
|
||||||
builder.setTitle(R.string.MediaPreviewActivity_media_delete_confirmation_title);
|
@Override
|
||||||
builder.setMessage(R.string.MediaPreviewActivity_media_delete_confirmation_message);
|
protected Void doInBackground(Void... voids) {
|
||||||
builder.setCancelable(true);
|
DatabaseAttachment attachment = mediaItem.attachment;
|
||||||
|
if (attachment != null) {
|
||||||
builder.setPositiveButton(R.string.delete, (dialogInterface, which) -> {
|
AttachmentUtil.deleteAttachment(getApplicationContext(), attachment);
|
||||||
new AsyncTask<Void, Void, Void>() {
|
}
|
||||||
@Override
|
return null;
|
||||||
protected Void doInBackground(Void... voids) {
|
}
|
||||||
if (mediaItem.attachment == null) {
|
}.execute();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
AttachmentUtil.deleteAttachment(MediaPreviewActivity.this.getApplicationContext(),
|
|
||||||
mediaItem.attachment);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.execute();
|
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(android.R.string.cancel, null);
|
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user