diff options
Diffstat (limited to 'src/com/cyanogenmod/trebuchet/Workspace.java')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Workspace.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java index a947cd43d..cfe791280 100644 --- a/src/com/cyanogenmod/trebuchet/Workspace.java +++ b/src/com/cyanogenmod/trebuchet/Workspace.java @@ -49,6 +49,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.LayoutInflater; import android.view.MotionEvent; @@ -231,6 +232,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; @@ -1434,6 +1438,14 @@ public class Workspace extends SmoothPagedView } super.onDraw(canvas); + + // Call back to LauncherModel to finish binding after the first draw + post(new Runnable() { + @Override + public void run() { + mLauncher.getModel().bindRemainingSynchronousPages(); + } + }); } boolean isDrawingBackgroundGradient() { @@ -3516,6 +3528,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(); |