- private void requestForDownload(OCFile file) {
- Account account = getAccount();
- if (!mDownloaderBinder.isDownloading(account, file)) {
- Intent i = new Intent(this, FileDownloader.class);
- i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
- i.putExtra(FileDownloader.EXTRA_FILE, file);
- startService(i);
+ /**
+ * Opens the image gallery showing the image {@link OCFile} received as parameter.
+ *
+ * @param file Image {@link OCFile} to show.
+ */
+ public void startImagePreview(OCFile file) {
+ Intent showDetailsIntent = new Intent(this, PreviewImageActivity.class);
+ showDetailsIntent.putExtra(EXTRA_FILE, file);
+ showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
+ startActivity(showDetailsIntent);
+
+ }
+
+ /**
+ * Stars the preview of an already down media {@link OCFile}.
+ *
+ * @param file Media {@link OCFile} to preview.
+ * @param startPlaybackPosition Media position where the playback will be started, in milliseconds.
+ * @param autoplay When 'true', the playback will start without user interactions.
+ */
+ 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.
+ */
+ public void startDownloadForPreview(OCFile file) {
+ Fragment detailFragment = new FileDetailFragment(file, getAccount());
+ setSecondFragment(detailFragment);
+ mWaitingToPreview = file;
+ requestForDownload();
+ updateFragmentsVisibility(true);
+ updateNavigationElementsInActionBar(file);
+ setFile(file);
+ }
+
+
+ public void cancelTransference(OCFile file) {
+ getFileOperationsHelper().cancelTransference(file);
+ if (mWaitingToPreview != null &&
+ mWaitingToPreview.getRemotePath().equals(file.getRemotePath())) {
+ mWaitingToPreview = null;
+ }
+ if (mWaitingToSend != null &&
+ mWaitingToSend.getRemotePath().equals(file.getRemotePath())) {
+ mWaitingToSend = null;