Merge "Fix assert fail during onSaveInstanceState()" am: 2af5b4b045 am: 5380b1e04d am: 6076b0e44f
Change-Id: Ic4c5c52532aa0750002093484398c852aecd78fb
This commit is contained in:
@@ -339,11 +339,23 @@ public class DraftMessageData extends BindableData implements ReadDraftDataActio
|
|||||||
*/
|
*/
|
||||||
private boolean addOneAttachmentNoNotify(final MessagePartData attachment) {
|
private boolean addOneAttachmentNoNotify(final MessagePartData attachment) {
|
||||||
Assert.isTrue(attachment.isAttachment());
|
Assert.isTrue(attachment.isAttachment());
|
||||||
|
// Check duplication.
|
||||||
|
for (final MessagePartData existingAttachment : mAttachments) {
|
||||||
|
if (existingAttachment.getContentUri().equals(attachment.getContentUri())) {
|
||||||
|
// Destroy existing attachment and replace with new attachment instead of destroying
|
||||||
|
// new one so that mSelectedImages in GalleryGridView could be maintained correctly.
|
||||||
|
mAttachments.remove(existingAttachment);
|
||||||
|
existingAttachment.destroyAsync();
|
||||||
|
addAttachment(attachment, null /*pendingAttachment*/);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final boolean reachedLimit = getAttachmentCount() >= getAttachmentLimit();
|
final boolean reachedLimit = getAttachmentCount() >= getAttachmentLimit();
|
||||||
if (reachedLimit || containsAttachment(attachment.getContentUri())) {
|
if (reachedLimit) {
|
||||||
// Never go over the limit. Never add duplicated attachments.
|
// Never go over the limit.
|
||||||
attachment.destroyAsync();
|
attachment.destroyAsync();
|
||||||
return reachedLimit;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
addAttachment(attachment, null /*pendingAttachment*/);
|
addAttachment(attachment, null /*pendingAttachment*/);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user