mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-03 14:40:07 +02:00
Fix jumps with Akkoma/Pleroma when media preview size is not set
This commit is contained in:
parent
25c372280f
commit
fdd39704ef
5 changed files with 27 additions and 16 deletions
|
@ -73,6 +73,16 @@ public class Attachment implements Serializable {
|
||||||
public MediaData original;
|
public MediaData original;
|
||||||
@SerializedName("small")
|
@SerializedName("small")
|
||||||
public MediaData small;
|
public MediaData small;
|
||||||
|
|
||||||
|
public MediaData getSmall() {
|
||||||
|
if (small != null) {
|
||||||
|
return small;
|
||||||
|
} else if (original != null) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Focus implements Serializable {
|
public static class Focus implements Serializable {
|
||||||
|
|
|
@ -390,8 +390,8 @@ public class MediaHelper {
|
||||||
int maxHeight = RelativeLayout.LayoutParams.WRAP_CONTENT;
|
int maxHeight = RelativeLayout.LayoutParams.WRAP_CONTENT;
|
||||||
if (attachmentList != null && attachmentList.size() > 0) {
|
if (attachmentList != null && attachmentList.size() > 0) {
|
||||||
for (Attachment attachment : attachmentList) {
|
for (Attachment attachment : attachmentList) {
|
||||||
if (attachment.meta != null && attachment.meta.small != null && attachment.meta.small.height > maxHeight) {
|
if (attachment.meta != null && attachment.meta.getSmall() != null && attachment.meta.getSmall().height > maxHeight) {
|
||||||
maxHeight = (int) Helper.convertDpToPixel(attachment.meta.small.height, context);
|
maxHeight = (int) Helper.convertDpToPixel(attachment.meta.getSmall().height, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||||
} else if (statusToDeal.media_attachments.size() == 3) {
|
} else if (statusToDeal.media_attachments.size() == 3) {
|
||||||
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
||||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small != null && statusToDeal.media_attachments.get(0).meta.small.width < statusToDeal.media_attachments.get(0).meta.small.height) {
|
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.getSmall() != null && statusToDeal.media_attachments.get(0).meta.getSmall().width < statusToDeal.media_attachments.get(0).meta.getSmall().height) {
|
||||||
ConstraintSet constraintSet = new ConstraintSet();
|
ConstraintSet constraintSet = new ConstraintSet();
|
||||||
constraintSet.clone(holder.binding.media.mediaContainer);
|
constraintSet.clone(holder.binding.media.mediaContainer);
|
||||||
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.START, holder.binding.media.media1Container.getId(), ConstraintSet.END);
|
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.START, holder.binding.media.media1Container.getId(), ConstraintSet.END);
|
||||||
|
@ -1570,7 +1570,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
if (mediaPosition == 1) {
|
if (mediaPosition == 1) {
|
||||||
holder.binding.media.media1Container.addView(layoutMediaBinding.getRoot());
|
holder.binding.media.media1Container.addView(layoutMediaBinding.getRoot());
|
||||||
} else if (mediaPosition == 2 && statusToDeal.media_attachments.size() == 3) {
|
} else if (mediaPosition == 2 && statusToDeal.media_attachments.size() == 3) {
|
||||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small != null && statusToDeal.media_attachments.get(0).meta.small.width < statusToDeal.media_attachments.get(0).meta.small.height) {
|
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.getSmall() != null && statusToDeal.media_attachments.get(0).meta.getSmall().width < statusToDeal.media_attachments.get(0).meta.getSmall().height) {
|
||||||
holder.binding.media.media2Container.addView(layoutMediaBinding.getRoot());
|
holder.binding.media.media2Container.addView(layoutMediaBinding.getRoot());
|
||||||
} else {
|
} else {
|
||||||
holder.binding.media.media3Container.addView(layoutMediaBinding.getRoot());
|
holder.binding.media.media3Container.addView(layoutMediaBinding.getRoot());
|
||||||
|
@ -1590,9 +1590,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
float ratio = 1.0f;
|
float ratio = 1.0f;
|
||||||
float mediaH = -1.0f;
|
float mediaH = -1.0f;
|
||||||
float mediaW = -1.0f;
|
float mediaW = -1.0f;
|
||||||
if (attachment.meta != null && attachment.meta.small != null) {
|
if (attachment.meta != null && attachment.meta.getSmall() != null) {
|
||||||
mediaH = attachment.meta.small.height;
|
mediaH = attachment.meta.getSmall().height;
|
||||||
mediaW = attachment.meta.small.width;
|
mediaW = attachment.meta.getSmall().width;
|
||||||
if (mediaW != 0) {
|
if (mediaW != 0) {
|
||||||
ratio = measuredWidth > 0 ? measuredWidth / mediaW : 1.0f;
|
ratio = measuredWidth > 0 ? measuredWidth / mediaW : 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -2628,7 +2628,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
|
|
||||||
float focusX = 0.f;
|
float focusX = 0.f;
|
||||||
float focusY = 0.f;
|
float focusY = 0.f;
|
||||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.getSmall() != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||||
}
|
}
|
||||||
|
@ -2905,9 +2905,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
}
|
}
|
||||||
int mediaH = 0;
|
int mediaH = 0;
|
||||||
int mediaW = 0;
|
int mediaW = 0;
|
||||||
if (attachment.meta != null && attachment.meta.small != null) {
|
if (attachment.meta != null && attachment.meta.getSmall() != null) {
|
||||||
mediaH = attachment.meta.small.height;
|
mediaH = attachment.meta.getSmall().height;
|
||||||
mediaW = attachment.meta.small.width;
|
mediaW = attachment.meta.getSmall().width;
|
||||||
}
|
}
|
||||||
return prepareRequestBuilder(context, attachment, mediaW, mediaH, focusX, focusY, attachment.sensitive, timelineType == Timeline.TimeLineEnum.ART).load(attachment);
|
return prepareRequestBuilder(context, attachment, mediaW, mediaH, focusX, focusY, attachment.sensitive, timelineType == Timeline.TimeLineEnum.ART).load(attachment);
|
||||||
}
|
}
|
||||||
|
@ -3127,10 +3127,10 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (status.art_attachment != null) {
|
if (status.art_attachment != null) {
|
||||||
if (status.art_attachment.meta != null && status.art_attachment.meta.small != null) {
|
if (status.art_attachment.meta != null && status.art_attachment.meta.getSmall() != null) {
|
||||||
ConstraintLayout.LayoutParams lp;
|
ConstraintLayout.LayoutParams lp;
|
||||||
float mediaH = status.art_attachment.meta.small.height;
|
float mediaH = status.art_attachment.meta.getSmall().height;
|
||||||
float mediaW = status.art_attachment.meta.small.width;
|
float mediaW = status.art_attachment.meta.getSmall().width;
|
||||||
float ratio = measuredWidthArt > 0 ? measuredWidthArt / mediaW : 1.0f;
|
float ratio = measuredWidthArt > 0 ? measuredWidthArt / mediaW : 1.0f;
|
||||||
lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
||||||
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||||
|
|
|
@ -534,7 +534,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||||
} else if (status.media_attachments.size() == 3) {
|
} else if (status.media_attachments.size() == 3) {
|
||||||
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
holder.binding.media.media1Container.setVisibility(View.VISIBLE);
|
||||||
if (status.media_attachments.get(0).meta != null && status.media_attachments.get(0).meta.small.width < status.media_attachments.get(0).meta.small.height) {
|
if (status.media_attachments.get(0).meta != null && status.media_attachments.get(0).meta.getSmall().width < status.media_attachments.get(0).meta.getSmall().height) {
|
||||||
ConstraintSet constraintSet = new ConstraintSet();
|
ConstraintSet constraintSet = new ConstraintSet();
|
||||||
constraintSet.clone(holder.binding.media.mediaContainer);
|
constraintSet.clone(holder.binding.media.mediaContainer);
|
||||||
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.START, holder.binding.media.media1Container.getId(), ConstraintSet.END);
|
constraintSet.connect(holder.binding.media.media4Container.getId(), ConstraintSet.START, holder.binding.media.media1Container.getId(), ConstraintSet.END);
|
||||||
|
@ -594,7 +594,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||||
if (mediaPosition == 1) {
|
if (mediaPosition == 1) {
|
||||||
holder.binding.media.media1Container.addView(layoutMediaBinding.getRoot());
|
holder.binding.media.media1Container.addView(layoutMediaBinding.getRoot());
|
||||||
} else if (mediaPosition == 2 && status.media_attachments.size() == 3) {
|
} else if (mediaPosition == 2 && status.media_attachments.size() == 3) {
|
||||||
if (status.media_attachments.get(0).meta != null && status.media_attachments.get(0).meta.small.width < status.media_attachments.get(0).meta.small.height) {
|
if (status.media_attachments.get(0).meta != null && status.media_attachments.get(0).meta.getSmall().width < status.media_attachments.get(0).meta.getSmall().height) {
|
||||||
holder.binding.media.media2Container.addView(layoutMediaBinding.getRoot());
|
holder.binding.media.media2Container.addView(layoutMediaBinding.getRoot());
|
||||||
} else {
|
} else {
|
||||||
holder.binding.media.media3Container.addView(layoutMediaBinding.getRoot());
|
holder.binding.media.media3Container.addView(layoutMediaBinding.getRoot());
|
||||||
|
|
|
@ -9,4 +9,5 @@ Changed:
|
||||||
Fixed:
|
Fixed:
|
||||||
- Fix an issue with Nitter and some URLs
|
- Fix an issue with Nitter and some URLs
|
||||||
- Fix an issue when entering a Peertube instance
|
- Fix an issue when entering a Peertube instance
|
||||||
|
- Fix jumps with Akkoma/Pleroma when media preview size is not set
|
||||||
- Some crashes
|
- Some crashes
|
Loading…
Reference in a new issue