Fix large image attachments not showing (#1043)

* fix for too large image attachments not fitting into GL texture

* Don't use context!!
This commit is contained in:
Ondřej Hruška 2019-02-16 14:31:41 +01:00 committed by Konrad Pozniak
commit fcc67c6918
4 changed files with 35 additions and 1 deletions

View file

@ -284,6 +284,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
final int n = Math.min(attachments.size(), Status.MAX_MEDIA_ATTACHMENTS);
final int maxW = context.getResources().getInteger(R.integer.media_max_width);
final int maxH = context.getResources().getInteger(R.integer.media_max_height);
for (int i = 0; i < n; i++) {
String previewUrl = attachments.get(i).getPreviewUrl();
String description = attachments.get(i).getDescription();
@ -299,6 +302,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
if (TextUtils.isEmpty(previewUrl)) {
Picasso.with(context)
.load(mediaPreviewUnloadedId)
.resize(maxW, maxH)
.onlyScaleDown()
.centerInside()
.into(mediaPreviews[i]);
} else {
MetaData meta = attachments.get(i).getMeta();
@ -310,6 +316,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
Picasso.with(context)
.load(previewUrl)
.placeholder(mediaPreviewUnloadedId)
.resize(maxW, maxH)
.onlyScaleDown()
.centerInside()
// Also pass the mediaPreview as a callback to ensure it is called
// initially when the image gets loaded:
.into(mediaPreviews[i], mediaPreviews[i]);
@ -319,6 +328,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
Picasso.with(context)
.load(previewUrl)
.placeholder(mediaPreviewUnloadedId)
.resize(maxW, maxH)
.onlyScaleDown()
.centerInside()
.into(mediaPreviews[i]);
}
}