Search in sources :

Example 1 with PreviewMediaFragment

use of com.owncloud.android.ui.preview.PreviewMediaFragment in project android by nextcloud.

the class FileDisplayActivity method refreshShowDetails.

private void refreshShowDetails() {
    Fragment details = getLeftFragment();
    if (details instanceof FileFragment) {
        OCFile file = ((FileFragment) details).getFile();
        if (file != null) {
            file = getStorageManager().getFileByPath(file.getRemotePath());
            if (details instanceof PreviewMediaFragment) {
                // Refresh  OCFile of the fragment
                ((PreviewMediaFragment) details).updateFile(file);
            } else if (details instanceof PreviewTextFragment) {
                // Refresh  OCFile of the fragment
                ((PreviewTextFileFragment) details).updateFile(file);
            } else {
                showDetails(file);
            }
        }
        supportInvalidateOptionsMenu();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) 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 2 with PreviewMediaFragment

use of com.owncloud.android.ui.preview.PreviewMediaFragment in project android by nextcloud.

the class FileDisplayActivity method onRenameFileOperationFinish.

/**
 * Updates the view associated to the activity after the finish of an operation trying to rename a file.
 *
 * @param operation Renaming operation performed.
 * @param result    Result of the renaming.
 */
private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) {
    Optional<User> optionalUser = getUser();
    OCFile renamedFile = operation.getFile();
    if (result.isSuccess() && optionalUser.isPresent()) {
        final User currentUser = optionalUser.get();
        Fragment leftFragment = getLeftFragment();
        if (leftFragment instanceof FileFragment) {
            final FileFragment fileFragment = (FileFragment) leftFragment;
            if (fileFragment instanceof FileDetailFragment && renamedFile.equals(fileFragment.getFile())) {
                ((FileDetailFragment) fileFragment).updateFileDetails(renamedFile, currentUser);
                showDetails(renamedFile);
            } else if (fileFragment instanceof PreviewMediaFragment && renamedFile.equals(fileFragment.getFile())) {
                ((PreviewMediaFragment) fileFragment).updateFile(renamedFile);
                if (PreviewMediaFragment.canBePreviewed(renamedFile)) {
                    long position = ((PreviewMediaFragment) fileFragment).getPosition();
                    startMediaPreview(renamedFile, position, true, true, true);
                } else {
                    getFileOperationsHelper().openFile(renamedFile);
                }
            } else if (fileFragment instanceof PreviewTextFragment && renamedFile.equals(fileFragment.getFile())) {
                ((PreviewTextFileFragment) fileFragment).updateFile(renamedFile);
                if (PreviewTextFileFragment.canBePreviewed(renamedFile)) {
                    startTextPreview(renamedFile, true);
                } else {
                    getFileOperationsHelper().openFile(renamedFile);
                }
            }
        }
        OCFile file = getStorageManager().getFileById(renamedFile.getParentId());
        if (file != null && file.equals(getCurrentDir())) {
            updateListOfFilesFragment(false);
        }
    } else {
        DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
        if (result.isSslRecoverableException()) {
            mLastSslUntrustedServerResult = result;
            showUntrustedCertDialog(mLastSslUntrustedServerResult);
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) User(com.nextcloud.client.account.User) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) 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 3 with PreviewMediaFragment

use of com.owncloud.android.ui.preview.PreviewMediaFragment in project android by nextcloud.

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) {
    if (!operation.isInBackground()) {
        DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
    }
    if (result.isSuccess()) {
        OCFile removedFile = operation.getFile();
        tryStopPlaying(removedFile);
        Fragment leftFragment = getLeftFragment();
        // check if file is still available, if so do nothing
        boolean fileAvailable = getStorageManager().fileExists(removedFile.getFileId());
        if (leftFragment instanceof FileFragment && !fileAvailable && removedFile.equals(((FileFragment) leftFragment).getFile())) {
            if (leftFragment instanceof PreviewMediaFragment) {
                ((PreviewMediaFragment) leftFragment).stopPreview(true);
            }
            setFile(getStorageManager().getFileById(removedFile.getParentId()));
            cleanSecondFragment();
        }
        OCFile parentFile = getStorageManager().getFileById(removedFile.getParentId());
        if (parentFile != null && parentFile.equals(getCurrentDir())) {
            updateListOfFilesFragment(false);
        } else if (getLeftFragment() instanceof GalleryFragment) {
            ((GalleryFragment) getLeftFragment()).onRefresh();
        }
        supportInvalidateOptionsMenu();
    } else {
        if (result.isSslRecoverableException()) {
            mLastSslUntrustedServerResult = result;
            showUntrustedCertDialog(mLastSslUntrustedServerResult);
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) 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 4 with PreviewMediaFragment

use of com.owncloud.android.ui.preview.PreviewMediaFragment in project android by nextcloud.

the class FileDisplayActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean retval = true;
    int itemId = item.getItemId();
    if (itemId == android.R.id.home) {
        FileFragment second = getSecondFragment();
        OCFile currentDir = getCurrentDir();
        if (isDrawerOpen()) {
            closeDrawer();
        } else if (currentDir != null && currentDir.getParentId() != 0 || second != null && second.getFile() != null || isSearchOpen()) {
            onBackPressed();
        } else if (getLeftFragment() instanceof FileDetailFragment || getLeftFragment() instanceof PreviewMediaFragment || getLeftFragment() instanceof UnifiedSearchFragment || getLeftFragment() instanceof PreviewPdfFragment) {
            onBackPressed();
        } else {
            openDrawer();
        }
    } else if (itemId == R.id.action_select_all) {
        OCFileListFragment fragment = getListOfFilesFragment();
        if (fragment != null) {
            fragment.selectAllFiles(true);
        }
    } else {
        retval = super.onOptionsItemSelected(item);
    }
    return retval;
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) SuppressLint(android.annotation.SuppressLint)

Aggregations

OCFile (com.owncloud.android.datamodel.OCFile)4 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)4 FileFragment (com.owncloud.android.ui.fragment.FileFragment)4 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)4 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)4 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)4 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)4 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)4 Fragment (androidx.fragment.app.Fragment)3 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)3 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)3 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)3 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)3 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)3 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)3 SuppressLint (android.annotation.SuppressLint)1 User (com.nextcloud.client.account.User)1