From: David A. Velasco Date: Mon, 17 Jun 2013 09:16:39 +0000 (+0200) Subject: Fixed bad transitions after adding protection for removed accounts to PreviewVideoAct... X-Git-Tag: oc-android-1.4.3~9^2~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/10b014a19aa591a6cfe1f838c7a635a8875b6385?ds=inline;hp=--cc Fixed bad transitions after adding protection for removed accounts to PreviewVideoActivity --- 10b014a19aa591a6cfe1f838c7a635a8875b6385 diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index ae8c9207..a70e266b 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -216,18 +216,24 @@ public class FileDisplayActivity extends FileActivity implements } setFile(file); mDirectories.clear(); - while(file != null && file.getFileName() != OCFile.PATH_SEPARATOR) { - if (file.isDirectory()) { - mDirectories.add(file.getFileName()); + OCFile fileIt = file; + while(fileIt != null && fileIt.getFileName() != OCFile.PATH_SEPARATOR) { + if (fileIt.isDirectory()) { + mDirectories.add(fileIt.getFileName()); } - file = mStorageManager.getFileById(file.getParentId()); + fileIt = mStorageManager.getFileById(fileIt.getParentId()); } mDirectories.add(OCFile.PATH_SEPARATOR); if (!stateWasRecovered) { Log_OC.e(TAG, "Initializing Fragments in onAccountChanged.."); initFragmentsWithFile(); + + } else { + updateFragmentsVisibility(!file.isDirectory()); + updateNavigationElementsInActionBar(file.isDirectory() ? null : file); } + } else { Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!"); } @@ -243,6 +249,14 @@ public class FileDisplayActivity extends FileActivity implements private void initFragmentsWithFile() { if (getAccount() != null && getFile() != null) { + /// First fragment + OCFileListFragment listOfFiles = getListOfFilesFragment(); + if (listOfFiles != null) { + listOfFiles.listDirectory(getCurrentDir()); + } else { + Log.e(TAG, "Still have a chance to lose the initializacion of list fragment >("); + } + /// Second fragment OCFile file = getFile(); Fragment secondFragment = chooseInitialSecondFragment(file); @@ -608,12 +622,6 @@ public class FileDisplayActivity extends FileActivity implements mDownloadFinishReceiver = new DownloadFinishReceiver(); registerReceiver(mDownloadFinishReceiver, downloadIntentFilter); - // List current directory - OCFileListFragment listOfFiles = getListOfFilesFragment(); - if (listOfFiles != null) { - listOfFiles.listDirectory(getCurrentDir()); // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check) - } - Log_OC.d(TAG, "onResume() end"); } @@ -988,9 +996,9 @@ public class FileDisplayActivity extends FileActivity implements /** * TODO */ - private void updateNavigationElementsInActionBar(OCFile currentFile) { + private void updateNavigationElementsInActionBar(OCFile chosenFile) { ActionBar actionBar = getSupportActionBar(); - if (currentFile == null || mDualPane) { + if (chosenFile == null || mDualPane) { // only list of files - set for browsing through folders OCFile currentDir = getCurrentDir(); actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0); @@ -1001,7 +1009,7 @@ public class FileDisplayActivity extends FileActivity implements } else { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); - actionBar.setTitle(currentFile.getFileName()); + actionBar.setTitle(chosenFile.getFileName()); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } } @@ -1011,15 +1019,6 @@ public class FileDisplayActivity extends FileActivity implements * {@inheritDoc} */ @Override - public OCFile getInitialDirectory() { - return getCurrentDir(); - } - - - /** - * {@inheritDoc} - */ - @Override public void onFileStateChanged() { refeshListOfFilesFragment(); } @@ -1317,12 +1316,11 @@ public class FileDisplayActivity extends FileActivity implements if (file != null) { if (file.isDirectory()) { return file; - } else { + } else if (mStorageManager != null) { return mStorageManager.getFileById(file.getParentId()); } - } else { - return null; } + return null; } } diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 80f53580..b05ba284 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -51,19 +51,14 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { private Context mContext; private OCFile mFile = null; private Vector mFiles = null; - private DataStorageManager mStorageManager; + private DataStorageManager mStorageManager = null; private Account mAccount; private TransferServiceGetter mTransferServiceGetter; - public FileListListAdapter(OCFile file, DataStorageManager storage_man, - Context context, TransferServiceGetter transferServiceGetter) { - mStorageManager = storage_man; + public FileListListAdapter(Context context, TransferServiceGetter transferServiceGetter) { mContext = context; mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext); mTransferServiceGetter = transferServiceGetter; - swapDirectory(file, mStorageManager); - /*mFile = file; - mFiles = mStorageManager.getDirectoryContent(mFile);*/ } @Override diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 35b37749..015ebaa1 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -94,7 +94,7 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log_OC.e(TAG, "onActivityCreated() start"); - mAdapter = new FileListListAdapter(mContainerActivity.getInitialDirectory(), mContainerActivity.getStorageManager(), getActivity(), mContainerActivity); + mAdapter = new FileListListAdapter(getActivity(), mContainerActivity); setListAdapter(mAdapter); registerForContextMenu(getListView()); @@ -124,7 +124,6 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName if (file != null) { if (file.isDirectory()) { // update state and view of this fragment - mFile = file; listDirectory(file); // then, notify parent activity to let it update its state and view, and other fragments mContainerActivity.onBrowsedDownTo(file); @@ -388,14 +387,6 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName /** - * Callback method invoked when the parent activity is fully created to get the directory to list firstly. - * - * @return Directory to list firstly. Can be NULL. - */ - public OCFile getInitialDirectory(); - - - /** * Callback method invoked when a the 'transfer state' of a file changes. * * This happens when a download or upload is started or ended for a file.