From 5b7c5f6244411d1a7a9bece5baf3ee53775f235b Mon Sep 17 00:00:00 2001 From: masensio Date: Thu, 3 Apr 2014 14:56:31 +0200 Subject: [PATCH] Take care with orientation changes when save and restore scroll position --- .../android/ui/fragment/OCFileListFragment.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index e25f3dc51a..70432486ad 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); } /**