mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
group message width layout fix (dynamic)
This commit is contained in:
parent
47e8645dea
commit
8de3021c7f
@ -4,6 +4,7 @@ import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
@ -42,6 +43,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private final int dmRadius;
|
||||
private final int messageInfoPaddingSmall;
|
||||
private final int dmRadiusSmall;
|
||||
private final int groupMessageWidth;
|
||||
private final List<Long> userIds;
|
||||
|
||||
public DirectItemViewHolder(@NonNull final LayoutDmBaseBinding binding,
|
||||
@ -60,10 +62,14 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
||||
binding.ivProfilePic.setOnClickListener(thread.isGroup() ? onClickListener : null);
|
||||
// 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();
|
||||
dmRadius = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius);
|
||||
dmRadiusSmall = resources.getDimensionPixelSize(R.dimen.dm_message_card_radius_small);
|
||||
messageInfoPaddingSmall = Utils.convertDpToPx(4);
|
||||
DisplayMetrics displayMetrics = itemView.getResources().getDisplayMetrics();
|
||||
// messageInfoPaddingSmall is used cuz it's also 4dp, 1 avatar margin + 2 paddings = 3
|
||||
groupMessageWidth = displayMetrics.widthPixels - margin - avatarSize - messageInfoPaddingSmall * 3;
|
||||
}
|
||||
|
||||
public void bind(final DirectItem item) {
|
||||
@ -86,6 +92,9 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
||||
binding.tvUsername.setText(user.getUsername());
|
||||
binding.ivProfilePic.setImageURI(user.getProfilePicUrl());
|
||||
}
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) binding.chatMessageLayout.getLayoutParams();
|
||||
layoutParams.matchConstraintMaxWidth = groupMessageWidth;
|
||||
binding.chatMessageLayout.setLayoutParams(layoutParams);
|
||||
}
|
||||
} else {
|
||||
binding.ivProfilePic.setVisibility(View.GONE);
|
||||
|
@ -123,7 +123,6 @@
|
||||
app:layout_constraintStart_toEndOf="@id/ivProfilePic"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvUsername"
|
||||
app:layout_constraintWidth_min="wrap"
|
||||
app:layout_constraintWidth_max="230dp"
|
||||
app:viewPartInfo="@id/message_info"
|
||||
app:viewPartMain="@id/message">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user