Browse Source

Add mention click listener to reel share view

legacy
Ammar Githam 4 years ago
parent
commit
8e43519c5b
  1. 2
      app/src/main/java/awais/instagrabber/adapters/DirectMessageItemsAdapter.java
  2. 20
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java

2
app/src/main/java/awais/instagrabber/adapters/DirectMessageItemsAdapter.java

@ -104,7 +104,7 @@ public final class DirectMessageItemsAdapter extends ListAdapter<DirectItemModel
}
case REEL_SHARE: {
final LayoutDmRavenMediaBinding binding = LayoutDmRavenMediaBinding.inflate(layoutInflater, itemViewParent, false);
return new DirectMessageReelShareViewHolder(baseBinding, binding, onClickListener);
return new DirectMessageReelShareViewHolder(baseBinding, binding, onClickListener, mentionClickListener);
}
case MEDIA_SHARE: {
final LayoutDmMediaShareBinding binding = LayoutDmMediaShareBinding.inflate(layoutInflater, itemViewParent, false);

20
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java

@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
import awais.instagrabber.databinding.LayoutDmBaseBinding;
import awais.instagrabber.databinding.LayoutDmRavenMediaBinding;
import awais.instagrabber.interfaces.MentionClickListener;
import awais.instagrabber.models.direct_messages.DirectItemModel;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.utils.Utils;
@ -16,30 +17,31 @@ public class DirectMessageReelShareViewHolder extends DirectMessageItemViewHolde
public DirectMessageReelShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
@NonNull final LayoutDmRavenMediaBinding binding,
final View.OnClickListener onClickListener) {
final View.OnClickListener onClickListener,
final MentionClickListener mentionClickListener) {
super(baseBinding, onClickListener);
this.binding = binding;
binding.tvMessage.setVisibility(View.GONE);
binding.tvMessage.setMentionClickListener(mentionClickListener);
setItemView(binding.getRoot());
}
@Override
public void bindItem(final DirectItemModel directItemModel) {
final DirectItemModel.DirectItemReelShareModel reelShare = directItemModel.getReelShare();
final String text = reelShare.getText();
if (!Utils.isEmpty(text)) {
CharSequence text = reelShare.getText();
if (Utils.isEmpty(text)) {
binding.tvMessage.setVisibility(View.GONE);
} else {
if (Utils.hasMentions(text)) text = Utils.getMentionText(text); // for mentions
binding.tvMessage.setText(text);
binding.tvMessage.setVisibility(View.VISIBLE);
}
final DirectItemModel.DirectItemMediaModel reelShareMedia = reelShare.getMedia();
final MediaItemType mediaType = reelShareMedia.getMediaType();
if (mediaType == null)
if (mediaType == null) {
binding.mediaExpiredIcon.setVisibility(View.VISIBLE);
else {
} else {
binding.typeIcon.setVisibility(mediaType == MediaItemType.MEDIA_TYPE_VIDEO ||
mediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE);
getGlideRequestManager().load(reelShareMedia.getThumbUrl()).into(binding.ivMediaPreview);
}
}

Loading…
Cancel
Save