Do not clear message box after upload but before final upload

Stephen Paul Weber created

Change summary

src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 6 
1 file changed, 4 insertions(+), 2 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/ConversationFragment.java 🔗

@@ -1261,6 +1261,7 @@ public class ConversationFragment extends XmppFragment
                         @Override
                         public void run() {
                             try {
+                                if (!i.hasNext()) return;
                                 final Attachment attachment = i.next();
                                 if (attachment.getType() == Attachment.Type.LOCATION) {
                                         attachLocationToConversation(conversation, attachment.getUri());
@@ -1269,14 +1270,15 @@ public class ConversationFragment extends XmppFragment
                                     Log.d(
                                           Config.LOGTAG,
                                           "ConversationsActivity.commitAttachments() - attaching image to conversations. CHOOSE_IMAGE");
-                                    attachImageToConversation(conversation, attachment.getUri(), attachment.getMime(), i.hasNext() ? this : null);
+                                    attachImageToConversation(conversation, attachment.getUri(), attachment.getMime(), this);
                                 } else {
                                     Log.d(
                                           Config.LOGTAG,
                                           "ConversationsActivity.commitAttachments() - attaching file to conversations. CHOOSE_FILE/RECORD_VOICE/RECORD_VIDEO");
-                                    attachFileToConversation(conversation, attachment.getUri(), attachment.getMime(), i.hasNext() ? this : null);
+                                    attachFileToConversation(conversation, attachment.getUri(), attachment.getMime(), this);
                                 }
                                 i.remove();
+                                if (!i.hasNext()) messageSent();
                             } catch (final java.util.ConcurrentModificationException e) {
                                 // Abort, leave any unsent attachments alone for the user to try again
                                 Toast.makeText(activity, "Sometimes went wrong with some attachments. Try again?", Toast.LENGTH_SHORT).show();