summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-07-24 22:34:36 -0700
committerAdam Cohen <adamcohen@google.com>2012-07-24 22:34:36 -0700
commit1462de39f01cec0ba785386532719cb0207dd827 (patch)
tree3204f51f6f91b97889fb180202d88f83a561c5ca /src/com/android/launcher2/Workspace.java
parenta13a2f2a7bd0550d1ad973f760ff25e1a4137c43 (diff)
downloadandroid_packages_apps_Trebuchet-1462de39f01cec0ba785386532719cb0207dd827.tar.gz
android_packages_apps_Trebuchet-1462de39f01cec0ba785386532719cb0207dd827.tar.bz2
android_packages_apps_Trebuchet-1462de39f01cec0ba785386532719cb0207dd827.zip
Ensuring that restoreInstanceState is being called promptly for synchronously bound page
Change-Id: I0e71c29f553ad360ec42a6a0b2529d16cbddd437
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();