Search in sources :

Example 1 with MediaUploadProgressHandler

use of com.applozic.mobicomkit.listners.MediaUploadProgressHandler in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationService method sendMessageWithHandler.

public void sendMessageWithHandler(Message message, final MediaUploadProgressHandler progressHandler) {
    if (message == null) {
        return;
    }
    if (!message.hasAttachment()) {
        ApplozicException exception = new ApplozicException("Message does not have any attachment.");
        if (progressHandler != null) {
            progressHandler.onUploadStarted(exception, null);
            progressHandler.onProgressUpdate(0, exception, null);
            progressHandler.onCancelled(exception, null);
        }
    }
    Handler handler = new Handler(new Handler.Callback() {

        @Override
        public boolean handleMessage(android.os.Message message) {
            handleState(message, progressHandler);
            return true;
        }
    });
    MessageWorker.enqueueWork(context, message, null, handler);
}
Also used : Handler(android.os.Handler) MediaUploadProgressHandler(com.applozic.mobicomkit.listners.MediaUploadProgressHandler) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException)

Example 2 with MediaUploadProgressHandler

use of com.applozic.mobicomkit.listners.MediaUploadProgressHandler in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationService method sendMessage.

public void sendMessage(Message message, final MediaUploadProgressHandler progressHandler, Class messageIntentClass) {
    Intent intent = new Intent(context, messageIntentClass);
    intent.putExtra(MobiComKitConstants.MESSAGE_JSON_INTENT, GsonUtils.getJsonFromObject(message, Message.class));
    Handler handler = new Handler(new Handler.Callback() {

        @Override
        public boolean handleMessage(android.os.Message message) {
            handleState(message, progressHandler);
            return true;
        }
    });
    MessageIntentService.enqueueWork(context, intent, handler);
}
Also used : Handler(android.os.Handler) MediaUploadProgressHandler(com.applozic.mobicomkit.listners.MediaUploadProgressHandler) Intent(android.content.Intent)

Example 3 with MediaUploadProgressHandler

use of com.applozic.mobicomkit.listners.MediaUploadProgressHandler in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method sendOpenGroupMessage.

public void sendOpenGroupMessage(String messageText) {
    attachReplyCancelLayout.setVisibility(View.GONE);
    replayRelativeLayout.setVisibility(View.GONE);
    attachmentLayout.setVisibility(View.GONE);
    Map<String, String> messageMetaData = new HashMap<>();
    if (this.messageMetaData != null && !this.messageMetaData.isEmpty()) {
        messageMetaData.putAll(this.messageMetaData);
    }
    MessageBuilder messageBuilder = new MessageBuilder(getActivity()).setMessage(messageText).setMetadata(messageMetaData).setGroupId(channel.getKey());
    if (!TextUtils.isEmpty(filePath)) {
        messageBuilder.setContentType(Message.ContentType.ATTACHMENT.getValue());
        messageBuilder.setFilePath(filePath);
        filePath = null;
    }
    messageBuilder.send(new MediaUploadProgressHandler() {

        @Override
        public void onUploadStarted(ApplozicException e, String oldMessageKey) {
        }

        @Override
        public void onProgressUpdate(int percentage, ApplozicException e, String oldMessageKey) {
        }

        @Override
        public void onCancelled(ApplozicException e, String oldMessageKey) {
        }

        @Override
        public void onCompleted(ApplozicException e, String oldMessageKey) {
        }

        @Override
        public void onSent(Message message, String oldMessageKey) {
            Message messageToBeReplied = new Message();
            messageToBeReplied.setKeyString(oldMessageKey);
            int indexOfObject = messageList.indexOf(messageToBeReplied);
            if (indexOfObject != -1) {
                messageList.set(indexOfObject, message);
                recyclerDetailConversationAdapter.notifyItemChanged(indexOfObject);
            }
        }
    });
    this.messageMetaData = null;
}
Also used : MessageBuilder(com.applozic.mobicomkit.api.conversation.MessageBuilder) AlRichMessage(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage) Message(com.applozic.mobicomkit.api.conversation.Message) HashMap(java.util.HashMap) MediaUploadProgressHandler(com.applozic.mobicomkit.listners.MediaUploadProgressHandler) Collections.disjoint(java.util.Collections.disjoint) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException)

Aggregations

MediaUploadProgressHandler (com.applozic.mobicomkit.listners.MediaUploadProgressHandler)3 Handler (android.os.Handler)2 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)2 Intent (android.content.Intent)1 Message (com.applozic.mobicomkit.api.conversation.Message)1 MessageBuilder (com.applozic.mobicomkit.api.conversation.MessageBuilder)1 AlRichMessage (com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage)1 Collections.disjoint (java.util.Collections.disjoint)1 HashMap (java.util.HashMap)1