Search in sources :

Example 1 with MobiComKitActivityInterface

use of com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface in project Applozic-Android-SDK by AppLozic.

the class DetailedConversationAdapter method showFullView.

private void showFullView(Message smListItem) {
    try {
        final String mimeType = FileUtils.getMimeType(smListItem.getFilePaths().get(0));
        if (mimeType != null) {
            if (mimeType.startsWith("image")) {
                Intent intent = new Intent(context, FullScreenImageActivity.class);
                intent.putExtra(MobiComKitConstants.MESSAGE_JSON_INTENT, GsonUtils.getJsonFromObject(smListItem, Message.class));
                ((MobiComKitActivityInterface) context).startActivityForResult(intent, MobiComKitActivityInterface.REQUEST_CODE_FULL_SCREEN_ACTION);
            }
            if (mimeType.startsWith("video")) {
                if (smListItem.isAttachmentDownloaded()) {
                    Intent intentVideo = new Intent();
                    intentVideo.setAction(Intent.ACTION_VIEW);
                    Uri outputUri;
                    if (Utils.hasNougat()) {
                        outputUri = FileProvider.getUriForFile(context, Utils.getMetaDataValue(context, MobiComKitConstants.PACKAGE_NAME) + ".provider", new File(smListItem.getFilePaths().get(0)));
                    } else {
                        outputUri = Uri.fromFile(new File(smListItem.getFilePaths().get(0)));
                    }
                    intentVideo.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    if (intentVideo.resolveActivity(context.getPackageManager()) != null) {
                        intentVideo.setDataAndType(outputUri, "video/*");
                        context.startActivity(intentVideo);
                    } else {
                        Toast.makeText(context, R.string.info_app_not_found_to_open_file, Toast.LENGTH_LONG).show();
                    }
                }
            }
        }
    } catch (Exception e) {
        Utils.printLog(context, TAG, "No application found to open this file");
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MobiComKitActivityInterface(com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface) Intent(android.content.Intent) SpannableString(android.text.SpannableString) Uri(android.net.Uri) File(java.io.File)

Example 2 with MobiComKitActivityInterface

use of com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface in project Applozic-Android-SDK by AppLozic.

the class ConversationUIService method reconnectMQTT.

public void reconnectMQTT() {
    try {
        if (((MobiComKitActivityInterface) fragmentActivity).getRetryCount() <= 3) {
            if (Utils.isInternetAvailable(fragmentActivity)) {
                Utils.printLog(fragmentActivity, TAG, "Reconnecting to mqtt.");
                ((MobiComKitActivityInterface) fragmentActivity).retry();
                Intent intent = new Intent(fragmentActivity, ApplozicMqttIntentService.class);
                intent.putExtra(ApplozicMqttIntentService.SUBSCRIBE, true);
                ApplozicMqttIntentService.enqueueWork(fragmentActivity, intent);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MobiComKitActivityInterface(com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface) Intent(android.content.Intent)

Example 3 with MobiComKitActivityInterface

use of com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method deleteMessageFromDeviceList.

public void deleteMessageFromDeviceList(String messageKeyString) {
    try {
        int position;
        boolean updateQuickConversation = false;
        int index;
        for (Message message : messageList) {
            boolean value = message.getKeyString() != null ? message.getKeyString().equals(messageKeyString) : false;
            if (value) {
                index = messageList.indexOf(message);
                if (index != -1) {
                    int aboveIndex = index - 1;
                    int belowIndex = index + 1;
                    Message aboveMessage = messageList.get(aboveIndex);
                    if (belowIndex != messageList.size()) {
                        Message belowMessage = messageList.get(belowIndex);
                        if (aboveMessage.isTempDateType() && belowMessage.isTempDateType()) {
                            messageList.remove(aboveMessage);
                        }
                    } else if (belowIndex == messageList.size() && aboveMessage.isTempDateType()) {
                        messageList.remove(aboveMessage);
                    }
                }
            }
            if (message.getKeyString() != null && message.getKeyString().equals(messageKeyString)) {
                position = messageList.indexOf(message);
                if (position == messageList.size() - 1) {
                    updateQuickConversation = true;
                }
                if (message.getScheduledAt() != null && message.getScheduledAt() != 0) {
                    messageDatabaseService.deleteScheduledMessage(messageKeyString);
                }
                messageList.remove(position);
                recyclerDetailConversationAdapter.notifyDataSetChanged();
                if (messageList.isEmpty()) {
                    emptyTextView.setVisibility(VISIBLE);
                    ((MobiComKitActivityInterface) getActivity()).removeConversation(message, channel != null ? String.valueOf(channel.getKey()) : contact.getFormattedContactNumber());
                }
                break;
            }
        }
        int messageListSize = messageList.size();
        if (messageListSize > 0 && updateQuickConversation) {
            ((MobiComKitActivityInterface) getActivity()).updateLatestMessage(messageList.get(messageListSize - 1), channel != null ? String.valueOf(channel.getKey()) : contact.getFormattedContactNumber());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MobiComKitActivityInterface(com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface) Collections.disjoint(java.util.Collections.disjoint)

Aggregations

MobiComKitActivityInterface (com.applozic.mobicomkit.uiwidgets.conversation.activity.MobiComKitActivityInterface)3 Intent (android.content.Intent)2 Message (com.applozic.mobicomkit.api.conversation.Message)2 Uri (android.net.Uri)1 SpannableString (android.text.SpannableString)1 File (java.io.File)1 Collections.disjoint (java.util.Collections.disjoint)1