}
- fileIt = mStorageManager.getFileById(fileIt.getParentId());
+ 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());
++ // 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();
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);
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;
}
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);
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