From 08bf32a39f716d37bbea2a476a7d5e37b216e56e Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 23 Sep 2024 12:13:03 +0200 Subject: [PATCH] Revert changes, only bug-fix Signed-off-by: alperozturk --- .../ui/fragment/OCFileListFragment.java | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index cd3432ff26..2321545566 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -924,45 +924,39 @@ public class OCFileListFragment extends ExtendedListFragment implements * return Count of folder levels browsed up. */ public int onBrowseUp() { - if (mFile == null) { - return 0; - } - - OCFile parentDir = null; + OCFile parentDir; int moveCount = 0; - FileDataStorageManager storageManager = mContainerActivity.getStorageManager(); - String parentPath = null; - if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) { - parentPath = new File(mFile.getRemotePath()).getParent(); - if (parentPath != null) { + if (mFile != null) { + FileDataStorageManager storageManager = mContainerActivity.getStorageManager(); + + String parentPath = null; + if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) { + parentPath = new File(mFile.getRemotePath()).getParent(); parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR; parentDir = storageManager.getFileByPath(parentPath); moveCount++; + } else { + parentDir = storageManager.getFileByPath(ROOT_PATH); } - } else { - parentDir = storageManager.getFileByPath(ROOT_PATH); - } - - while (parentDir == null) { - parentPath = new File(parentPath).getParent(); - if (parentPath != null) { + while (parentDir == null) { + parentPath = new File(parentPath).getParent(); parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR; parentDir = storageManager.getFileByPath(parentPath); moveCount++; - } - } + } // exit is granted because storageManager.getFileByPath("/") never returns null + mFile = parentDir; - mFile = parentDir; + listDirectory(mFile, MainApp.isOnlyOnDevice(), false); - listDirectory(mFile, MainApp.isOnlyOnDevice(), false); + onRefresh(false); - onRefresh(false); + // restore index and top position + restoreIndexAndTopPosition(); - // restore index and top position - restoreIndexAndTopPosition(); + } // else - should never happen now return moveCount; }