Fix issue #469 - Crashes with pinned and Pixelfed

pull/483/head
Thomas 2 years ago
parent ba53e174ab
commit a946ea49d1

@ -32,10 +32,12 @@ public class Tag implements Serializable {
public int getWeight() {
int weight = 0;
for (History h : history) {
try {
weight += Integer.parseInt(h.accounts);
} catch (Exception ignored) {
if (history != null && history.size() > 0) {
for (History h : history) {
try {
weight += Integer.parseInt(h.accounts);
} catch (Exception ignored) {
}
}
}
return weight;

@ -2161,30 +2161,35 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
@Override
public void onGlobalLayout() {
holder.bindingArt.artMedia.getViewTreeObserver().removeOnGlobalLayoutListener(this);
float viewWidth = holder.bindingArt.artMedia.getWidth();
ConstraintLayout.LayoutParams lp;
float mediaH = status.art_attachment.meta.small.height;
float mediaW = status.art_attachment.meta.small.width;
float ratio = 1.0f;
if (mediaW != 0) {
ratio = viewWidth / mediaW;
if (status.art_attachment.meta != null) {
float viewWidth = holder.bindingArt.artMedia.getWidth();
ConstraintLayout.LayoutParams lp;
float mediaH = status.art_attachment.meta.small.height;
float mediaW = status.art_attachment.meta.small.width;
float ratio = 1.0f;
if (mediaW != 0) {
ratio = viewWidth / mediaW;
}
lp = new ConstraintLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
holder.bindingArt.artMedia.setLayoutParams(lp);
}
lp = new ConstraintLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
holder.bindingArt.artMedia.setLayoutParams(lp);
}
});
float viewWidth = holder.bindingArt.artMedia.getWidth();
ConstraintLayout.LayoutParams lp;
float mediaH = status.art_attachment.meta.small.height;
float mediaW = status.art_attachment.meta.small.width;
float ratio = 1.0f;
if (mediaW != 0) {
ratio = viewWidth / mediaW;
if (status.art_attachment.meta != null) {
float viewWidth = holder.bindingArt.artMedia.getWidth();
ConstraintLayout.LayoutParams lp;
float mediaH = status.art_attachment.meta.small.height;
float mediaW = status.art_attachment.meta.small.width;
float ratio = 1.0f;
if (mediaW != 0) {
ratio = viewWidth / mediaW;
}
lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
holder.bindingArt.artMedia.setLayoutParams(lp);
}
lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
holder.bindingArt.artMedia.setLayoutParams(lp);
Glide.with(holder.bindingArt.artMedia.getContext())
.load(status.art_attachment.preview_url)
.apply(new RequestOptions().transform(new RoundedCorners((int) Helper.convertDpToPixel(3, context))))

Loading…
Cancel
Save