1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-16 11:47:29 +00:00

Add mention click listener to reel share view

This commit is contained in:
Ammar Githam 2020-08-21 22:44:24 +09:00
parent f7fb374aca
commit 8e43519c5b
2 changed files with 12 additions and 10 deletions

View File

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

View File

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