Search in sources :

Example 6 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method setVideoData.

private void setVideoData(VideoMessageViewHolder viewHolder, int i) {
    BaseMessage baseMessage = messageList.get(i);
    if (!baseMessage.getSender().getUid().equals(loggedInUser.getUid())) {
        if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
            viewHolder.tvUser.setVisibility(View.GONE);
            viewHolder.ivUser.setVisibility(View.GONE);
        } else if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
            if (isUserDetailVisible) {
                viewHolder.tvUser.setVisibility(View.VISIBLE);
                viewHolder.ivUser.setVisibility(View.VISIBLE);
            } else {
                viewHolder.tvUser.setVisibility(View.GONE);
                viewHolder.ivUser.setVisibility(View.INVISIBLE);
            }
            setAvatar(viewHolder.ivUser, baseMessage.getSender().getAvatar(), baseMessage.getSender().getName());
            viewHolder.tvUser.setText(baseMessage.getSender().getName());
        }
    }
    if (((MediaMessage) baseMessage).getAttachment() != null)
        Glide.with(context).load(((MediaMessage) baseMessage).getAttachment().getFileUrl()).into(viewHolder.imageView);
    FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() {

        @Override
        public void onSuccess(Boolean booleanVal) {
            if (baseMessage.getReplyCount() != 0 && booleanVal) {
                viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE);
                viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount() + " " + context.getResources().getString(R.string.replies));
            } else {
                viewHolder.tvThreadReplyCount.setVisibility(View.GONE);
            }
        }
    });
    viewHolder.tvThreadReplyCount.setOnClickListener(view -> {
        Intent intent = new Intent(context, CometChatThreadMessageListActivity.class);
        // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString());
        intent.putExtra(UIKitConstants.IntentStrings.NAME, baseMessage.getSender().getName());
        intent.putExtra(UIKitConstants.IntentStrings.AVATAR, baseMessage.getSender().getAvatar());
        intent.putExtra(UIKitConstants.IntentStrings.REPLY_COUNT, baseMessage.getReplyCount());
        intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getName());
        intent.putExtra(UIKitConstants.IntentStrings.PARENT_ID, baseMessage.getId());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, baseMessage.getType());
        intent.putExtra(UIKitConstants.IntentStrings.REACTION_INFO, Extensions.getReactionsOnMessage(baseMessage));
        intent.putExtra(UIKitConstants.IntentStrings.SENTAT, baseMessage.getSentAt());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_NAME, ((MediaMessage) baseMessage).getAttachment().getFileName());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_EXTENSION, ((MediaMessage) baseMessage).getAttachment().getFileExtension());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_URL, ((MediaMessage) baseMessage).getAttachment().getFileUrl());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_SIZE, ((MediaMessage) baseMessage).getAttachment().getFileSize());
        intent.putExtra(UIKitConstants.IntentStrings.TYPE, baseMessage.getReceiverType());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_CATEGORY, baseMessage.getCategory());
        if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
            intent.putExtra(UIKitConstants.IntentStrings.GUID, baseMessage.getReceiverUid());
        } else {
            if (baseMessage.getReceiverUid().equals(loggedInUser.getUid()))
                intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getUid());
            else
                intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getReceiverUid());
        }
        context.startActivity(intent);
    });
    showMessageTime(viewHolder, baseMessage);
    // if (selectedItemList.contains(baseMessage.getId()))
    viewHolder.txtTime.setVisibility(View.VISIBLE);
    // else
    // viewHolder.txtTime.setVisibility(View.GONE);
    // 
    viewHolder.rlMessageBubble.setOnClickListener(view -> {
        setSelectedMessage(baseMessage.getId());
        notifyDataSetChanged();
    });
    viewHolder.rlMessageBubble.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (!isLongClickEnabled && !isTextMessageClick) {
                isImageMessageClick = true;
                setLongClickSelectedItem(baseMessage);
                messageLongClick.setLongMessageClick(longselectedItemList);
                notifyItemChanged(i);
            }
            return true;
        }
    });
    viewHolder.playBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            openMediaViewActivity(baseMessage);
        }
    });
    viewHolder.reactionLayout.setVisibility(View.GONE);
    setReactionSupport(baseMessage, viewHolder.reactionLayout);
}
Also used : MediaMessage(com.cometchat.pro.models.MediaMessage) BaseMessage(com.cometchat.pro.models.BaseMessage) FeatureRestriction(com.cometchat.pro.uikit.ui_settings.FeatureRestriction) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) MaterialCardView(com.google.android.material.card.MaterialCardView)

Example 7 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method setStickerData.

/**
 * This method is called whenever viewType of item is sticker. It is used to bind StickerMessageViewHolder
 * contents with CustomMessage at a given position.
 * It loads image from url availabl in CustomMessage.
 *
 * @param viewHolder is a object of StickerMessageViewHolder.
 * @param i is a position of item in recyclerView.
 * @see CustomMessage
 * @see BaseMessage
 */
private void setStickerData(StickerMessageViewHolder viewHolder, int i) {
    BaseMessage baseMessage = messageList.get(i);
    if (!baseMessage.getSender().getUid().equals(loggedInUser.getUid())) {
        if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
            viewHolder.tvUser.setVisibility(View.GONE);
            viewHolder.ivUser.setVisibility(View.GONE);
        } else if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
            if (isUserDetailVisible) {
                viewHolder.tvUser.setVisibility(View.VISIBLE);
                viewHolder.ivUser.setVisibility(View.VISIBLE);
            } else {
                viewHolder.tvUser.setVisibility(View.GONE);
                viewHolder.ivUser.setVisibility(View.INVISIBLE);
            }
            setAvatar(viewHolder.ivUser, baseMessage.getSender().getAvatar(), baseMessage.getSender().getName());
            viewHolder.tvUser.setText(baseMessage.getSender().getName());
        }
    }
    viewHolder.stickerView.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_defaulf_image));
    try {
        Glide.with(context).load(((CustomMessage) baseMessage).getCustomData().getString("sticker_url")).into(viewHolder.stickerView);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() {

        @Override
        public void onSuccess(Boolean booleanVal) {
            if (baseMessage.getReplyCount() != 0 && booleanVal) {
                viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE);
                viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount() + " " + context.getResources().getString(R.string.replies));
            } else {
                viewHolder.tvThreadReplyCount.setVisibility(View.GONE);
            }
        }
    });
    viewHolder.tvThreadReplyCount.setOnClickListener(view -> {
        Intent intent = new Intent(context, CometChatThreadMessageListActivity.class);
        // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString());
        intent.putExtra(UIKitConstants.IntentStrings.NAME, baseMessage.getSender().getName());
        intent.putExtra(UIKitConstants.IntentStrings.AVATAR, baseMessage.getSender().getAvatar());
        intent.putExtra(UIKitConstants.IntentStrings.REPLY_COUNT, baseMessage.getReplyCount());
        intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getName());
        intent.putExtra(UIKitConstants.IntentStrings.PARENT_ID, baseMessage.getId());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, UIKitConstants.IntentStrings.STICKERS);
        intent.putExtra(UIKitConstants.IntentStrings.REACTION_INFO, Extensions.getReactionsOnMessage(baseMessage));
        intent.putExtra(UIKitConstants.IntentStrings.SENTAT, baseMessage.getSentAt());
        try {
            intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_NAME, ((CustomMessage) baseMessage).getCustomData().getString("name"));
            intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_URL, ((CustomMessage) baseMessage).getCustomData().getString("url"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        intent.putExtra(UIKitConstants.IntentStrings.TYPE, baseMessage.getReceiverType());
        intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_CATEGORY, baseMessage.getCategory());
        if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
            intent.putExtra(UIKitConstants.IntentStrings.GUID, baseMessage.getReceiverUid());
        } else {
            if (baseMessage.getReceiverUid().equals(loggedInUser.getUid()))
                intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getUid());
            else
                intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getReceiverUid());
        }
        context.startActivity(intent);
    });
    showMessageTime(viewHolder, baseMessage);
    // if (selectedItemList.contains(baseMessage.getId()))
    viewHolder.txtTime.setVisibility(View.VISIBLE);
    // else
    // viewHolder.txtTime.setVisibility(View.GONE);
    viewHolder.stickerView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (!isLongClickEnabled && !isTextMessageClick) {
                isImageMessageClick = true;
                setLongClickSelectedItem(baseMessage);
                messageLongClick.setLongMessageClick(longselectedItemList);
                notifyItemChanged(i);
            }
            return true;
        }
    });
    viewHolder.reactionLayout.setVisibility(View.GONE);
    setReactionSupport(baseMessage, viewHolder.reactionLayout);
}
Also used : BaseMessage(com.cometchat.pro.models.BaseMessage) FeatureRestriction(com.cometchat.pro.uikit.ui_settings.FeatureRestriction) CustomMessage(com.cometchat.pro.models.CustomMessage) JSONException(org.json.JSONException) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) MaterialCardView(com.google.android.material.card.MaterialCardView)

Example 8 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method setLinkData.

private void setLinkData(LinkMessageViewHolder viewHolder, int i) {
    BaseMessage baseMessage = messageList.get(i);
    String url = null;
    if (baseMessage != null) {
        if (!baseMessage.getSender().getUid().equals(loggedInUser.getUid())) {
            if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
                viewHolder.tvUser.setVisibility(View.GONE);
                viewHolder.ivUser.setVisibility(View.GONE);
            } else if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
                if (isUserDetailVisible) {
                    viewHolder.tvUser.setVisibility(View.VISIBLE);
                    viewHolder.ivUser.setVisibility(View.VISIBLE);
                } else {
                    viewHolder.tvUser.setVisibility(View.GONE);
                    viewHolder.ivUser.setVisibility(View.INVISIBLE);
                }
                setAvatar(viewHolder.ivUser, baseMessage.getSender().getAvatar(), baseMessage.getSender().getName());
                viewHolder.tvUser.setText(baseMessage.getSender().getName());
            }
        }
        if (baseMessage.getDeletedAt() == 0) {
            HashMap<String, JSONObject> extensionList = Extensions.extensionCheck(baseMessage);
            if (extensionList != null) {
                if (extensionList.containsKey("linkPreview")) {
                    JSONObject linkPreviewJsonObject = extensionList.get("linkPreview");
                    try {
                        String description = linkPreviewJsonObject.getString("description");
                        String image = linkPreviewJsonObject.getString("image");
                        String title = linkPreviewJsonObject.getString("title");
                        url = linkPreviewJsonObject.getString("url");
                        Log.e("setLinkData: ", baseMessage.toString() + "\n\n" + url + "\n" + description + "\n" + image);
                        viewHolder.linkTitle.setText(title);
                        viewHolder.linkSubtitle.setText(description);
                        Glide.with(context).load(Uri.parse(image)).timeout(1000).into(viewHolder.linkImg);
                        if (url.contains("youtu.be") || url.contains("youtube")) {
                            viewHolder.videoLink.setVisibility(View.VISIBLE);
                            viewHolder.linkVisit.setText(context.getResources().getString(R.string.view_on_youtube));
                        } else {
                            viewHolder.videoLink.setVisibility(View.GONE);
                            viewHolder.linkVisit.setText(context.getResources().getString(R.string.visit));
                        }
                        String messageStr = ((TextMessage) baseMessage).getText();
                        if (((TextMessage) baseMessage).getText().equals(url) || ((TextMessage) baseMessage).getText().equals(url + "/")) {
                            viewHolder.message.setVisibility(View.GONE);
                        } else {
                            viewHolder.message.setVisibility(View.VISIBLE);
                        }
                        viewHolder.message.setText(messageStr);
                    } catch (Exception e) {
                        Log.e("setLinkData: ", e.getMessage());
                    }
                }
            }
        }
        FeatureRestriction.isThreadedMessagesEnabled(new FeatureRestriction.OnSuccessListener() {

            @Override
            public void onSuccess(Boolean booleanVal) {
                if (baseMessage.getReplyCount() != 0 && booleanVal) {
                    viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE);
                    viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount() + " " + context.getResources().getString(R.string.replies));
                } else {
                    viewHolder.tvThreadReplyCount.setVisibility(View.GONE);
                }
            }
        });
        viewHolder.tvThreadReplyCount.setOnClickListener(view -> {
            Intent intent = new Intent(context, CometChatThreadMessageListActivity.class);
            // intent.putExtra(StringContract.IntentStrings.PARENT_BASEMESSAGE,baseMessage.toString());
            intent.putExtra(UIKitConstants.IntentStrings.NAME, baseMessage.getSender().getName());
            intent.putExtra(UIKitConstants.IntentStrings.AVATAR, baseMessage.getSender().getAvatar());
            intent.putExtra(UIKitConstants.IntentStrings.REPLY_COUNT, baseMessage.getReplyCount());
            intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getName());
            intent.putExtra(UIKitConstants.IntentStrings.PARENT_ID, baseMessage.getId());
            intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, baseMessage.getType());
            intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_CATEGORY, baseMessage.getCategory());
            intent.putExtra(UIKitConstants.IntentStrings.REACTION_INFO, Extensions.getReactionsOnMessage(baseMessage));
            intent.putExtra(UIKitConstants.IntentStrings.SENTAT, baseMessage.getSentAt());
            if (baseMessage.getType().equals(CometChatConstants.MESSAGE_TYPE_TEXT))
                intent.putExtra(UIKitConstants.IntentStrings.TEXTMESSAGE, ((TextMessage) baseMessage).getText());
            else {
                intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_NAME, ((MediaMessage) baseMessage).getAttachment().getFileName());
                intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_EXTENSION, ((MediaMessage) baseMessage).getAttachment().getFileExtension());
                intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_URL, ((MediaMessage) baseMessage).getAttachment().getFileUrl());
                intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE_IMAGE_SIZE, ((MediaMessage) baseMessage).getAttachment().getFileSize());
            }
            intent.putExtra(UIKitConstants.IntentStrings.TYPE, baseMessage.getReceiverType());
            if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
                intent.putExtra(UIKitConstants.IntentStrings.GUID, baseMessage.getReceiverUid());
            } else {
                if (baseMessage.getReceiverUid().equals(loggedInUser.getUid()))
                    intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getSender().getUid());
                else
                    intent.putExtra(UIKitConstants.IntentStrings.UID, baseMessage.getReceiverUid());
            }
            context.startActivity(intent);
        });
        PatternUtils.setHyperLinkSupport(context, viewHolder.message);
        showMessageTime(viewHolder, baseMessage);
        String finalUrl = url;
        viewHolder.linkVisit.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (finalUrl != null) {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(finalUrl));
                    context.startActivity(intent);
                }
            }
        });
        // if (selectedItemList.contains(baseMessage.getId()))
        viewHolder.txtTime.setVisibility(View.VISIBLE);
        // else
        // viewHolder.txtTime.setVisibility(View.GONE);
        // if (i < selectedItems.length && selectedItems[i] == 0) {
        // viewHolder.txtTime.setVisibility(View.GONE);
        // } else
        // viewHolder.txtTime.setVisibility(View.VISIBLE);
        setColorFilter(baseMessage, viewHolder.cvMessageView);
        viewHolder.rlMessageBubble.setOnClickListener(view -> {
            if (isLongClickEnabled && !isImageMessageClick) {
                setLongClickSelectedItem(baseMessage);
                messageLongClick.setLongMessageClick(longselectedItemList);
            } else {
                setSelectedMessage(baseMessage.getId());
            }
            notifyItemChanged(i);
        });
        viewHolder.rlMessageBubble.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View view) {
                if (!isImageMessageClick) {
                    isLongClickEnabled = true;
                    isTextMessageClick = true;
                    setLongClickSelectedItem(baseMessage);
                    messageLongClick.setLongMessageClick(longselectedItemList);
                    notifyItemChanged(i);
                }
                return true;
            }
        });
        viewHolder.reactionLayout.setVisibility(View.GONE);
        setReactionSupport(baseMessage, viewHolder.reactionLayout);
        viewHolder.itemView.setTag(R.string.message, baseMessage);
    }
}
Also used : MediaMessage(com.cometchat.pro.models.MediaMessage) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) MaterialCardView(com.google.android.material.card.MaterialCardView) CometChatException(com.cometchat.pro.exceptions.CometChatException) JSONException(org.json.JSONException) BaseMessage(com.cometchat.pro.models.BaseMessage) JSONObject(org.json.JSONObject) FeatureRestriction(com.cometchat.pro.uikit.ui_settings.FeatureRestriction) TextMessage(com.cometchat.pro.models.TextMessage)

Example 9 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method onBindHeaderViewHolder.

@Override
public void onBindHeaderViewHolder(DateItemHolder var1, int var2, long var3) {
    BaseMessage baseMessage = messageList.get(var2);
    var1.txtMessageDate.setBackground(context.getResources().getDrawable(R.drawable.cc_rounded_date_button));
    if (baseMessage.getSentAt() > 0) {
        Date date = new Date(baseMessage.getSentAt());
        String formattedDate = Utils.getDate(context, date.getTime());
        var1.txtMessageDate.setText(formattedDate);
    } else {
        var1.txtMessageDate.setText(context.getString(R.string.updating));
    }
}
Also used : BaseMessage(com.cometchat.pro.models.BaseMessage) Date(java.util.Date)

Example 10 with BaseMessage

use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.

the class MessageAdapter method onBindViewHolder.

/**
 * This method is used to bind the various ViewHolder content with their respective view types.
 * Here different methods are being called for different view type and in each method different
 * ViewHolder are been passed as parameter along with position of item.
 *
 * Ex :- For TextMessage <code>setTextData((TextMessageViewHolder)viewHolder,i)</code> is been called.
 * where <b>viewHolder</b> is casted as <b>TextMessageViewHolder</b> and <b>i</b> is position of item.
 *
 * @see MessageAdapter#setTextData(TextMessageViewHolder, int)
 * @see MessageAdapter#setImageData(ImageMessageViewHolder, int)
 * @see MessageAdapter#setFileData(FileMessageViewHolder, int)
 * @see MessageAdapter#setActionData(ActionMessageViewHolder, int)
 *
 * @param viewHolder is a object of RecyclerViewHolder.
 * @param i is position of item in recyclerView.
 */
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
    BaseMessage baseMessage = messageList.get(i);
    BaseMessage nextMessage = null, prevMessage = null;
    boolean isNextMessage = false, isPreviousMessage = false, isPrevActionMessage = false;
    if ((i + 1) < messageList.size()) {
        if (messageList.get(i + 1).getSender() != null)
            nextMessage = messageList.get(i + 1);
    }
    if ((i - 1) >= 0) {
        if (messageList.get(i - 1).getSender() != null)
            prevMessage = messageList.get(i - 1);
    }
    isPrevActionMessage = (prevMessage != null && (prevMessage.getCategory().equals(CometChatConstants.CATEGORY_ACTION) || prevMessage.getCategory().equals(CometChatConstants.CATEGORY_CALL)));
    isNextMessage = (nextMessage != null && baseMessage.getSender().getUid().equals(nextMessage.getSender().getUid()));
    isPreviousMessage = (prevMessage != null && baseMessage.getSender().getUid().equals(prevMessage.getSender().getUid()));
    if (!isPreviousMessage && isNextMessage) {
        isUserDetailVisible = true;
    }
    if (isPreviousMessage && isNextMessage) {
        isUserDetailVisible = false;
    } else if (!isNextMessage && !isPreviousMessage) {
        isUserDetailVisible = true;
    } else if (!isNextMessage) {
        isUserDetailVisible = false;
    }
    if (isPrevActionMessage) {
        isUserDetailVisible = true;
    }
    switch(viewHolder.getItemViewType()) {
        case LEFT_DELETE_MESSAGE:
            ((DeleteMessageViewHolder) viewHolder).ivUser.setVisibility(View.GONE);
        case RIGHT_DELETE_MESSAGE:
            setDeleteData((DeleteMessageViewHolder) viewHolder, i);
            break;
        case LEFT_TEXT_MESSAGE:
        case LEFT_REPLY_TEXT_MESSAGE:
            ((TextMessageViewHolder) viewHolder).ivUser.setVisibility(View.GONE);
        case RIGHT_TEXT_MESSAGE:
        case RIGHT_REPLY_TEXT_MESSAGE:
            setTextData((TextMessageViewHolder) viewHolder, i);
            break;
        case LEFT_LINK_MESSAGE:
        case RIGHT_LINK_MESSAGE:
            setLinkData((LinkMessageViewHolder) viewHolder, i);
            break;
        case LEFT_IMAGE_MESSAGE:
        case RIGHT_IMAGE_MESSAGE:
            setImageData((ImageMessageViewHolder) viewHolder, i);
            break;
        case LEFT_STICKER_MESSAGE:
        case RIGHT_STICKER_MESSAGE:
            setStickerData((StickerMessageViewHolder) viewHolder, i);
            break;
        case LEFT_AUDIO_MESSAGE:
        case RIGHT_AUDIO_MESSAGE:
            setAudioData((AudioMessageViewHolder) viewHolder, i);
            break;
        case LEFT_VIDEO_MESSAGE:
        case RIGHT_VIDEO_MESSAGE:
            setVideoData((VideoMessageViewHolder) viewHolder, i);
            break;
        case LEFT_FILE_MESSAGE:
            ((FileMessageViewHolder) viewHolder).ivUser.setVisibility(View.GONE);
        case RIGHT_FILE_MESSAGE:
            setFileData((FileMessageViewHolder) viewHolder, i);
            break;
        case ACTION_MESSAGE:
        case CALL_MESSAGE:
            setActionData((ActionMessageViewHolder) viewHolder, i);
            break;
        case LEFT_CUSTOM_MESSAGE:
            ((CustomMessageViewHolder) viewHolder).ivUser.setVisibility(View.GONE);
        case RIGHT_CUSTOM_MESSAGE:
            setCustomData((CustomMessageViewHolder) viewHolder, i);
            break;
        case LEFT_LOCATION_CUSTOM_MESSAGE:
        case RIGHT_LOCATION_CUSTOM_MESSAGE:
            setLocationData((LocationMessageViewHolder) viewHolder, i);
            break;
        case RIGHT_POLLS_CUSTOM_MESSAGE:
        case LEFT_POLLS_CUSTOM_MESSAGE:
            setPollsData((PollMessageViewHolder) viewHolder, i);
            break;
        case LEFT_WHITEBOARD_MESSAGE:
        case RIGHT_WHITEBOARD_MESSAGE:
            setWhiteBoardData((WhiteBoardViewHolder) viewHolder, i);
            break;
        case LEFT_WRITEBOARD_MESSAGE:
        case RIGHT_WRITEBOARD_MESSAGE:
            setWriteBoardData((WriteBoardViewHolder) viewHolder, i);
            break;
        case LEFT_GROUP_CALL_MESSAGE:
        case RIGHT_GROUP_CALL_MESSAGE:
            setGroupCallMessageData((GroupCallMessageViewHolder) viewHolder, i);
            break;
    }
}
Also used : BaseMessage(com.cometchat.pro.models.BaseMessage)

Aggregations

BaseMessage (com.cometchat.pro.models.BaseMessage)53 View (android.view.View)19 ImageView (android.widget.ImageView)19 TextView (android.widget.TextView)19 CardView (androidx.cardview.widget.CardView)19 RecyclerView (androidx.recyclerview.widget.RecyclerView)19 MaterialCardView (com.google.android.material.card.MaterialCardView)19 Intent (android.content.Intent)18 MediaMessage (com.cometchat.pro.models.MediaMessage)14 JSONException (org.json.JSONException)14 CometChatException (com.cometchat.pro.exceptions.CometChatException)11 FeatureRestriction (com.cometchat.pro.uikit.ui_settings.FeatureRestriction)11 JSONObject (org.json.JSONObject)10 TextMessage (com.cometchat.pro.models.TextMessage)8 User (com.cometchat.pro.models.User)7 AlertDialog (android.app.AlertDialog)6 DialogInterface (android.content.DialogInterface)6 CustomMessage (com.cometchat.pro.models.CustomMessage)5 Call (com.cometchat.pro.core.Call)4 Attachment (com.cometchat.pro.models.Attachment)4