From: masensio Date: Thu, 3 Apr 2014 12:56:31 +0000 (+0200) Subject: Take care with orientation changes when save and restore scroll position X-Git-Tag: oc-android-1.7.0_signed~337^2~8 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/5b7c5f6244411d1a7a9bece5baf3ee53775f235b?ds=inline Take care with orientation changes when save and restore scroll position --- diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index e25f3dc5..70432486 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -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(); + mTops = new ArrayList(); + } + setListAdapter(mAdapter); registerForContextMenu(getListView()); getListView().setOnCreateContextMenuListener(this); mHandler = new Handler(); - - mIndexes = new ArrayList(); - mTops = new ArrayList(); - } @@ -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); } /**