Use higher res versions when displaying comment images

pull/14/head
Sam Bosley 12 years ago
parent ec15892ccc
commit b310fb767f

@ -401,7 +401,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
// picture // picture
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_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 static class NoteOrUpdate {
private final String picture; private final String picture;
private final Spanned title; private final Spanned title;
private final String commentPicture; private final String pictureThumb;
private final String pictureFull;
private final Bitmap commentBitmap; private final Bitmap commentBitmap;
private final long createdAt; 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(); super();
this.picture = picture; this.picture = picture;
this.title = title; this.title = title;
this.commentPicture = commentPicture; this.pictureThumb = pictureThumb;
this.pictureFull = pictureFull;
this.commentBitmap = commentBitmap; this.commentBitmap = commentBitmap;
this.createdAt = createdAt; this.createdAt = createdAt;
} }
@ -510,20 +512,23 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL), return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL),
title, title,
m.getValue(NoteMetadata.COMMENT_PICTURE), m.getValue(NoteMetadata.COMMENT_PICTURE),
m.getValue(NoteMetadata.COMMENT_PICTURE),
null, null,
m.getValue(Metadata.CREATION_DATE)); m.getValue(Metadata.CREATION_DATE));
} }
public static NoteOrUpdate fromUpdateOrHistory(AstridActivity context, UserActivity u, History history, User user, String linkColor) { public static NoteOrUpdate fromUpdateOrHistory(AstridActivity context, UserActivity u, History history, User user, String linkColor) {
String userImage = ""; //$NON-NLS-1$ String userImage = ""; //$NON-NLS-1$
String commentPicture = ""; //$NON-NLS-1$ String pictureThumb = ""; //$NON-NLS-1$
String pictureFull = ""; //$NON-NLS-1$
Spanned title; Spanned title;
Bitmap commentBitmap = null; Bitmap commentBitmap = null;
long createdAt = 0; long createdAt = 0;
if (u != null) { if (u != null) {
commentPicture = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); pictureThumb = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
if (TextUtils.isEmpty(commentPicture)) pictureFull = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE);
if (TextUtils.isEmpty(pictureThumb))
commentBitmap = u.getPictureBitmap(UserActivity.PICTURE); commentBitmap = u.getPictureBitmap(UserActivity.PICTURE);
title = UpdateAdapter.getUpdateComment(context, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW); title = UpdateAdapter.getUpdateComment(context, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW);
userImage = ""; //$NON-NLS-1$ userImage = ""; //$NON-NLS-1$
@ -539,7 +544,8 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
return new NoteOrUpdate(userImage, return new NoteOrUpdate(userImage,
title, title,
commentPicture, pictureThumb,
pictureFull,
commentBitmap, commentBitmap,
createdAt); createdAt);
} }

@ -266,11 +266,12 @@ public class UpdateAdapter extends CursorAdapter {
} }
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); { 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; Bitmap updateBitmap = null;
if (TextUtils.isEmpty(updatePicture)) if (TextUtils.isEmpty(pictureThumb))
updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE); updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE);
setupImagePopupForCommentView(view, commentPictureView, updatePicture, updateBitmap, setupImagePopupForCommentView(view, commentPictureView, pictureThumb, pictureFull, updateBitmap,
activity.getValue(UserActivity.MESSAGE), fragment, imageCache); activity.getValue(UserActivity.MESSAGE), fragment, imageCache);
} }
@ -314,23 +315,23 @@ public class UpdateAdapter extends CursorAdapter {
return false; 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) { 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); commentPictureView.setVisibility(View.VISIBLE);
if (updateBitmap != null) if (updateBitmap != null)
commentPictureView.setImageBitmap(updateBitmap); commentPictureView.setImageBitmap(updateBitmap);
else else
commentPictureView.setUrl(updatePicture); commentPictureView.setUrl(pictureThumb);
if(imageCache.contains(updatePicture) && updateBitmap == null) { if(imageCache.contains(pictureThumb) && updateBitmap == null) {
try { try {
commentPictureView.setDefaultImageBitmap(imageCache.get(updatePicture)); commentPictureView.setDefaultImageBitmap(imageCache.get(pictureThumb));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else if (updateBitmap == null) { } else if (updateBitmap == null) {
commentPictureView.setUrl(updatePicture); commentPictureView.setUrl(pictureThumb);
} }
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@ -343,7 +344,7 @@ public class UpdateAdapter extends CursorAdapter {
if (updateBitmap != null) if (updateBitmap != null)
imageView.setImageBitmap(updateBitmap); imageView.setImageBitmap(updateBitmap);
else else
imageView.setUrl(updatePicture); imageView.setUrl(pictureFull);
image.setView(imageView); image.setView(imageView);
image.setMessage(message); image.setMessage(message);

Loading…
Cancel
Save