From: David A. Velasco Date: Tue, 22 Oct 2013 06:26:40 +0000 (+0200) Subject: Merge branch 'develop' into refresh_folder_contents_when_browsed_into X-Git-Tag: oc-android-1.5.5~155^2~6 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/9060663f66a4c518bd428d4d68e035b64e24c26c?hp=--cc Merge branch 'develop' into refresh_folder_contents_when_browsed_into --- 9060663f66a4c518bd428d4d68e035b64e24c26c diff --cc src/com/owncloud/android/ui/activity/FileDisplayActivity.java index cb7ff054,284ece2d..1ab7c5ce --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@@ -251,19 -257,6 +255,23 @@@ OCFileListFragment.ContainerActivity, F } + private void setNavigationListWithFolder(OCFile file) { + mDirectories.clear(); + OCFile fileIt = file; ++ String parentPath; + while(fileIt != null && fileIt.getFileName() != OCFile.ROOT_PATH) { + if (fileIt.isFolder()) { + mDirectories.add(fileIt.getFileName()); + } - fileIt = mStorageManager.getFileById(fileIt.getParentId()); ++ //fileIt = mStorageManager.getFileById(fileIt.getParentId()); ++ // get parent from path ++ parentPath = fileIt.getRemotePath().substring(0, fileIt.getRemotePath().lastIndexOf(fileIt.getFileName())); ++ fileIt = mStorageManager.getFileByPath(parentPath); + } + mDirectories.add(OCFile.PATH_SEPARATOR); + } + + private void createMinFragments() { OCFileListFragment listOfFiles = new OCFileListFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); @@@ -878,9 -858,12 +886,11 @@@ public void onReceive(Context context, Intent intent) { boolean inProgress = intent.getBooleanExtra(FileSyncService.IN_PROGRESS, false); String accountName = intent.getStringExtra(FileSyncService.ACCOUNT_NAME); - - Log_OC.d(TAG, "sync of account " + accountName + " is in_progress: " + inProgress); + RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncService.SYNC_RESULT); - if (getAccount() != null && accountName.equals(getAccount().name)) { + if (getAccount() != null && accountName.equals(getAccount().name) + && mStorageManager != null + ) { String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); @@@ -1434,10 -1363,11 +1444,11 @@@ private OCFile getCurrentDir() { OCFile file = getFile(); if (file != null) { - if (file.isDirectory()) { + if (file.isFolder()) { return file; } else if (mStorageManager != null) { - return mStorageManager.getFileById(file.getParentId()); + String parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName())); + return mStorageManager.getFileByPath(parentPath); } } return null; diff --cc src/com/owncloud/android/ui/preview/PreviewImageActivity.java index 863c926c,50cab7ee..4b3364a6 --- a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java @@@ -104,10 -103,13 +102,13 @@@ public class PreviewImageActivity exten } private void initViewPager() { - OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId()); + // get parent from path + String parentPath = getFile().getRemotePath().substring(0, getFile().getRemotePath().lastIndexOf(getFile().getFileName())); + OCFile parentFolder = mStorageManager.getFileByPath(parentPath); + //OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId()); if (parentFolder == null) { // should not be necessary - parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); + parentFolder = mStorageManager.getFileByPath(OCFile.ROOT_PATH); } mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), mStorageManager); mViewPager = (ViewPager) findViewById(R.id.fragmentPager); @@@ -429,8 -431,12 +430,12 @@@ if (!file.isImage()) { throw new IllegalArgumentException("Non-image file passed as argument"); } - mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver()); - file = mStorageManager.getFileById(file.getFileId()); + mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver()); + + // Update file according to DB file, if it is possible - if (file.getFileId() > DataStorageManager.ROOT_PARENT_ID) ++ if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID) + file = mStorageManager.getFileById(file.getFileId()); + if (file != null) { /// Refresh the activity according to the Account and OCFile set setFile(file); // reset after getting it fresh from mStorageManager