Search in sources :

Example 1 with AttachmentView

use of com.applozic.mobicomkit.api.attachment.AttachmentView in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method updateDownloadStatus.

public void updateDownloadStatus(final Message message) {
    if (this.getActivity() == null) {
        return;
    }
    this.getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                int index = messageList.indexOf(message);
                if (index != -1) {
                    Message smListItem = messageList.get(index);
                    smListItem.setKeyString(message.getKeyString());
                    smListItem.setFileMetaKeyStrings(message.getFileMetaKeyStrings());
                    if (messageList.get(index) != null) {
                        messageList.get(index).setKeyString(message.getKeyString());
                        messageList.get(index).setFileMetaKeyStrings(message.getFileMetaKeyStrings());
                    }
                    View view = recyclerView.getChildAt(index - linearLayoutManager.findFirstVisibleItemPosition());
                    if (view != null) {
                        final RelativeLayout attachmentDownloadProgressLayout = (RelativeLayout) view.findViewById(R.id.attachment_download_progress_layout);
                        final AttachmentView attachmentView = (AttachmentView) view.findViewById(R.id.main_attachment_view);
                        final ImageView preview = (ImageView) view.findViewById(R.id.preview);
                        TextView audioDurationTextView = (TextView) view.findViewById(R.id.audio_duration_textView);
                        final ImageView videoIcon = (ImageView) view.findViewById(R.id.video_icon);
                        String audioDuration;
                        if (message.getFileMetas() != null && message.getFileMetas().getContentType().contains("image")) {
                            attachmentView.setVisibility(VISIBLE);
                            preview.setVisibility(View.GONE);
                            attachmentView.setMessage(smListItem);
                            attachmentDownloadProgressLayout.setVisibility(View.GONE);
                        } else if (message.getFileMetas() != null && message.getFileMetas().getContentType().contains("video")) {
                            FileClientService fileClientService = new FileClientService(getContext());
                            attachedFile.setVisibility(View.GONE);
                            preview.setVisibility(VISIBLE);
                            videoIcon.setVisibility(VISIBLE);
                            preview.setImageBitmap(fileClientService.getOrCreateVideoThumbnail(message.getFilePaths().get(0)));
                        } else if (message.getFileMetas() != null) {
                            // Hide Attachment View...
                            RelativeLayout applozicDocRelativeLayout = (RelativeLayout) view.findViewById(R.id.applozic_doc_downloaded);
                            ImageView imageViewDoc = (ImageView) applozicDocRelativeLayout.findViewById(R.id.doc_icon);
                            if (message.getFileMetas() != null && message.getFilePaths() == null) {
                                if (message.getFileMetas().getContentType().contains("audio")) {
                                    imageViewDoc.setImageResource(R.drawable.ic_play_circle_outline);
                                } else {
                                    imageViewDoc.setImageResource(R.drawable.ic_documentreceive);
                                }
                                applozicDocRelativeLayout.setVisibility(VISIBLE);
                            } else if (message.getFilePaths() != null) {
                                String filePath = message.getFilePaths().get(0);
                                final String mimeType = FileUtils.getMimeType(filePath);
                                if (mimeType.contains("audio")) {
                                    if (message.isAttachmentDownloaded()) {
                                        audioDuration = ApplozicAudioManager.getInstance(getContext()).refreshAudioDuration(filePath);
                                        audioDurationTextView.setVisibility(View.VISIBLE);
                                        audioDurationTextView.setText(audioDuration);
                                    } else {
                                        audioDurationTextView.setVisibility(View.VISIBLE);
                                        audioDurationTextView.setText("00:00");
                                    }
                                    imageViewDoc.setImageResource(R.drawable.ic_play_circle_outline);
                                } else {
                                    imageViewDoc.setImageResource(R.drawable.ic_documentreceive);
                                }
                                applozicDocRelativeLayout.setVisibility(VISIBLE);
                            }
                            view.findViewById(R.id.applozic_doc_download_progress_rl).setVisibility(View.GONE);
                        }
                    }
                }
            } catch (Exception ex) {
                Utils.printLog(getContext(), TAG, "Exception while updating download status: " + ex.getMessage());
            }
        }
    });
}
Also used : AlRichMessage(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage) Message(com.applozic.mobicomkit.api.conversation.Message) AttachmentView(com.applozic.mobicomkit.api.attachment.AttachmentView) RelativeLayout(android.widget.RelativeLayout) FileClientService(com.applozic.mobicomkit.api.attachment.FileClientService) MentionAutoCompleteTextView(com.applozic.mobicomkit.uiwidgets.conversation.mention.MentionAutoCompleteTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) MentionAutoCompleteTextView(com.applozic.mobicomkit.uiwidgets.conversation.mention.MentionAutoCompleteTextView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AttachmentView(com.applozic.mobicomkit.api.attachment.AttachmentView) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 2 with AttachmentView

use of com.applozic.mobicomkit.api.attachment.AttachmentView in project Applozic-Android-SDK by AppLozic.

the class MessageInfoFragment method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.applozic_message_info, container, false);
    Bundle bundle = getArguments();
    String messageJson = bundle.getString(MESSAGE_ARGUMENT_KEY);
    message = (Message) GsonUtils.getObjectFromJson(messageJson, Message.class);
    attachmentView = (AttachmentView) view.findViewById(R.id.applozic_message_info_attachmentview);
    ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.applozic_message_info_progress_bar);
    attachmentView.setProressBar(progressBar);
    attachmentView.setVisibility(message.hasAttachment() ? View.VISIBLE : View.GONE);
    RelativeLayout defaultRelativeLayout = (RelativeLayout) view.findViewById(R.id.applozic_message_info_default_layout);
    TextView textView = (TextView) view.findViewById(R.id.applozic_message_info_message_text);
    readListView = (RecyclerView) view.findViewById(R.id.applozic_message_info_read_list);
    deliveredListView = (RecyclerView) view.findViewById(R.id.applozic_message_info_delivered_list_view);
    readListView.setHasFixedSize(true);
    deliveredListView.setHasFixedSize(true);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    RecyclerView.LayoutManager mLayoutManagerForDev = new LinearLayoutManager(getActivity());
    readListView.setLayoutManager(mLayoutManager);
    readListView.setClickable(true);
    deliveredListView.setLayoutManager(mLayoutManagerForDev);
    deliveredListView.setClickable(true);
    init();
    ImageView locationImageView = (ImageView) view.findViewById(R.id.static_mapview);
    final LinearLayout mainContactShareLayout = (LinearLayout) view.findViewById(R.id.contact_share_layout);
    RelativeLayout chatLocation = (RelativeLayout) view.findViewById(R.id.chat_location);
    if (message.hasAttachment() && !message.isContactMessage() && !message.isLocationMessage()) {
        textView.setVisibility(View.GONE);
        attachmentView.setMessage(message);
        chatLocation.setVisibility(View.GONE);
        defaultRelativeLayout.setVisibility(View.GONE);
        defaultRelativeLayout.setVisibility(View.VISIBLE);
        setupAttachmentView(message, defaultRelativeLayout);
    } else {
        defaultRelativeLayout.setVisibility(View.GONE);
        textView.setVisibility(View.VISIBLE);
        textView.setText(message.getMessage());
    }
    if (message.isLocationMessage()) {
        defaultRelativeLayout.setVisibility(View.GONE);
        chatLocation.setVisibility(View.VISIBLE);
        locationImageLoader.setImageFadeIn(false);
        locationImageLoader.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
        locationImageLoader.loadImage(LocationUtils.loadStaticMap(message.getMessage(), geoApiKey), locationImageView);
        textView.setVisibility(View.GONE);
    } else {
        chatLocation.setVisibility(View.GONE);
    }
    if (message.isContactMessage()) {
        chatLocation.setVisibility(View.GONE);
        defaultRelativeLayout.setVisibility(View.GONE);
        setupContactShareView(message, mainContactShareLayout);
        textView.setVisibility(View.GONE);
    } else {
        mainContactShareLayout.setVisibility(View.GONE);
    }
    messageInfoAsyncTask = new MessageInfoAsyncTask(message.getKeyString(), getActivity());
    AlTask.execute(messageInfoAsyncTask);
    return view;
}
Also used : Bundle(android.os.Bundle) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AttachmentView(com.applozic.mobicomkit.api.attachment.AttachmentView) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout)

Aggregations

View (android.view.View)2 ImageView (android.widget.ImageView)2 RelativeLayout (android.widget.RelativeLayout)2 TextView (android.widget.TextView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 AttachmentView (com.applozic.mobicomkit.api.attachment.AttachmentView)2 Bundle (android.os.Bundle)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 LinearLayout (android.widget.LinearLayout)1 ProgressBar (android.widget.ProgressBar)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)1 Message (com.applozic.mobicomkit.api.conversation.Message)1 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1 MentionAutoCompleteTextView (com.applozic.mobicomkit.uiwidgets.conversation.mention.MentionAutoCompleteTextView)1 AlRichMessage (com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1