mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-23 07:07:30 +00:00
Move almost all dimens to parent class
This commit is contained in:
parent
f1721c37ec
commit
33ec122a94
@ -8,7 +8,6 @@ import androidx.core.util.Pair;
|
|||||||
|
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
|
|
||||||
import awais.instagrabber.R;
|
|
||||||
import awais.instagrabber.databinding.LayoutDmAnimatedMediaBinding;
|
import awais.instagrabber.databinding.LayoutDmAnimatedMediaBinding;
|
||||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||||
import awais.instagrabber.interfaces.MentionClickListener;
|
import awais.instagrabber.interfaces.MentionClickListener;
|
||||||
@ -19,13 +18,10 @@ import awais.instagrabber.repositories.responses.directmessages.DirectItem;
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.DirectItemAnimatedMedia;
|
import awais.instagrabber.repositories.responses.directmessages.DirectItemAnimatedMedia;
|
||||||
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||||
import awais.instagrabber.utils.NumberUtils;
|
import awais.instagrabber.utils.NumberUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemAnimatedMediaViewHolder extends DirectItemViewHolder {
|
public class DirectItemAnimatedMediaViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
private final LayoutDmAnimatedMediaBinding binding;
|
private final LayoutDmAnimatedMediaBinding binding;
|
||||||
private final int maxHeight;
|
|
||||||
private final int maxWidth;
|
|
||||||
|
|
||||||
public DirectItemAnimatedMediaViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
public DirectItemAnimatedMediaViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||||
@NonNull final LayoutDmAnimatedMediaBinding binding,
|
@NonNull final LayoutDmAnimatedMediaBinding binding,
|
||||||
@ -35,9 +31,6 @@ public class DirectItemAnimatedMediaViewHolder extends DirectItemViewHolder {
|
|||||||
final View.OnClickListener onClickListener) {
|
final View.OnClickListener onClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
maxHeight = itemView.getResources().getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
|
||||||
final int margin = itemView.getResources().getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
|
||||||
maxWidth = Utils.displayMetrics.widthPixels - margin;
|
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +46,8 @@ public class DirectItemAnimatedMediaViewHolder extends DirectItemViewHolder {
|
|||||||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
||||||
fixedHeight.getHeight(),
|
fixedHeight.getHeight(),
|
||||||
fixedHeight.getWidth(),
|
fixedHeight.getWidth(),
|
||||||
maxHeight,
|
mediaImageMaxHeight,
|
||||||
maxWidth
|
mediaImageMaxWidth
|
||||||
);
|
);
|
||||||
binding.ivAnimatedMessage.setVisibility(View.VISIBLE);
|
binding.ivAnimatedMessage.setVisibility(View.VISIBLE);
|
||||||
final ViewGroup.LayoutParams layoutParams = binding.ivAnimatedMessage.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.ivAnimatedMessage.getLayoutParams();
|
||||||
|
@ -5,7 +5,6 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import awais.instagrabber.R;
|
|
||||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||||
import awais.instagrabber.databinding.LayoutDmLinkBinding;
|
import awais.instagrabber.databinding.LayoutDmLinkBinding;
|
||||||
import awais.instagrabber.interfaces.MentionClickListener;
|
import awais.instagrabber.interfaces.MentionClickListener;
|
||||||
@ -15,7 +14,6 @@ import awais.instagrabber.repositories.responses.directmessages.DirectItemLink;
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.DirectItemLinkContext;
|
import awais.instagrabber.repositories.responses.directmessages.DirectItemLinkContext;
|
||||||
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||||
import awais.instagrabber.utils.TextUtils;
|
import awais.instagrabber.utils.TextUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemLinkViewHolder extends DirectItemViewHolder {
|
public class DirectItemLinkViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
@ -29,8 +27,7 @@ public class DirectItemLinkViewHolder extends DirectItemViewHolder {
|
|||||||
final View.OnClickListener onClickListener) {
|
final View.OnClickListener onClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
final int margin = itemView.getResources().getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
final int width = windowWidth - margin - dmRadiusSmall;
|
||||||
final int width = Utils.displayMetrics.widthPixels - margin - Utils.convertDpToPx(8);
|
|
||||||
final ViewGroup.LayoutParams layoutParams = binding.preview.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.preview.getLayoutParams();
|
||||||
layoutParams.width = width;
|
layoutParams.width = width;
|
||||||
binding.preview.requestLayout();
|
binding.preview.requestLayout();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package awais.instagrabber.adapters.viewholder.directmessages;
|
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -29,16 +28,11 @@ import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.DirectUser;
|
import awais.instagrabber.repositories.responses.directmessages.DirectUser;
|
||||||
import awais.instagrabber.utils.NumberUtils;
|
import awais.instagrabber.utils.NumberUtils;
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
private final LayoutDmMediaShareBinding binding;
|
private final LayoutDmMediaShareBinding binding;
|
||||||
private final int maxHeight;
|
|
||||||
private final int maxWidth;
|
private final int maxWidth;
|
||||||
private final int dmRadius;
|
|
||||||
private final int dmRadiusSmall;
|
|
||||||
// private final RoundingParams roundingParams;
|
|
||||||
|
|
||||||
public DirectItemMediaShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
public DirectItemMediaShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||||
@NonNull final LayoutDmMediaShareBinding binding,
|
@NonNull final LayoutDmMediaShareBinding binding,
|
||||||
@ -48,12 +42,7 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
|||||||
final View.OnClickListener onClickListener) {
|
final View.OnClickListener onClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
final Resources resources = itemView.getResources();
|
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||||
maxHeight = resources.getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
|
||||||
final int margin = resources.getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
|
||||||
maxWidth = Utils.displayMetrics.widthPixels - margin - Utils.convertDpToPx(8);
|
|
||||||
dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
|
||||||
dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +106,7 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
|||||||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
||||||
media.getOriginalHeight(),
|
media.getOriginalHeight(),
|
||||||
media.getOriginalWidth(),
|
media.getOriginalWidth(),
|
||||||
maxHeight,
|
mediaImageMaxHeight,
|
||||||
maxWidth
|
maxWidth
|
||||||
);
|
);
|
||||||
final ViewGroup.LayoutParams layoutParams = binding.mediaPreview.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.mediaPreview.getLayoutParams();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package awais.instagrabber.adapters.viewholder.directmessages;
|
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@ -11,7 +10,6 @@ import com.facebook.drawee.drawable.ScalingUtils;
|
|||||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||||
import com.facebook.drawee.generic.RoundingParams;
|
import com.facebook.drawee.generic.RoundingParams;
|
||||||
|
|
||||||
import awais.instagrabber.R;
|
|
||||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||||
import awais.instagrabber.databinding.LayoutDmMediaBinding;
|
import awais.instagrabber.databinding.LayoutDmMediaBinding;
|
||||||
import awais.instagrabber.interfaces.MentionClickListener;
|
import awais.instagrabber.interfaces.MentionClickListener;
|
||||||
@ -23,12 +21,10 @@ import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
||||||
import awais.instagrabber.utils.NumberUtils;
|
import awais.instagrabber.utils.NumberUtils;
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
private final LayoutDmMediaBinding binding;
|
private final LayoutDmMediaBinding binding;
|
||||||
private final int maxHeight;
|
|
||||||
private final int maxWidth;
|
private final int maxWidth;
|
||||||
private final RoundingParams incomingRoundingParams;
|
private final RoundingParams incomingRoundingParams;
|
||||||
private final RoundingParams outgoingRoundingParams;
|
private final RoundingParams outgoingRoundingParams;
|
||||||
@ -41,12 +37,7 @@ public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
|||||||
final View.OnClickListener onClickListener) {
|
final View.OnClickListener onClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
final Resources resources = itemView.getResources();
|
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||||
maxHeight = resources.getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
|
||||||
final int margin = resources.getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
|
||||||
maxWidth = Utils.displayMetrics.widthPixels - margin - Utils.convertDpToPx(8);
|
|
||||||
final int dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
|
||||||
final int dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
|
||||||
incomingRoundingParams = RoundingParams.fromCornersRadii(dmRadiusSmall, dmRadius, dmRadius, dmRadius);
|
incomingRoundingParams = RoundingParams.fromCornersRadii(dmRadiusSmall, dmRadius, dmRadius, dmRadius);
|
||||||
outgoingRoundingParams = RoundingParams.fromCornersRadii(dmRadius, dmRadiusSmall, dmRadius, dmRadius);
|
outgoingRoundingParams = RoundingParams.fromCornersRadii(dmRadius, dmRadiusSmall, dmRadius, dmRadius);
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
@ -67,7 +58,7 @@ public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
|||||||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
||||||
media.getOriginalHeight(),
|
media.getOriginalHeight(),
|
||||||
media.getOriginalWidth(),
|
media.getOriginalWidth(),
|
||||||
maxHeight,
|
mediaImageMaxHeight,
|
||||||
maxWidth
|
maxWidth
|
||||||
);
|
);
|
||||||
final ViewGroup.LayoutParams layoutParams = binding.mediaPreview.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.mediaPreview.getLayoutParams();
|
||||||
|
@ -49,7 +49,6 @@ public class DirectItemProfileViewHolder extends DirectItemViewHolder {
|
|||||||
binding.preview6
|
binding.preview6
|
||||||
);
|
);
|
||||||
final Resources resources = itemView.getResources();
|
final Resources resources = itemView.getResources();
|
||||||
final int dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
|
||||||
binding.preview4.setHierarchy(new GenericDraweeHierarchyBuilder(resources)
|
binding.preview4.setHierarchy(new GenericDraweeHierarchyBuilder(resources)
|
||||||
.setRoundingParams(RoundingParams.fromCornersRadii(0, 0, 0, dmRadius))
|
.setRoundingParams(RoundingParams.fromCornersRadii(0, 0, 0, dmRadius))
|
||||||
.build());
|
.build());
|
||||||
|
@ -11,7 +11,6 @@ import com.facebook.drawee.drawable.ScalingUtils;
|
|||||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||||
import com.facebook.drawee.generic.RoundingParams;
|
import com.facebook.drawee.generic.RoundingParams;
|
||||||
|
|
||||||
import awais.instagrabber.R;
|
|
||||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||||
import awais.instagrabber.databinding.LayoutDmRavenMediaBinding;
|
import awais.instagrabber.databinding.LayoutDmRavenMediaBinding;
|
||||||
import awais.instagrabber.interfaces.MentionClickListener;
|
import awais.instagrabber.interfaces.MentionClickListener;
|
||||||
@ -25,15 +24,11 @@ import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
||||||
import awais.instagrabber.utils.NumberUtils;
|
import awais.instagrabber.utils.NumberUtils;
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
private final LayoutDmRavenMediaBinding binding;
|
private final LayoutDmRavenMediaBinding binding;
|
||||||
private final int maxHeight;
|
|
||||||
private final int maxWidth;
|
private final int maxWidth;
|
||||||
private final int dmRadius;
|
|
||||||
private final int dmRadiusSmall;
|
|
||||||
|
|
||||||
public DirectItemRavenMediaViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
public DirectItemRavenMediaViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||||
@NonNull final LayoutDmRavenMediaBinding binding,
|
@NonNull final LayoutDmRavenMediaBinding binding,
|
||||||
@ -44,11 +39,7 @@ public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
|||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
final Resources resources = itemView.getResources();
|
final Resources resources = itemView.getResources();
|
||||||
maxHeight = resources.getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||||
final int margin = resources.getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
|
||||||
maxWidth = Utils.displayMetrics.widthPixels - margin - Utils.convertDpToPx(8);
|
|
||||||
dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
|
||||||
dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +173,7 @@ public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
|||||||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
||||||
media.getOriginalHeight(),
|
media.getOriginalHeight(),
|
||||||
media.getOriginalWidth(),
|
media.getOriginalWidth(),
|
||||||
maxHeight,
|
mediaImageMaxHeight,
|
||||||
maxWidth
|
maxWidth
|
||||||
);
|
);
|
||||||
final ViewGroup.LayoutParams layoutParams = binding.preview.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.preview.getLayoutParams();
|
||||||
|
@ -23,15 +23,10 @@ import awais.instagrabber.repositories.responses.directmessages.DirectUser;
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||||
import awais.instagrabber.utils.TextUtils;
|
import awais.instagrabber.utils.TextUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
private final LayoutDmReelShareBinding binding;
|
private final LayoutDmReelShareBinding binding;
|
||||||
// private final int maxHeight;
|
|
||||||
// private final int maxWidth;
|
|
||||||
private final int dmRadiusSmall;
|
|
||||||
private final int messageMargin;
|
|
||||||
|
|
||||||
public DirectItemReelShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
public DirectItemReelShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||||
@NonNull final LayoutDmReelShareBinding binding,
|
@NonNull final LayoutDmReelShareBinding binding,
|
||||||
@ -41,9 +36,6 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
|||||||
final View.OnClickListener onClickListener) {
|
final View.OnClickListener onClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
dmRadiusSmall = itemView.getResources().getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
|
||||||
// binding.tvMessage.setMentionClickListener(mentionClickListener);
|
|
||||||
messageMargin = Utils.convertDpToPx(4);
|
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +89,8 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
|||||||
final ConstraintLayout.LayoutParams messageLayoutParams = (ConstraintLayout.LayoutParams) binding.message.getLayoutParams();
|
final ConstraintLayout.LayoutParams messageLayoutParams = (ConstraintLayout.LayoutParams) binding.message.getLayoutParams();
|
||||||
messageLayoutParams.startToStart = isIncoming ? ConstraintLayout.LayoutParams.PARENT_ID : ConstraintLayout.LayoutParams.UNSET;
|
messageLayoutParams.startToStart = isIncoming ? ConstraintLayout.LayoutParams.PARENT_ID : ConstraintLayout.LayoutParams.UNSET;
|
||||||
messageLayoutParams.endToEnd = isIncoming ? ConstraintLayout.LayoutParams.UNSET : ConstraintLayout.LayoutParams.PARENT_ID;
|
messageLayoutParams.endToEnd = isIncoming ? ConstraintLayout.LayoutParams.UNSET : ConstraintLayout.LayoutParams.PARENT_ID;
|
||||||
messageLayoutParams.setMarginStart(isIncoming ? messageMargin : 0);
|
messageLayoutParams.setMarginStart(isIncoming ? messageInfoPaddingSmall : 0);
|
||||||
messageLayoutParams.setMarginEnd(isIncoming ? 0 : messageMargin);
|
messageLayoutParams.setMarginEnd(isIncoming ? 0 : messageInfoPaddingSmall);
|
||||||
final ConstraintLayout.LayoutParams reactionLayoutParams = (ConstraintLayout.LayoutParams) binding.reaction.getLayoutParams();
|
final ConstraintLayout.LayoutParams reactionLayoutParams = (ConstraintLayout.LayoutParams) binding.reaction.getLayoutParams();
|
||||||
final int previewId = binding.preview.getId();
|
final int previewId = binding.preview.getId();
|
||||||
if (isIncoming) {
|
if (isIncoming) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package awais.instagrabber.adapters.viewholder.directmessages;
|
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@ -11,7 +10,6 @@ import com.facebook.drawee.drawable.ScalingUtils;
|
|||||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||||
import com.facebook.drawee.generic.RoundingParams;
|
import com.facebook.drawee.generic.RoundingParams;
|
||||||
|
|
||||||
import awais.instagrabber.R;
|
|
||||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||||
import awais.instagrabber.databinding.LayoutDmStoryShareBinding;
|
import awais.instagrabber.databinding.LayoutDmStoryShareBinding;
|
||||||
import awais.instagrabber.interfaces.MentionClickListener;
|
import awais.instagrabber.interfaces.MentionClickListener;
|
||||||
@ -25,15 +23,11 @@ import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
|||||||
import awais.instagrabber.utils.NumberUtils;
|
import awais.instagrabber.utils.NumberUtils;
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||||
import awais.instagrabber.utils.TextUtils;
|
import awais.instagrabber.utils.TextUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
||||||
|
|
||||||
private final LayoutDmStoryShareBinding binding;
|
private final LayoutDmStoryShareBinding binding;
|
||||||
private final int maxHeight;
|
|
||||||
private final int maxWidth;
|
private final int maxWidth;
|
||||||
private final int dmRadius;
|
|
||||||
private final int dmRadiusSmall;
|
|
||||||
|
|
||||||
public DirectItemStoryShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
public DirectItemStoryShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||||
@NonNull final LayoutDmStoryShareBinding binding,
|
@NonNull final LayoutDmStoryShareBinding binding,
|
||||||
@ -43,12 +37,7 @@ public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
|||||||
final View.OnClickListener onClickListener) {
|
final View.OnClickListener onClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
maxHeight = itemView.getResources().getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||||
final Resources resources = itemView.getResources();
|
|
||||||
final int margin = resources.getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
|
||||||
maxWidth = Utils.displayMetrics.widthPixels - margin - Utils.convertDpToPx(8);
|
|
||||||
dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
|
||||||
dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +78,7 @@ public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
|||||||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
||||||
storyShareMedia.getOriginalHeight(),
|
storyShareMedia.getOriginalHeight(),
|
||||||
storyShareMedia.getOriginalWidth(),
|
storyShareMedia.getOriginalWidth(),
|
||||||
maxHeight,
|
mediaImageMaxHeight,
|
||||||
maxWidth
|
maxWidth
|
||||||
);
|
);
|
||||||
final ViewGroup.LayoutParams layoutParams = binding.ivMediaPreview.getLayoutParams();
|
final ViewGroup.LayoutParams layoutParams = binding.ivMediaPreview.getLayoutParams();
|
||||||
|
@ -23,22 +23,13 @@ public class DirectItemTextViewHolder extends DirectItemViewHolder {
|
|||||||
final MentionClickListener mentionClickListener) {
|
final MentionClickListener mentionClickListener) {
|
||||||
super(baseBinding, currentUser, thread, onClickListener);
|
super(baseBinding, currentUser, thread, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
// this.binding.tvMessage.setMentionClickListener(mentionClickListener);
|
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindItem(final DirectItem directItemModel, final MessageDirection messageDirection) {
|
public void bindItem(final DirectItem directItemModel, final MessageDirection messageDirection) {
|
||||||
// final Context context = itemView.getContext();
|
|
||||||
final String text = directItemModel.getText();
|
final String text = directItemModel.getText();
|
||||||
if (text == null) return;
|
if (text == null) return;
|
||||||
binding.tvMessage.setText(text);
|
binding.tvMessage.setText(text);
|
||||||
// text = TextUtils.getSpannableUrl(text.toString()); // for urls
|
|
||||||
// if (TextUtils.hasMentions(text)) text = TextUtils.getMentionText(text); // for mentions
|
|
||||||
// if (text instanceof Spanned)
|
|
||||||
// binding.tvMessage.setText(text, TextView.BufferType.SPANNABLE);
|
|
||||||
// else if (text == "") {
|
|
||||||
// binding.tvMessage.setText(context.getText(R.string.dms_inbox_raven_message_unknown));
|
|
||||||
// } else binding.tvMessage.setText(text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import android.content.res.ColorStateList;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@ -31,7 +30,6 @@ import awais.instagrabber.repositories.responses.directmessages.DirectItemReacti
|
|||||||
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||||
import awais.instagrabber.repositories.responses.directmessages.DirectUser;
|
import awais.instagrabber.repositories.responses.directmessages.DirectUser;
|
||||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||||
import awais.instagrabber.utils.Utils;
|
|
||||||
|
|
||||||
public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
private static final String TAG = DirectItemViewHolder.class.getSimpleName();
|
private static final String TAG = DirectItemViewHolder.class.getSimpleName();
|
||||||
@ -39,12 +37,15 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
private final LayoutDmBaseBinding binding;
|
private final LayoutDmBaseBinding binding;
|
||||||
private final DirectUser currentUser;
|
private final DirectUser currentUser;
|
||||||
private final DirectThread thread;
|
private final DirectThread thread;
|
||||||
private final int margin;
|
protected final int margin;
|
||||||
private final int dmRadius;
|
protected final int dmRadius;
|
||||||
private final int messageInfoPaddingSmall;
|
protected final int dmRadiusSmall;
|
||||||
private final int dmRadiusSmall;
|
protected final int messageInfoPaddingSmall;
|
||||||
private final int groupMessageWidth;
|
private final int groupMessageWidth;
|
||||||
private final List<Long> userIds;
|
private final List<Long> userIds;
|
||||||
|
protected final int mediaImageMaxHeight;
|
||||||
|
protected final int windowWidth;
|
||||||
|
protected final int mediaImageMaxWidth;
|
||||||
|
|
||||||
public DirectItemViewHolder(@NonNull final LayoutDmBaseBinding binding,
|
public DirectItemViewHolder(@NonNull final LayoutDmBaseBinding binding,
|
||||||
@NonNull final ProfileModel currentUser,
|
@NonNull final ProfileModel currentUser,
|
||||||
@ -61,15 +62,17 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
binding.ivProfilePic.setVisibility(thread.isGroup() ? View.VISIBLE : View.GONE);
|
binding.ivProfilePic.setVisibility(thread.isGroup() ? View.VISIBLE : View.GONE);
|
||||||
binding.ivProfilePic.setOnClickListener(thread.isGroup() ? onClickListener : null);
|
binding.ivProfilePic.setOnClickListener(thread.isGroup() ? onClickListener : null);
|
||||||
// binding.messageCard.setOnClickListener(onClickListener);
|
// binding.messageCard.setOnClickListener(onClickListener);
|
||||||
margin = itemView.getResources().getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
|
||||||
final int avatarSize = Utils.convertDpToPx(48);
|
|
||||||
final Resources resources = itemView.getResources();
|
final Resources resources = itemView.getResources();
|
||||||
|
margin = resources.getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
||||||
|
final int avatarSize = resources.getDimensionPixelSize(R.dimen.dm_message_item_avatar_size);
|
||||||
dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
||||||
dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
||||||
messageInfoPaddingSmall = Utils.convertDpToPx(4);
|
messageInfoPaddingSmall = resources.getDimensionPixelSize(R.dimen.dm_message_info_padding_small);
|
||||||
DisplayMetrics displayMetrics = itemView.getResources().getDisplayMetrics();
|
windowWidth = resources.getDisplayMetrics().widthPixels;
|
||||||
|
mediaImageMaxHeight = resources.getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
||||||
|
mediaImageMaxWidth = windowWidth - margin;
|
||||||
// messageInfoPaddingSmall is used cuz it's also 4dp, 1 avatar margin + 2 paddings = 3
|
// messageInfoPaddingSmall is used cuz it's also 4dp, 1 avatar margin + 2 paddings = 3
|
||||||
groupMessageWidth = displayMetrics.widthPixels - margin - avatarSize - messageInfoPaddingSmall * 3;
|
groupMessageWidth = windowWidth - margin - avatarSize - messageInfoPaddingSmall * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(final DirectItem item) {
|
public void bind(final DirectItem item) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package awais.instagrabber.adapters.viewholder.directmessages;
|
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@ -52,8 +51,7 @@ public class DirectItemVoiceMediaViewHolder extends DirectItemViewHolder {
|
|||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.dataSourceFactory = new DefaultDataSourceFactory(binding.getRoot().getContext(), "instagram");
|
this.dataSourceFactory = new DefaultDataSourceFactory(binding.getRoot().getContext(), "instagram");
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
final int margin = itemView.getResources().getDimensionPixelSize(R.dimen.dm_message_item_margin);
|
binding.waveformSeekBar.getLayoutParams().width = windowWidth - margin - Utils.convertDpToPx(56);
|
||||||
binding.waveformSeekBar.getLayoutParams().width = Utils.displayMetrics.widthPixels - margin - Utils.convertDpToPx(56);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
<dimen name="dm_link_image_size">150dp</dimen>
|
<dimen name="dm_link_image_size">150dp</dimen>
|
||||||
<dimen name="dm_message_card_radius">16dp</dimen>
|
<dimen name="dm_message_card_radius">16dp</dimen>
|
||||||
<dimen name="dm_message_card_radius_small">8dp</dimen>
|
<dimen name="dm_message_card_radius_small">8dp</dimen>
|
||||||
<dimen name="dm_message_item_margin">120dp</dimen>
|
<dimen name="dm_message_item_margin">80dp</dimen>
|
||||||
|
<dimen name="dm_message_item_avatar_size">48dp</dimen>
|
||||||
|
<dimen name="dm_message_info_padding_small">4dp</dimen>
|
||||||
|
|
||||||
<dimen name="feed_item_bottom_icon_size">32dp</dimen>
|
<dimen name="feed_item_bottom_icon_size">32dp</dimen>
|
||||||
<dimen name="keyboard_height">200dp</dimen>
|
<dimen name="keyboard_height">200dp</dimen>
|
||||||
|
Loading…
Reference in New Issue
Block a user