Search in sources :

Example 6 with FileUploaderBinder

use of com.owncloud.android.files.services.FileUploader.FileUploaderBinder in project android by nextcloud.

the class FileOperationsHelper method cancelTransference.

/**
 * Cancel the transference in downloads (files/folders) and file uploads
 *
 * @param file OCFile
 */
public void cancelTransference(OCFile file) {
    Account account = mFileActivity.getAccount();
    if (file.isFolder()) {
        OperationsService.OperationsServiceBinder opsBinder = mFileActivity.getOperationsServiceBinder();
        if (opsBinder != null) {
            opsBinder.cancel(account, file);
        }
    }
    // for both files and folders
    FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
    if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) {
        downloaderBinder.cancel(account, file);
    }
    FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
    if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
        uploaderBinder.cancel(account, file);
    }
}
Also used : Account(android.accounts.Account) FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder) OperationsService(com.owncloud.android.services.OperationsService)

Example 7 with FileUploaderBinder

use of com.owncloud.android.files.services.FileUploader.FileUploaderBinder in project android by nextcloud.

the class FileMenuFilter method anyFileSynchronizing.

private boolean anyFileSynchronizing() {
    boolean synchronizing = false;
    if (mComponentsGetter != null && !mFiles.isEmpty() && mAccount != null) {
        OperationsServiceBinder opsBinder = mComponentsGetter.getOperationsServiceBinder();
        FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
        FileDownloaderBinder downloaderBinder = mComponentsGetter.getFileDownloaderBinder();
        synchronizing = (// comparing local and remote
        anyFileSynchronizing(opsBinder) || anyFileDownloading(downloaderBinder) || anyFileUploading(uploaderBinder));
    }
    return synchronizing;
}
Also used : OperationsServiceBinder(com.owncloud.android.services.OperationsService.OperationsServiceBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder) FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder)

Example 8 with FileUploaderBinder

use of com.owncloud.android.files.services.FileUploader.FileUploaderBinder in project android by owncloud.

the class FileDetailFragment method setButtonsForTransferring.

/**
 * Enables or disables buttons for a file being downloaded
 */
private void setButtonsForTransferring() {
    if (!isEmpty()) {
        // show the progress bar for the transfer
        getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
        TextView progressText = getView().findViewById(R.id.fdProgressText);
        progressText.setVisibility(View.VISIBLE);
        FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
        // if (getFile().isDownloading()) {
        if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) {
            progressText.setText(R.string.downloader_download_in_progress_ticker);
        } else {
            if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) {
                progressText.setText(R.string.uploader_upload_in_progress_ticker);
            }
        }
    }
}
Also used : FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder) TextView(android.widget.TextView)

Example 9 with FileUploaderBinder

use of com.owncloud.android.files.services.FileUploader.FileUploaderBinder in project android by owncloud.

the class FileDetailFragment method updateFileDetails.

/**
 * Updates the view with all relevant details about that file.
 *
 * @param forcedTransferring Flag signaling if the file should be considered as downloading or uploading,
 *                           although {@link FileDownloaderBinder#isDownloading(Account, OCFile)}  and
 *                           {@link FileUploaderBinder#isUploading(Account, OCFile)} return false.
 * @param refresh            If 'true', try to refresh the whole file from the database
 */
private void updateFileDetails(boolean forcedTransferring, boolean refresh) {
    if (readyToShow()) {
        FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
        if (refresh && storageManager != null) {
            setFile(storageManager.getFileByPath(getFile().getRemotePath()));
        }
        OCFile file = getFile();
        // set file details
        setFilename(file.getFileName());
        setFiletype(file);
        setFilesize(file.getFileLength());
        setTimeModified(file.getModificationTimestamp());
        // configure UI for depending upon local state of the file
        FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
        if (forcedTransferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) || (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file))) {
            setButtonsForTransferring();
        } else if (file.isDown()) {
            setButtonsForDown();
        } else {
            // TODO load default preview image; when the local file is removed, the preview
            // remains there
            setButtonsForRemote();
        }
    }
    getView().invalidate();
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Aggregations

FileDownloaderBinder (com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder)9 FileUploaderBinder (com.owncloud.android.files.services.FileUploader.FileUploaderBinder)9 OperationsServiceBinder (com.owncloud.android.services.OperationsService.OperationsServiceBinder)3 Account (android.accounts.Account)2 TextView (android.widget.TextView)2 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)2 OCFile (com.owncloud.android.datamodel.OCFile)2 OperationsService (com.owncloud.android.services.OperationsService)2 SwitchCompat (android.support.v7.widget.SwitchCompat)1