X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/16f121a7b23b48078a6d0e7cef8b9b9fb9688d51..5dc43aab3cc1243f9989dd6a0c7dd3350c3f709b:/src/com/owncloud/android/ui/activity/FileDisplayActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 51f6b568..bcd62a38 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -222,7 +222,14 @@ public class FileDisplayActivity extends FileActivity implements /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account OCFile file = getFile(); if (file != null) { - file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account + if (file.isDown() && file.getLastSyncDateForProperties() == 0) { + // upload in progress - right now, files are not inserted in the local cache until the upload is successful + if (mStorageManager.getFileById(file.getParentId()) == null) { + file = null; // not able to know the directory where the file is uploading + } + } else { + file = mStorageManager.getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account + } } if (file == null) { // fall back to root folder @@ -273,7 +280,9 @@ public class FileDisplayActivity extends FileActivity implements private Fragment chooseInitialSecondFragment(OCFile file) { Fragment secondFragment = null; if (file != null && !file.isDirectory()) { - if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) { + if (file.isDown() && PreviewMediaFragment.canBePreviewed(file) + && file.getLastSyncDateForProperties() > 0 // temporal fix + ) { int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0); boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true); secondFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay); @@ -379,19 +388,21 @@ public class FileDisplayActivity extends FileActivity implements 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)) { - startMediaPreview(mWaitingToPreview, 0, true); - - } else { - detailsFragment.updateFileDetails(false, (success)); - openFile(mWaitingToPreview); + // 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; - - } else { + } + if (!detailsFragmentChanged) { detailsFragment.updateFileDetails(false, (success)); } }