- protected void updateLeftPanel() {
- OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
- if (fileListFragment != null) {
- fileListFragment.listDirectory();
- }
- }
-
- protected void updateRightPanel(String downloadEvent, String downloadedRemotePath, boolean success) {
- Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- boolean waitedPreview = (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
- if (fragment != null && fragment instanceof FileDetailFragment) {
- FileDetailFragment detailsFragment = (FileDetailFragment) fragment;
- OCFile fileInFragment = detailsFragment.getFile();
- if (fileInFragment != null && !downloadedRemotePath.equals(fileInFragment.getRemotePath())) {
- // the user browsed to other file ; forget the automatic preview
- mWaitingToPreview = null;
-
- } else if (downloadEvent.equals(FileDownloader.DOWNLOAD_ADDED_MESSAGE)) {
- // grant that the right panel updates the progress bar
- detailsFragment.listenForTransferProgress();
- detailsFragment.updateFileDetails(true, false);
-
- } else if (downloadEvent.equals(FileDownloader.DOWNLOAD_FINISH_MESSAGE)) {
- // update the right panel
- if (success && waitedPreview) {
- mWaitingToPreview = mStorageManager.getFileById(mWaitingToPreview.getFileId()); // update the file from database, for the local storage path
- if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mWaitingToPreview, getAccount(), 0, true), FileDetailFragment.FTAG);
- transaction.commit();
- } else {
- // file cannot be previewed
- detailsFragment.updateFileDetails(false, (success));
-
- }
- mWaitingToPreview = null;
-
- } else {
- detailsFragment.updateFileDetails(false, (success));
- }
- }
- }
- }
-
-