Search in sources :

Example 1 with FileFragment

use of com.owncloud.android.ui.fragment.FileFragment in project android by owncloud.

the class FileDisplayActivity method cancelTransference.

/**
     * Request stopping the upload/download operation in progress over the given {@link OCFile} file.
     *
     * @param file {@link OCFile} file which operation are wanted to be cancel
     */
public void cancelTransference(OCFile file) {
    getFileOperationsHelper().cancelTransference(file);
    if (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(file.getRemotePath())) {
        mWaitingToPreview = null;
    }
    if (mWaitingToSend != null && mWaitingToSend.getRemotePath().equals(file.getRemotePath())) {
        mWaitingToSend = null;
    }
    refreshListOfFilesFragment(false);
    FileFragment secondFragment = getSecondFragment();
    if (secondFragment != null && file.equals(secondFragment.getFile())) {
        if (!file.fileExists()) {
            cleanSecondFragment();
        } else {
            secondFragment.onSyncEvent(FileDownloader.getDownloadFinishMessage(), false, null);
        }
    }
    invalidateOptionsMenu();
}
Also used : FileFragment(com.owncloud.android.ui.fragment.FileFragment)

Example 2 with FileFragment

use of com.owncloud.android.ui.fragment.FileFragment in project android by owncloud.

the class FileDisplayActivity method onSynchronizeFileOperationFinish.

private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
    if (result.isSuccess()) {
        if (operation.transferWasRequested()) {
            // this block is probably useless duy
            OCFile syncedFile = operation.getLocalFile();
            refreshListOfFilesFragment(false);
            FileFragment secondFragment = getSecondFragment();
            if (secondFragment != null && syncedFile.equals(secondFragment.getFile())) {
                secondFragment.onSyncEvent(FileDownloader.getDownloadAddedMessage(), false, null);
                invalidateOptionsMenu();
            }
        } else if (getSecondFragment() == null) {
            showSnackMessage(ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
        }
    }
    /// no matter if sync was right or not - if there was no transfer and the file is down, OPEN it
    boolean waitedForPreview = (mWaitingToPreview != null && mWaitingToPreview.equals(operation.getLocalFile()) && mWaitingToPreview.isDown());
    if (!operation.transferWasRequested() & waitedForPreview) {
        getFileOperationsHelper().openFile(mWaitingToPreview);
        mWaitingToPreview = null;
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment)

Example 3 with FileFragment

use of com.owncloud.android.ui.fragment.FileFragment in project android by owncloud.

the class FileDisplayActivity method onRemoveFileOperationFinish.

/**
     * Updates the view associated to the activity after the finish of an operation trying to
     * remove a file.
     *
     * @param operation Removal operation performed.
     * @param result    Result of the removal.
     */
private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
    showSnackMessage(ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
    if (result.isSuccess()) {
        OCFile removedFile = operation.getFile();
        FileFragment second = getSecondFragment();
        if (second != null && removedFile.equals(second.getFile())) {
            if (second instanceof PreviewAudioFragment) {
                ((PreviewAudioFragment) second).stopPreview();
            } else if (second instanceof PreviewVideoFragment) {
                ((PreviewVideoFragment) second).stopPreview();
            }
            setFile(getStorageManager().getFileById(removedFile.getParentId()));
            cleanSecondFragment();
        }
        if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) {
            refreshListOfFilesFragment(true);
        }
        invalidateOptionsMenu();
    } else {
        if (result.isSslRecoverableException()) {
            mLastSslUntrustedServerResult = result;
            showUntrustedCertDialog(mLastSslUntrustedServerResult);
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) PreviewAudioFragment(com.owncloud.android.ui.preview.PreviewAudioFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewVideoFragment(com.owncloud.android.ui.preview.PreviewVideoFragment)

Example 4 with FileFragment

use of com.owncloud.android.ui.fragment.FileFragment in project android by nextcloud.

the class FileDisplayActivity method onResume.

@Override
protected void onResume() {
    Log_OC.v(TAG, "onResume() start");
    super.onResume();
    // Instead of onPostCreate, starting the loading in onResume for children fragments
    Fragment leftFragment = getLeftFragment();
    // Listen for sync messages
    if (!(leftFragment instanceof OCFileListFragment) || !((OCFileListFragment) leftFragment).isSearchFragment()) {
        IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
        syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
        syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
        syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
        syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
        mSyncBroadcastReceiver = new SyncBroadcastReceiver();
        localBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
    }
    if (!(leftFragment instanceof OCFileListFragment)) {
        if (leftFragment instanceof FileFragment) {
            super.updateActionBarTitleAndHomeButton(((FileFragment) leftFragment).getFile());
        }
        return;
    }
    OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
    ocFileListFragment.setLoading(mSyncInProgress);
    syncAndUpdateFolder(false);
    OCFile startFile = null;
    if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
        startFile = getIntent().getParcelableExtra(EXTRA_FILE);
        setFile(startFile);
    }
    // refresh list of files
    if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
        searchView.setQuery(searchQuery, false);
    } else if (!ocFileListFragment.isSearchFragment() && startFile == null) {
        updateListOfFilesFragment(false);
        ocFileListFragment.registerFabListener();
    } else {
        ocFileListFragment.listDirectory(startFile, false, false);
        updateActionBarTitleAndHomeButton(startFile);
    }
    // Listen for upload messages
    IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
    mUploadFinishReceiver = new UploadFinishReceiver();
    localBroadcastManager.registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
    // Listen for download messages
    IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
    downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
    mDownloadFinishReceiver = new DownloadFinishReceiver();
    localBroadcastManager.registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
    // setup drawer
    menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
    if (menuItemId == -1) {
        if (MainApp.isOnlyOnDevice()) {
            setDrawerMenuItemChecked(R.id.nav_on_device);
            setupToolbar();
        } else {
            setDrawerMenuItemChecked(R.id.nav_all_files);
            setupHomeSearchToolbarWithSortAndListButtons();
        }
    } else {
        if (menuItemId == R.id.nav_all_files) {
            setupHomeSearchToolbarWithSortAndListButtons();
        } else {
            setupToolbar();
        }
        setDrawerMenuItemChecked(menuItemId);
    }
    if (ocFileListFragment instanceof GalleryFragment) {
        updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
    }
    Log_OC.v(TAG, "onResume() end");
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) IntentFilter(android.content.IntentFilter) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) Fragment(androidx.fragment.app.Fragment) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SortingOrderDialogFragment(com.owncloud.android.ui.dialog.SortingOrderDialogFragment) PreviewImageFragment(com.owncloud.android.ui.preview.PreviewImageFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)

Example 5 with FileFragment

use of com.owncloud.android.ui.fragment.FileFragment in project android by nextcloud.

the class PreviewImagePagerAdapter method updateFile.

public void updateFile(int position, OCFile file) {
    FileFragment fragmentToUpdate = mCachedFragments.get(position);
    if (fragmentToUpdate != null) {
        mObsoleteFragments.add(fragmentToUpdate);
    }
    mObsoletePositions.add(position);
    mImageFiles.set(position, file);
}
Also used : FileFragment(com.owncloud.android.ui.fragment.FileFragment)

Aggregations

FileFragment (com.owncloud.android.ui.fragment.FileFragment)16 OCFile (com.owncloud.android.datamodel.OCFile)9 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)6 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)5 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)5 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)5 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)5 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)5 Fragment (androidx.fragment.app.Fragment)4 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)4 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)4 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)4 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)4 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)4 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)4 SuppressLint (android.annotation.SuppressLint)1 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 User (com.nextcloud.client.account.User)1 PreviewAudioFragment (com.owncloud.android.ui.preview.PreviewAudioFragment)1