From b310fb767f371b699676d4ffd9c39347fa3f9888 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 21 Mar 2013 10:36:52 -0700 Subject: [PATCH] Use higher res versions when displaying comment images --- .../astrid/notes/EditNoteActivity.java | 22 ++++++++++++------- .../todoroo/astrid/adapter/UpdateAdapter.java | 21 +++++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java index 2d78fc5ed..c071fbf01 100644 --- a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java @@ -401,7 +401,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene // picture final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); { - UpdateAdapter.setupImagePopupForCommentView(view, commentPictureView, item.commentPicture, item.commentBitmap, item.title.toString(), fragment, imageCache); + UpdateAdapter.setupImagePopupForCommentView(view, commentPictureView, item.pictureThumb, item.pictureFull, item.commentBitmap, item.title.toString(), fragment, imageCache); } } @@ -488,15 +488,17 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene private static class NoteOrUpdate { private final String picture; private final Spanned title; - private final String commentPicture; + private final String pictureThumb; + private final String pictureFull; private final Bitmap commentBitmap; private final long createdAt; - public NoteOrUpdate(String picture, Spanned title, String commentPicture, Bitmap commentBitmap, long createdAt) { + public NoteOrUpdate(String picture, Spanned title, String pictureThumb, String pictureFull, Bitmap commentBitmap, long createdAt) { super(); this.picture = picture; this.title = title; - this.commentPicture = commentPicture; + this.pictureThumb = pictureThumb; + this.pictureFull = pictureFull; this.commentBitmap = commentBitmap; this.createdAt = createdAt; } @@ -510,20 +512,23 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL), title, m.getValue(NoteMetadata.COMMENT_PICTURE), + m.getValue(NoteMetadata.COMMENT_PICTURE), null, m.getValue(Metadata.CREATION_DATE)); } public static NoteOrUpdate fromUpdateOrHistory(AstridActivity context, UserActivity u, History history, User user, String linkColor) { String userImage = ""; //$NON-NLS-1$ - String commentPicture = ""; //$NON-NLS-1$ + String pictureThumb = ""; //$NON-NLS-1$ + String pictureFull = ""; //$NON-NLS-1$ Spanned title; Bitmap commentBitmap = null; long createdAt = 0; if (u != null) { - commentPicture = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); - if (TextUtils.isEmpty(commentPicture)) + pictureThumb = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); + pictureFull = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE); + if (TextUtils.isEmpty(pictureThumb)) commentBitmap = u.getPictureBitmap(UserActivity.PICTURE); title = UpdateAdapter.getUpdateComment(context, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW); userImage = ""; //$NON-NLS-1$ @@ -539,7 +544,8 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene return new NoteOrUpdate(userImage, title, - commentPicture, + pictureThumb, + pictureFull, commentBitmap, createdAt); } diff --git a/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java b/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java index c1d3f5449..83509631d 100644 --- a/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java @@ -266,11 +266,12 @@ public class UpdateAdapter extends CursorAdapter { } final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); { - String updatePicture = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_THUMB); + String pictureThumb = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); + String pictureFull = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE); Bitmap updateBitmap = null; - if (TextUtils.isEmpty(updatePicture)) + if (TextUtils.isEmpty(pictureThumb)) updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE); - setupImagePopupForCommentView(view, commentPictureView, updatePicture, updateBitmap, + setupImagePopupForCommentView(view, commentPictureView, pictureThumb, pictureFull, updateBitmap, activity.getValue(UserActivity.MESSAGE), fragment, imageCache); } @@ -314,23 +315,23 @@ public class UpdateAdapter extends CursorAdapter { return false; } - public static void setupImagePopupForCommentView(View view, AsyncImageView commentPictureView, final String updatePicture, final Bitmap updateBitmap, + public static void setupImagePopupForCommentView(View view, AsyncImageView commentPictureView, final String pictureThumb, final String pictureFull, final Bitmap updateBitmap, final String message, final Fragment fragment, ImageDiskCache imageCache) { - if ((!TextUtils.isEmpty(updatePicture) && !"null".equals(updatePicture)) || updateBitmap != null) { //$NON-NLS-1$ + if ((!TextUtils.isEmpty(pictureThumb) && !"null".equals(pictureThumb)) || updateBitmap != null) { //$NON-NLS-1$ commentPictureView.setVisibility(View.VISIBLE); if (updateBitmap != null) commentPictureView.setImageBitmap(updateBitmap); else - commentPictureView.setUrl(updatePicture); + commentPictureView.setUrl(pictureThumb); - if(imageCache.contains(updatePicture) && updateBitmap == null) { + if(imageCache.contains(pictureThumb) && updateBitmap == null) { try { - commentPictureView.setDefaultImageBitmap(imageCache.get(updatePicture)); + commentPictureView.setDefaultImageBitmap(imageCache.get(pictureThumb)); } catch (IOException e) { e.printStackTrace(); } } else if (updateBitmap == null) { - commentPictureView.setUrl(updatePicture); + commentPictureView.setUrl(pictureThumb); } view.setOnClickListener(new OnClickListener() { @@ -343,7 +344,7 @@ public class UpdateAdapter extends CursorAdapter { if (updateBitmap != null) imageView.setImageBitmap(updateBitmap); else - imageView.setUrl(updatePicture); + imageView.setUrl(pictureFull); image.setView(imageView); image.setMessage(message);