Search in sources :

Example 1 with FileUploaderBinder

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

the class FileDetailFragment method updateFileDetails.

/**
 * Updates the view with all relevant details about that file.
 *
 * TODO Remove parameter when the transferring state of files is kept in database.
 *
 * @param transferring Flag signaling if the file should be considered as downloading or uploading,
 *                     although {@link FileDownloaderBinder#isDownloading(User, OCFile)}  and
 *                     {@link FileUploaderBinder#isUploading(User, OCFile)} return false.
 * @param refresh      If 'true', try to refresh the whole file from the database
 */
public void updateFileDetails(boolean transferring, boolean refresh) {
    if (readyToShow()) {
        FileDataStorageManager storageManager = containerActivity.getStorageManager();
        if (storageManager == null) {
            return;
        }
        if (refresh) {
            setFile(storageManager.getFileByPath(getFile().getRemotePath()));
        }
        OCFile file = getFile();
        // set file details
        if (MimeTypeUtil.isImage(file)) {
            binding.filename.setText(file.getFileName());
        } else {
            binding.filename.setVisibility(View.GONE);
        }
        binding.size.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
        boolean showDetailedTimestamp = preferences.isShowDetailedTimestampEnabled();
        setFileModificationTimestamp(file, showDetailedTimestamp);
        setFilePreview(file);
        setFavoriteIconStatus(file.isFavorite());
        // configure UI for depending upon local state of the file
        FileDownloaderBinder downloaderBinder = containerActivity.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = containerActivity.getFileUploaderBinder();
        if (transferring || (downloaderBinder != null && downloaderBinder.isDownloading(user, file)) || (uploaderBinder != null && uploaderBinder.isUploading(user, file))) {
            setButtonsForTransferring();
        } else if (file.isDown()) {
            setButtonsForDown();
        } else {
            // TODO load default preview image; when the local file is removed, the preview
            // remains there
            setButtonsForRemote();
        }
    }
    setupViewPager();
    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)

Example 2 with FileUploaderBinder

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

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
        binding.progressBlock.setVisibility(View.VISIBLE);
        binding.progressText.setVisibility(View.VISIBLE);
        FileDownloaderBinder downloaderBinder = containerActivity.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = containerActivity.getFileUploaderBinder();
        // if (getFile().isDownloading()) {
        if (downloaderBinder != null && downloaderBinder.isDownloading(user, getFile())) {
            binding.progressText.setText(R.string.downloader_download_in_progress_ticker);
        } else {
            if (uploaderBinder != null && uploaderBinder.isUploading(user, getFile())) {
                binding.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)

Example 3 with FileUploaderBinder

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

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 4 with FileUploaderBinder

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

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 5 with FileUploaderBinder

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

the class FileListListAdapter method setIconPinAccordingToFilesLocalState.

private void setIconPinAccordingToFilesLocalState(ImageView localStateView, OCFile file) {
    // local state
    localStateView.bringToFront();
    final FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
    final FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
    final OperationsServiceBinder opsBinder = mTransferServiceGetter.getOperationsServiceBinder();
    // default first
    localStateView.setVisibility(View.INVISIBLE);
    if (opsBinder != null && opsBinder.isSynchronizing(mAccount, file)) {
        // syncing
        localStateView.setImageResource(R.drawable.sync_pin);
        localStateView.setVisibility(View.VISIBLE);
    } else if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
        // downloading
        localStateView.setImageResource(R.drawable.sync_pin);
        localStateView.setVisibility(View.VISIBLE);
    } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
        // uploading
        localStateView.setImageResource(R.drawable.sync_pin);
        localStateView.setVisibility(View.VISIBLE);
    } else if (file.getEtagInConflict() != null) {
        // conflict
        localStateView.setImageResource(R.drawable.error_pin);
        localStateView.setVisibility(View.VISIBLE);
    } else {
        if (file.isDown()) {
            localStateView.setVisibility(View.VISIBLE);
            localStateView.setImageResource(R.drawable.downloaded_pin);
        }
        if (file.isAvailableOffline()) {
            localStateView.setVisibility(View.VISIBLE);
            localStateView.setImageResource(R.drawable.offline_available_pin);
        }
    }
}
Also used : OperationsServiceBinder(com.owncloud.android.services.OperationsService.OperationsServiceBinder) FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder)

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 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)2 OCFile (com.owncloud.android.datamodel.OCFile)2 OperationsService (com.owncloud.android.services.OperationsService)2 Account (android.accounts.Account)1 TextView (android.widget.TextView)1 User (com.nextcloud.client.account.User)1