use of im.actor.runtime.files.FileSystemReference in project actor-platform by actorapp.
the class MessagesModule method sendAudio.
public void sendAudio(@NotNull Peer peer, @NotNull String fileName, int duration, @NotNull String descriptor) {
FileSystemReference reference = Storage.fileFromDescriptor(descriptor);
sendMessageActor.send(new SenderActor.SendAudio(peer, descriptor, fileName, reference.getSize(), duration));
}
use of im.actor.runtime.files.FileSystemReference in project actor-platform by actorapp.
the class DownloadTask method completeDownload.
private void completeDownload() {
if (isCompleted) {
return;
}
if (LOG) {
Log.d(TAG, "Closing file...");
}
if (!outputFile.close()) {
reportError();
return;
}
FileSystemReference reference = Storage.commitTempFile(destReference, fileReference.getFileId(), fileReference.getFileName());
if (reference == null) {
reportError();
return;
}
if (LOG) {
Log.d(TAG, "Complete download {" + reference.getDescriptor() + "}");
}
reportComplete(reference);
}
use of im.actor.runtime.files.FileSystemReference in project actor-platform by actorapp.
the class DownloadManager method requestState.
// Tasks
public void requestState(long fileId, final FileCallback callback) {
if (LOG) {
Log.d(TAG, "Requesting state file #" + fileId);
}
Downloaded downloaded1 = downloaded.getValue(fileId);
if (downloaded1 != null) {
FileSystemReference reference = Storage.fileFromDescriptor(downloaded1.getDescriptor());
boolean isExist = reference.isExist();
int fileSize = reference.getSize();
if (isExist && fileSize == downloaded1.getFileSize()) {
if (LOG) {
Log.d(TAG, "- Downloaded");
}
final FileSystemReference fileSystemReference = Storage.fileFromDescriptor(downloaded1.getDescriptor());
im.actor.runtime.Runtime.dispatch(() -> callback.onDownloaded(fileSystemReference));
return;
} else {
if (LOG) {
Log.d(TAG, "- File is corrupted");
if (!isExist) {
Log.d(TAG, "- File not found");
}
if (fileSize != downloaded1.getFileSize()) {
Log.d(TAG, "- Incorrect file size. Expected: " + downloaded1.getFileSize() + ", got: " + fileSize);
}
}
downloaded.removeItem(downloaded1.getFileId());
}
}
final QueueItem queueItem = findItem(fileId);
if (queueItem == null) {
im.actor.runtime.Runtime.dispatch(() -> callback.onNotDownloaded());
} else {
if (queueItem.isStarted) {
final float progress = queueItem.progress;
im.actor.runtime.Runtime.dispatch(() -> callback.onDownloading(progress));
} else if (queueItem.isStopped) {
im.actor.runtime.Runtime.dispatch(() -> callback.onNotDownloaded());
} else {
im.actor.runtime.Runtime.dispatch(() -> callback.onDownloading(0));
}
}
}
Aggregations