From a7b16c1210d7562208dfd65c029df30b6d9c4ed3 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 19 Jan 2015 23:08:41 +0100 Subject: [PATCH] Refresh thumbnail after downloading attachment --- .../k9/ui/messageview/AttachmentController.java | 1 + .../fsck/k9/ui/messageview/AttachmentView.java | 16 ++++++++++------ .../k9/ui/messageview/MessageViewFragment.java | 4 ++++ .../k9/ui/messageview/SingleMessageView.java | 4 ++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentController.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentController.java index b5f2021ee..9af2e764d 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentController.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentController.java @@ -92,6 +92,7 @@ public class AttachmentController { downloadAttachment(localPart, new Runnable() { @Override public void run() { + messageViewFragment.refreshAttachmentThumbnail(attachment); saveAttachmentTo(directory); } }); diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentView.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentView.java index 2713da359..ff8992ad5 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentView.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/AttachmentView.java @@ -77,12 +77,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo attachmentName.setText(attachment.displayName); attachmentInfo.setText(SizeFormatter.formatSize(getContext(), attachment.size)); - ImageView thumbnailView = (ImageView) findViewById(R.id.attachment_icon); - Glide.with(getContext()) - .load(attachment.uri) - .placeholder(R.drawable.attached_image_placeholder) - .centerCrop() - .into(thumbnailView); + refreshThumbnail(); } @Override @@ -124,4 +119,13 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo public void setCallback(AttachmentViewCallback callback) { this.callback = callback; } + + public void refreshThumbnail() { + ImageView thumbnailView = (ImageView) findViewById(R.id.attachment_icon); + Glide.with(getContext()) + .load(attachment.uri) + .placeholder(R.drawable.attached_image_placeholder) + .centerCrop() + .into(thumbnailView); + } } diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java index 67657f1c6..61ff0c9be 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.java @@ -694,6 +694,10 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF }); } + public void refreshAttachmentThumbnail(AttachmentViewInfo attachment) { + mMessageView.refreshAttachmentThumbnail(attachment); + } + public interface MessageViewFragmentListener { public void onForward(LocalMessage mMessage, PgpData mPgpData); public void disableDeleteAction(); diff --git a/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java b/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java index 433d0911b..ac9ed9953 100644 --- a/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java +++ b/k9mail/src/main/java/com/fsck/k9/ui/messageview/SingleMessageView.java @@ -721,6 +721,10 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, getAttachmentView(attachment).disableButtons(); } + public void refreshAttachmentThumbnail(AttachmentViewInfo attachment) { + getAttachmentView(attachment).refreshThumbnail(); + } + private AttachmentView getAttachmentView(AttachmentViewInfo attachment) { return attachments.get(attachment); }