Search in sources :

Example 1 with FileEventCallback

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

the class DownloadManager method onDownloaded.

public void onDownloaded(final long fileId, final FileSystemReference reference) {
    if (LOG) {
        Log.d(TAG, "onDownloaded file #" + fileId);
    }
    QueueItem queueItem = findItem(fileId);
    if (queueItem == null) {
        return;
    }
    if (!queueItem.isStarted) {
        return;
    }
    downloaded.addOrUpdateItem(new Downloaded(queueItem.fileReference.getFileId(), queueItem.fileReference.getFileSize(), reference.getDescriptor()));
    queue.remove(queueItem);
    queueItem.taskRef.send(PoisonPill.INSTANCE);
    for (final WeakCallbackHolder weakReference : globalCallbacks) {
        final FileEventCallback callback = weakReference.getCallbackWeakReference().get();
        if (callback != null) {
            im.actor.runtime.Runtime.dispatch(() -> callback.onDownloaded(fileId));
        }
    }
    for (final FileCallback fileCallback : getSubscribers(fileId)) {
        im.actor.runtime.Runtime.dispatch(() -> fileCallback.onDownloaded(reference));
    }
    checkQueue();
}
Also used : FileCallback(im.actor.core.viewmodel.FileCallback) Downloaded(im.actor.core.modules.file.entity.Downloaded) FileEventCallback(im.actor.core.viewmodel.FileEventCallback)

Aggregations

Downloaded (im.actor.core.modules.file.entity.Downloaded)1 FileCallback (im.actor.core.viewmodel.FileCallback)1 FileEventCallback (im.actor.core.viewmodel.FileEventCallback)1