- private void startDownloadForPreview(OCFile file, boolean onOrientationChange) {
- if (mDualPane && !onOrientationChange) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.file_details_container, new FileDetailFragment(file, getAccount()), FileDetailFragment.FTAG);
- transaction.commit();
- mWaitingToPreview = file;
- requestForDownload();
-
+ /**
+ * 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();
+ updateNavigationElementsInActionBar(getFile(), 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);
+ updateNavigationElementsInActionBar(getFile(), file);
+ }
+
+
+ /**
+ * Replaces the second fragment managed by the activity with the received as
+ * a parameter.
+ *
+ * Assumes never will be more than two fragments managed at the same time.
+ *
+ * @param fragment New second Fragment to set.
+ */
+ private void setSecondFragment(Fragment fragment) {
+ FragmentManager fm = getSupportFragmentManager();
+ FragmentTransaction transaction = fm.beginTransaction();
+ if (mDualPane) {
+ transaction.replace(R.id.right_fragment_container, fragment);