1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-02-20 04:31:47 -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:
cketti 2012-02-27 21:00:44 +01:00
parent 25dff5ae6a
commit 206c559236
2 changed files with 97 additions and 95 deletions

View File

@ -33,6 +33,7 @@ import com.fsck.k9.helper.MediaScannerNotifier;
import com.fsck.k9.helper.SizeFormatter;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.MimeHeader;
import com.fsck.k9.mail.internet.MimeUtility;
@ -120,11 +121,13 @@ public class AttachmentView extends FrameLayout {
* @param listener
*
* @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,
MessagingController controller, MessagingListener listener) {
MessagingController controller, MessagingListener listener) throws MessagingException {
boolean firstClassAttachment = true;
try {
part = (LocalAttachmentBodyPart) inputPart;
contentType = MimeUtility.unfoldAndDecode(part.getContentType());
@ -214,11 +217,6 @@ public class AttachmentView extends FrameLayout {
} else {
attachmentIcon.setImageResource(R.drawable.attached_image_placeholder);
}
}
catch (Exception e) {
Log.e(K9.LOG_TAG, "error ", e);
}
return firstClassAttachment;
}

View File

@ -398,11 +398,15 @@ public class SingleMessageView extends LinearLayout implements OnClickListener {
AttachmentView view = (AttachmentView)mInflater.inflate(R.layout.message_view_attachment, null);
view.setCallback(attachmentCallback);
try {
if (view.populateFromPart(part, message, account, controller, listener)) {
addAttachment(view);
} else {
addHiddenAttachment(view);
}
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Error adding attachment view", e);
}
}
}