Search in sources :

Example 6 with UploadFileCallback

use of im.actor.core.viewmodel.UploadFileCallback in project actor-platform by actorapp.

the class UploadManager method onUploadTaskComplete.

public void onUploadTaskComplete(long rid, FileReference fileReference, FileSystemReference reference) {
    if (LOG) {
        Log.d(TAG, "Upload #" + rid + " complete");
    }
    QueueItem queueItem = findItem(rid);
    if (queueItem == null) {
        return;
    }
    if (!queueItem.isStarted) {
        return;
    }
    queue.remove(queueItem);
    queueItem.taskRef.send(PoisonPill.INSTANCE);
    // Saving reference to uploaded file
    context().getFilesModule().getDownloadedEngine().addOrUpdateItem(new Downloaded(fileReference.getFileId(), fileReference.getFileSize(), reference.getDescriptor()));
    ArrayList<UploadFileCallback> clist = callbacks.get(rid);
    if (clist != null) {
        for (final UploadFileCallback callback : clist) {
            im.actor.runtime.Runtime.dispatch(() -> callback.onUploaded());
        }
    }
    queueItem.requestActor.send(new UploadCompleted(rid, fileReference));
    checkQueue();
}
Also used : UploadFileCallback(im.actor.core.viewmodel.UploadFileCallback) Downloaded(im.actor.core.modules.file.entity.Downloaded)

Example 7 with UploadFileCallback

use of im.actor.core.viewmodel.UploadFileCallback in project actor-platform by actorapp.

the class UploadManager method onUploadTaskProgress.

public void onUploadTaskProgress(long rid, final float progress) {
    if (LOG) {
        Log.d(TAG, "Upload #" + rid + " progress " + progress);
    }
    QueueItem queueItem = findItem(rid);
    if (queueItem == null) {
        return;
    }
    if (!queueItem.isStarted) {
        return;
    }
    queueItem.progress = progress;
    ArrayList<UploadFileCallback> clist = callbacks.get(rid);
    if (clist != null) {
        for (final UploadFileCallback callback : clist) {
            im.actor.runtime.Runtime.dispatch(() -> callback.onUploading(progress));
        }
    }
}
Also used : UploadFileCallback(im.actor.core.viewmodel.UploadFileCallback)

Example 8 with UploadFileCallback

use of im.actor.core.viewmodel.UploadFileCallback in project actor-platform by actorapp.

the class UploadManager method onUploadTaskError.

// Queue processing
public void onUploadTaskError(long rid) {
    if (LOG) {
        Log.d(TAG, "Upload #" + rid + " error");
    }
    QueueItem queueItem = findItem(rid);
    if (queueItem == null) {
        if (LOG) {
            Log.d(TAG, "- Nothing found");
        }
        return;
    }
    if (!queueItem.isStarted) {
        return;
    }
    queueItem.taskRef.send(PoisonPill.INSTANCE);
    queueItem.isStopped = true;
    queueItem.isStarted = false;
    ArrayList<UploadFileCallback> clist = callbacks.get(rid);
    if (clist != null) {
        for (final UploadFileCallback callback : clist) {
            im.actor.runtime.Runtime.dispatch(() -> callback.onNotUploading());
        }
    }
    queueItem.requestActor.send(new UploadError(rid));
    checkQueue();
}
Also used : UploadFileCallback(im.actor.core.viewmodel.UploadFileCallback)

Aggregations

UploadFileCallback (im.actor.core.viewmodel.UploadFileCallback)8 FileReference (im.actor.core.entity.FileReference)2 FileLocalSource (im.actor.core.entity.content.FileLocalSource)2 FileRemoteSource (im.actor.core.entity.content.FileRemoteSource)2 PhotoContent (im.actor.core.entity.content.PhotoContent)2 FileCallback (im.actor.core.viewmodel.FileCallback)2 FileSystemReference (im.actor.runtime.files.FileSystemReference)2 Activity (android.app.Activity)1 AnimationContent (im.actor.core.entity.content.AnimationContent)1 DocumentContent (im.actor.core.entity.content.DocumentContent)1 VideoContent (im.actor.core.entity.content.VideoContent)1 Downloaded (im.actor.core.modules.file.entity.Downloaded)1 ImageLoadException (im.actor.sdk.util.images.common.ImageLoadException)1