mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Merge pull request #2404 from nextcloud/fixNPEonRestoring
Resume activity crash due to grid view check
This commit is contained in:
commit
a028232d9c
3 changed files with 17 additions and 25 deletions
|
@ -254,6 +254,11 @@ public abstract class PreferenceManager {
|
|||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
FileDataStorageManager storageManager = ((ComponentsGetter)context).getStorageManager();
|
||||
|
||||
if (storageManager == null) {
|
||||
storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
}
|
||||
|
||||
String value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, folder));
|
||||
while (folder != null && value.isEmpty()) {
|
||||
folder = storageManager.getFileById(folder.getParentId());
|
||||
|
|
|
@ -385,16 +385,6 @@ public class ExtendedListFragment extends Fragment
|
|||
return false;
|
||||
});
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION);
|
||||
|
||||
if (mRecyclerView != null) {
|
||||
Log_OC.v(TAG, "Setting and centering around list position " + referencePosition);
|
||||
|
||||
mRecyclerView.getLayoutManager().scrollToPosition(referencePosition);
|
||||
}
|
||||
}
|
||||
|
||||
// Pull-down to refresh layout
|
||||
mRefreshListLayout = v.findViewById(R.id.swipe_containing_list);
|
||||
onCreateSwipeToRefresh(mRefreshListLayout);
|
||||
|
@ -420,16 +410,6 @@ public class ExtendedListFragment extends Fragment
|
|||
layoutParams.setMargins(0, 0, pixel / 2, bottomNavigationView.getMeasuredHeight() + pixel * 2);
|
||||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState.getBoolean(KEY_IS_GRID_VISIBLE, false)) {
|
||||
switchToGridView();
|
||||
}
|
||||
int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION);
|
||||
|
||||
Log_OC.v(TAG, "Setting grid position " + referencePosition);
|
||||
scrollToPosition(referencePosition);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -483,6 +463,14 @@ public class ExtendedListFragment extends Fragment
|
|||
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
|
||||
mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
|
||||
setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
|
||||
|
||||
if (savedInstanceState.getBoolean(KEY_IS_GRID_VISIBLE, false) && getRecyclerView().getAdapter() != null) {
|
||||
switchToGridView();
|
||||
}
|
||||
|
||||
int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION);
|
||||
Log_OC.v(TAG, "Setting grid position " + referencePosition);
|
||||
scrollToPosition(referencePosition);
|
||||
} else {
|
||||
mIndexes = new ArrayList<>();
|
||||
mFirstPositions = new ArrayList<>();
|
||||
|
|
|
@ -200,10 +200,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
|||
}
|
||||
|
||||
searchFragment = currentSearchType != null;
|
||||
|
||||
if (isGridViewPreferred(getCurrentFile())) {
|
||||
switchToGridView();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,8 +348,11 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
|||
onMessageEvent(searchEvent);
|
||||
}
|
||||
|
||||
setTitle();
|
||||
if (isGridViewPreferred(getCurrentFile())) {
|
||||
switchToGridView();
|
||||
}
|
||||
|
||||
setTitle();
|
||||
}
|
||||
|
||||
private void prepareCurrentSearch(SearchEvent event) {
|
||||
|
|
Loading…
Reference in a new issue