From 494a04ffb16d9967b947c96bd7c1ce2723da0db0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 15 Jan 2016 23:47:55 +0100 Subject: [PATCH] hide prepare image toasts when attaching multiple images --- .../ui/ConversationActivity.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 97849b6d0..2f6ebe33c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -112,8 +112,6 @@ public class ConversationActivity extends XmppActivity private ArrayAdapter listAdapter; - private Toast prepareFileToast; - private boolean mActivityPaused = false; private AtomicBoolean mRedirected = new AtomicBoolean(false); private Pair mPostponedActivityResult; @@ -1250,6 +1248,9 @@ public class ConversationActivity extends XmppActivity @SuppressLint("NewApi") private static List extractUriFromIntent(final Intent intent) { List uris = new ArrayList<>(); + if (intent == null) { + return uris; + } Uri uri = intent.getData(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && uri == null) { ClipData clipData = intent.getClipData(); @@ -1397,17 +1398,18 @@ public class ConversationActivity extends XmppActivity if (conversation == null) { return; } - prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_file), Toast.LENGTH_LONG); + final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_file), Toast.LENGTH_LONG); prepareFileToast.show(); xmppConnectionService.attachFileToConversation(conversation, uri, new UiCallback() { @Override public void success(Message message) { - hidePrepareFileToast(); + hidePrepareFileToast(prepareFileToast); xmppConnectionService.sendMessage(message); } @Override public void error(int errorCode, Message message) { + hidePrepareFileToast(prepareFileToast); displayErrorDialog(errorCode); } @@ -1422,32 +1424,31 @@ public class ConversationActivity extends XmppActivity if (conversation == null) { return; } - prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_image), Toast.LENGTH_LONG); + final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_image), Toast.LENGTH_LONG); prepareFileToast.show(); xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback() { @Override - public void userInputRequried(PendingIntent pi, - Message object) { - hidePrepareFileToast(); + public void userInputRequried(PendingIntent pi, Message object) { + hidePrepareFileToast(prepareFileToast); } @Override public void success(Message message) { - hidePrepareFileToast(); + hidePrepareFileToast(prepareFileToast); xmppConnectionService.sendMessage(message); } @Override public void error(int error, Message message) { - hidePrepareFileToast(); + hidePrepareFileToast(prepareFileToast); displayErrorDialog(error); } }); } - private void hidePrepareFileToast() { + private void hidePrepareFileToast(final Toast prepareFileToast) { if (prepareFileToast != null) { runOnUiThread(new Runnable() {