Catch concurrent modification and abort
Someone added an attachment while we were sending or what? (cherry picked from commit c4f751e2dd6b0f1bbb56704a3f95e76152989389)
This commit is contained in:
parent
d2ef9e3428
commit
475c01cbc6
1 changed files with 20 additions and 15 deletions
|
@ -1524,6 +1524,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
final Runnable next = new Runnable() {
|
final Runnable next = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
try {
|
||||||
final Attachment attachment = i.next();
|
final Attachment attachment = i.next();
|
||||||
if (attachment.getType() == Attachment.Type.LOCATION) {
|
if (attachment.getType() == Attachment.Type.LOCATION) {
|
||||||
attachLocationToConversation(conversation, attachment.getUri());
|
attachLocationToConversation(conversation, attachment.getUri());
|
||||||
|
@ -1540,6 +1541,10 @@ public class ConversationFragment extends XmppFragment
|
||||||
attachFileToConversation(conversation, attachment.getUri(), attachment.getMime(), i.hasNext() ? this : null);
|
attachFileToConversation(conversation, attachment.getUri(), attachment.getMime(), i.hasNext() ? this : null);
|
||||||
}
|
}
|
||||||
i.remove();
|
i.remove();
|
||||||
|
} 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();
|
||||||
|
}
|
||||||
mediaPreviewAdapter.notifyDataSetChanged();
|
mediaPreviewAdapter.notifyDataSetChanged();
|
||||||
toggleInputMethod();
|
toggleInputMethod();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue