mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-21 05:01:54 -05:00
Don't handle exceptions in AttachmentView.populateFromPart()
We now catch exceptions in SingleMessageView.renderAttachments(). This way we can avoid adding AttachmentViews that couldn't be properly populated.
This commit is contained in:
parent
25dff5ae6a
commit
206c559236
@ -33,6 +33,7 @@ import com.fsck.k9.helper.MediaScannerNotifier;
|
|||||||
import com.fsck.k9.helper.SizeFormatter;
|
import com.fsck.k9.helper.SizeFormatter;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.Part;
|
import com.fsck.k9.mail.Part;
|
||||||
import com.fsck.k9.mail.internet.MimeHeader;
|
import com.fsck.k9.mail.internet.MimeHeader;
|
||||||
import com.fsck.k9.mail.internet.MimeUtility;
|
import com.fsck.k9.mail.internet.MimeUtility;
|
||||||
@ -120,11 +121,13 @@ public class AttachmentView extends FrameLayout {
|
|||||||
* @param listener
|
* @param listener
|
||||||
*
|
*
|
||||||
* @return {@code true} for a regular attachment. {@code false}, otherwise.
|
* @return {@code true} for a regular attachment. {@code false}, otherwise.
|
||||||
|
*
|
||||||
|
* @throws MessagingException
|
||||||
|
* In case of an error
|
||||||
*/
|
*/
|
||||||
public boolean populateFromPart(Part inputPart, Message message, Account account,
|
public boolean populateFromPart(Part inputPart, Message message, Account account,
|
||||||
MessagingController controller, MessagingListener listener) {
|
MessagingController controller, MessagingListener listener) throws MessagingException {
|
||||||
boolean firstClassAttachment = true;
|
boolean firstClassAttachment = true;
|
||||||
try {
|
|
||||||
part = (LocalAttachmentBodyPart) inputPart;
|
part = (LocalAttachmentBodyPart) inputPart;
|
||||||
|
|
||||||
contentType = MimeUtility.unfoldAndDecode(part.getContentType());
|
contentType = MimeUtility.unfoldAndDecode(part.getContentType());
|
||||||
@ -214,11 +217,6 @@ public class AttachmentView extends FrameLayout {
|
|||||||
} else {
|
} else {
|
||||||
attachmentIcon.setImageResource(R.drawable.attached_image_placeholder);
|
attachmentIcon.setImageResource(R.drawable.attached_image_placeholder);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
catch (Exception e) {
|
|
||||||
Log.e(K9.LOG_TAG, "error ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return firstClassAttachment;
|
return firstClassAttachment;
|
||||||
}
|
}
|
||||||
|
@ -398,11 +398,15 @@ public class SingleMessageView extends LinearLayout implements OnClickListener {
|
|||||||
AttachmentView view = (AttachmentView)mInflater.inflate(R.layout.message_view_attachment, null);
|
AttachmentView view = (AttachmentView)mInflater.inflate(R.layout.message_view_attachment, null);
|
||||||
view.setCallback(attachmentCallback);
|
view.setCallback(attachmentCallback);
|
||||||
|
|
||||||
|
try {
|
||||||
if (view.populateFromPart(part, message, account, controller, listener)) {
|
if (view.populateFromPart(part, message, account, controller, listener)) {
|
||||||
addAttachment(view);
|
addAttachment(view);
|
||||||
} else {
|
} else {
|
||||||
addHiddenAttachment(view);
|
addHiddenAttachment(view);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(K9.LOG_TAG, "Error adding attachment view", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user