summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r--src/com/android/launcher2/Workspace.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 331e86f33..44b9f68da 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -47,6 +47,7 @@ import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.SparseArray;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
@@ -232,6 +233,9 @@ public class Workspace extends SmoothPagedView
private int mLastReorderX = -1;
private int mLastReorderY = -1;
+ private SparseArray<Parcelable> mSavedStates;
+ private final ArrayList<Integer> mRestoredPages = new ArrayList<Integer>();
+
// These variables are used for storing the initial and final values during workspace animations
private int mSavedScrollX;
private float mSavedRotationY;
@@ -3411,6 +3415,32 @@ public class Workspace extends SmoothPagedView
}
@Override
+ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
+ // We don't dispatch restoreInstanceState to our children using this code path.
+ // Some pages will be restored immediately as their items are bound immediately, and
+ // others we will need to wait until after their items are bound.
+ mSavedStates = container;
+ }
+
+ public void restoreInstanceStateForChild(int child) {
+ if (mSavedStates != null) {
+ mRestoredPages.add(child);
+ CellLayout cl = (CellLayout) getChildAt(child);
+ cl.restoreInstanceState(mSavedStates);
+ }
+ }
+
+ public void restoreInstanceStateForRemainingPages() {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ if (!mRestoredPages.contains(i)) {
+ restoreInstanceStateForChild(i);
+ }
+ }
+ mRestoredPages.clear();
+ }
+
+ @Override
public void scrollLeft() {
if (!isSmall() && !mIsSwitchingState) {
super.scrollLeft();