X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/0c4adf5134ef12dff149c6e7bf03be4c7e15b8db..db1ea015619a1cc5a3886ea90dc20f910fc6dd9e:/src/com/owncloud/android/ui/preview/PreviewImageActivity.java diff --git a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java index 9ce05885..50cab7ee 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -16,8 +16,6 @@ */ package com.owncloud.android.ui.preview; -import android.app.Dialog; -import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -105,7 +103,10 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C } 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); @@ -153,7 +154,7 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C Log_OC.d(TAG, "Simulating reselection of current page after connection of download binder"); onPageSelected(mViewPager.getCurrentItem()); } - + } else if (component.equals(new ComponentName(PreviewImageActivity.this, FileUploader.class))) { Log_OC.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploaderBinder) service; @@ -241,27 +242,6 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C finish(); } - -// @Override -// protected Dialog onCreateDialog(int id) { -// Dialog dialog = null; -// switch (id) { -// case DIALOG_SHORT_WAIT: { -// ProgressDialog working_dialog = new ProgressDialog(this); -// working_dialog.setMessage(getResources().getString( -// R.string.wait_a_moment)); -// working_dialog.setIndeterminate(true); -// working_dialog.setCancelable(false); -// dialog = working_dialog; -// break; -// } -// default: -// dialog = null; -// } -// return dialog; -// } - - /** * Show loading dialog */ @@ -451,8 +431,12 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C 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) + 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