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();
}
Aggregations