|
@ -4,6 +4,7 @@ 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; |
|
@ -42,6 +43,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder { |
|
|
private final int dmRadius; |
|
|
private final int dmRadius; |
|
|
private final int messageInfoPaddingSmall; |
|
|
private final int messageInfoPaddingSmall; |
|
|
private final int dmRadiusSmall; |
|
|
private final int dmRadiusSmall; |
|
|
|
|
|
private final int groupMessageWidth; |
|
|
private final List<Long> userIds; |
|
|
private final List<Long> userIds; |
|
|
|
|
|
|
|
|
public DirectItemViewHolder(@NonNull final LayoutDmBaseBinding binding, |
|
|
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.ivProfilePic.setOnClickListener(thread.isGroup() ? onClickListener : null); |
|
|
// binding.messageCard.setOnClickListener(onClickListener); |
|
|
// binding.messageCard.setOnClickListener(onClickListener); |
|
|
margin = itemView.getResources().getDimensionPixelSize(R.dimen.dm_message_item_margin); |
|
|
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(); |
|
|
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 = 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) { |
|
|
public void bind(final DirectItem item) { |
|
@ -86,6 +92,9 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder { |
|
|
binding.tvUsername.setText(user.getUsername()); |
|
|
binding.tvUsername.setText(user.getUsername()); |
|
|
binding.ivProfilePic.setImageURI(user.getProfilePicUrl()); |
|
|
binding.ivProfilePic.setImageURI(user.getProfilePicUrl()); |
|
|
} |
|
|
} |
|
|
|
|
|
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) binding.chatMessageLayout.getLayoutParams(); |
|
|
|
|
|
layoutParams.matchConstraintMaxWidth = groupMessageWidth; |
|
|
|
|
|
binding.chatMessageLayout.setLayoutParams(layoutParams); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
binding.ivProfilePic.setVisibility(View.GONE); |
|
|
binding.ivProfilePic.setVisibility(View.GONE); |
|
|