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