+ protected FileFragment getSecondFragment() {
+ Fragment second = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_SECOND_FRAGMENT);
+ if (second != null) {
+ return (FileFragment)second;
+ }
+ return null;
+ }
+
+ public void cleanSecondFragment() {
+ Fragment second = getSecondFragment();
+ if (second != null) {
+ FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
+ tr.remove(second);
+ tr.commit();
+ }
+ updateFragmentsVisibility(false);
+ updateNavigationElementsInActionBar(null);
+ }
+
+ protected void refeshListOfFilesFragment() {
+ OCFileListFragment fileListFragment = getListOfFilesFragment();
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory();
+ }
+ }
+
+ protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, boolean success) {
+ FileFragment secondFragment = getSecondFragment();
+ boolean waitedPreview = (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
+ if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
+ FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment;
+ 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.getDownloadAddedMessage())) {
+ // grant that the right panel updates the progress bar
+ detailsFragment.listenForTransferProgress();
+ detailsFragment.updateFileDetails(true, false);
+
+ } else if (downloadEvent.equals(FileDownloader.getDownloadFinishMessage())) {
+ // update the right panel
+ boolean detailsFragmentChanged = false;
+ if (waitedPreview) {
+ if (success) {
+ mWaitingToPreview = mStorageManager.getFileById(mWaitingToPreview.getFileId()); // update the file from database, for the local storage path
+ if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
+ startMediaPreview(mWaitingToPreview, 0, true);
+ detailsFragmentChanged = true;
+ } else {
+ openFile(mWaitingToPreview);
+ }
+ }
+ mWaitingToPreview = null;
+ }
+ if (!detailsFragmentChanged) {
+ detailsFragment.updateFileDetails(false, (success));
+ }
+ }
+ }
+ }
+
+