Search in sources :

Example 1 with AttachmentTask

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

the class ApplozicConversation method downloadMessage.

public static void downloadMessage(Context context, Message message, MediaDownloadProgressHandler handler) {
    ApplozicException e;
    if (message == null || handler == null) {
        return;
    }
    if (!message.hasAttachment()) {
        e = new ApplozicException("Message does not have Attachment");
        handler.onProgressUpdate(0, e);
        handler.onCompleted(null, e);
    } else if (message.isAttachmentDownloaded()) {
        e = new ApplozicException("Attachment for the message already downloaded");
        handler.onProgressUpdate(0, e);
        handler.onCompleted(null, e);
    } else {
        AttachmentTask mDownloadThread = null;
        if (!AttachmentManager.isAttachmentInProgress(message.getKeyString())) {
            // Starts downloading this View, using the current cache setting
            mDownloadThread = AttachmentManager.startDownload(null, true, message, handler, context);
        // After successfully downloading the image, this marks that it's available.
        }
        if (mDownloadThread == null) {
            mDownloadThread = AttachmentManager.getBGThreadForAttachment(message.getKeyString());
            if (mDownloadThread != null) {
                mDownloadThread.setAttachment(message, handler, context);
            }
        }
    }
}
Also used : AttachmentTask(com.applozic.mobicomkit.api.attachment.AttachmentTask) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException)

Aggregations

AttachmentTask (com.applozic.mobicomkit.api.attachment.AttachmentTask)1 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1