1
0
Fork 0
mirror of https://github.com/KokaKiwi/BarInsta synced 2026-03-05 20:11:36 +00:00

dm media layout finalization

This commit is contained in:
Austin Huang 2020-09-26 14:42:35 -04:00
parent a3c0b496aa
commit 99a8e03578
No known key found for this signature in database
GPG key ID: 84C23AA04587A91F
8 changed files with 7 additions and 34 deletions

View file

@ -53,41 +53,12 @@ public class DirectMessageMediaShareViewHolder extends DirectMessageItemViewHold
maxWidth
);
final ViewGroup.LayoutParams layoutParams = binding.ivMediaPreview.getLayoutParams();
layoutParams.width = widthHeight.first != null ? widthHeight.first : 0;
layoutParams.height = widthHeight.second != null ? widthHeight.second : 0;
layoutParams.width = widthHeight.first != null ? widthHeight.first : 0;
binding.ivMediaPreview.requestLayout();
binding.ivMediaPreview.setImageURI(mediaModel.getThumbUrl());
final MediaItemType modelMediaType = mediaModel.getMediaType();
binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO
|| modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE);
}
private class WidthHeight {
private final DirectItemMediaModel mediaModel;
private int height;
private int width;
public WidthHeight(final DirectItemMediaModel mediaModel) {this.mediaModel = mediaModel;}
public int getHeight() {
return height;
}
public int getWidth() {
return width;
}
public WidthHeight invoke() {
height = mediaModel.getHeight();
width = mediaModel.getWidth();
// make height 500dp regardless
width = NumberUtils.getResultingWidth(maxHeight, height, width);
height = maxHeight;
if (width > maxWidth) {
height = NumberUtils.getResultingHeight(maxWidth, height, width);
width = maxWidth;
}
return this;
}
}
}

View file

@ -841,7 +841,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
}
private void fetchPosts() {
Log.d("austin_debug", "fp");
stopCurrentExecutor();
binding.swipeRefreshLayout.setRefreshing(true);
currentlyExecuting = new PostsFetcher(profileModel.getId(), PostItemType.MAIN, endCursor, postsFetchListener)

View file

@ -57,8 +57,8 @@ public final class NumberUtils {
@NonNull
public static Pair<Integer, Integer> calculateWidthHeight(final int height, final int width, final int maxHeight, final int maxWidth) {
int tempWidth = NumberUtils.getResultingWidth(maxHeight, height, width);
int tempHeight = maxHeight;
int tempWidth = width;
int tempHeight = height > maxHeight ? maxHeight : height;
if (tempWidth > maxWidth) {
tempHeight = NumberUtils.getResultingHeight(maxWidth, height, width);
tempWidth = maxWidth;