mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Take care with orientation changes when save and restore scroll position
This commit is contained in:
parent
20e3a5f420
commit
5b7c5f6244
1 changed files with 13 additions and 4 deletions
|
@ -65,6 +65,9 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
|
|||
|
||||
private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ? OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment";
|
||||
private static final String EXTRA_FILE = MY_PACKAGE + ".extra.FILE";
|
||||
|
||||
private static final String KEY_INDEXES = "INDEXES";
|
||||
private static final String KEY_TOPS = "TOPS";
|
||||
|
||||
private OCFileListFragment.ContainerActivity mContainerActivity;
|
||||
|
||||
|
@ -103,17 +106,21 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
|
|||
mAdapter = new FileListListAdapter(getActivity(), mContainerActivity);
|
||||
if (savedInstanceState != null) {
|
||||
mFile = savedInstanceState.getParcelable(EXTRA_FILE);
|
||||
mIndexes = savedInstanceState.getIntegerArrayList(KEY_INDEXES);
|
||||
mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
|
||||
|
||||
} else {
|
||||
mIndexes = new ArrayList<Integer>();
|
||||
mTops = new ArrayList<Integer>();
|
||||
|
||||
}
|
||||
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
registerForContextMenu(getListView());
|
||||
getListView().setOnCreateContextMenuListener(this);
|
||||
|
||||
mHandler = new Handler();
|
||||
|
||||
mIndexes = new ArrayList<Integer>();
|
||||
mTops = new ArrayList<Integer>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -124,6 +131,8 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
|
|||
public void onSaveInstanceState (Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(EXTRA_FILE, mFile);
|
||||
outState.putIntegerArrayList(KEY_INDEXES, mIndexes);
|
||||
outState.putIntegerArrayList(KEY_TOPS, mTops);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue