+ public void startMediaPreview(OCFile file, int startPlaybackPosition, boolean autoplay) {
+ Fragment mediaFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay);
+ setSecondFragment(mediaFragment);
+ updateFragmentsVisibility(true);
+ updateNavigationElementsInActionBar(file);
+ setFile(file);
+ }
+
+ /**
+ * Requests the download of the received {@link OCFile} , updates the UI
+ * to monitor the download progress and prepares the activity to preview
+ * or open the file when the download finishes.
+ *
+ * @param file {@link OCFile} to download and preview.
+ */
+ @Override
+ public void startDownloadForPreview(OCFile file) {
+ Fragment detailFragment = new FileDetailFragment(file, getAccount());
+ setSecondFragment(detailFragment);
+ mWaitingToPreview = file;
+ requestForDownload();
+ updateFragmentsVisibility(true);
+ updateNavigationElementsInActionBar(file);
+ setFile(file);
+ }
+
+
+ /**
+ * Shows the information of the {@link OCFile} received as a
+ * parameter in the second fragment.
+ *
+ * @param file {@link OCFile} whose details will be shown
+ */
+ @Override
+ public void showDetails(OCFile file) {
+ Fragment detailFragment = new FileDetailFragment(file, getAccount());
+ setSecondFragment(detailFragment);
+ updateFragmentsVisibility(true);
+ updateNavigationElementsInActionBar(file);
+ setFile(file);
+ }
+
+
+ /**
+ * TODO
+ */
+ private void updateNavigationElementsInActionBar(OCFile chosenFile) {
+ ActionBar actionBar = getSupportActionBar();
+ if (chosenFile == null || mDualPane) {
+ // only list of files - set for browsing through folders
+ OCFile currentDir = getCurrentDir();
+ actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0 && !mSyncInProgress);
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+ actionBar.setListNavigationCallbacks(mDirectories, this); // assuming mDirectories is updated
+
+ } else {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowTitleEnabled(true);
+ actionBar.setTitle(chosenFile.getFileName());
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ }
+ }
+
+
+ private void updateDisplayHomeAtSync(){
+ ActionBar actionBar = getSupportActionBar();
+ OCFile currentDir = getCurrentDir();
+ if (currentDir.getParentId() != DataStorageManager.ROOT_PARENT_ID) {
+ actionBar.setHomeButtonEnabled(!mSyncInProgress);
+ actionBar.setDisplayHomeAsUpEnabled(!mSyncInProgress);
+ }
+ else {
+ actionBar.setHomeButtonEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(false);
+ }