Search in sources :

Example 16 with FileSystemReference

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));
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference) SenderActor(im.actor.core.modules.messaging.actions.SenderActor)

Example 17 with FileSystemReference

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);
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference)

Example 18 with FileSystemReference

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));
        }
    }
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference) Downloaded(im.actor.core.modules.file.entity.Downloaded)

Aggregations

FileSystemReference (im.actor.runtime.files.FileSystemReference)18 FileVMCallback (im.actor.core.viewmodel.FileVMCallback)6 File (java.io.File)6 SenderActor (im.actor.core.modules.messaging.actions.SenderActor)5 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)4 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)3 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)3 FileReference (im.actor.core.entity.FileReference)3 FileCallback (im.actor.core.viewmodel.FileCallback)3 SpannableStringBuilder (android.text.SpannableStringBuilder)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 Downloaded (im.actor.core.modules.file.entity.Downloaded)2 UploadFileCallback (im.actor.core.viewmodel.UploadFileCallback)2 ImageLoadException (im.actor.sdk.util.images.common.ImageLoadException)2 Activity (android.app.Activity)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1