Merge "Solve stutter when swiping All Apps the first time" into jb-dev

This commit is contained in:
Michael Jurka
2012-05-15 17:01:25 -07:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 2 deletions

View File

@@ -816,6 +816,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
onSyncWidgetPageItems(d);
}
mDeferredSyncWidgetPageItems.clear();
mForceDrawAllChildrenNextFrame = !toWorkspace;
}
@Override
@@ -1519,7 +1520,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
protected void onPageEndMoving() {
super.onPageEndMoving();
mForceDrawAllChildrenNextFrame = true;
// We reset the save index when we change pages so that it will be recalculated on next
// rotation
mSaveInstanceStateItemIndex = -1;

View File

@@ -134,6 +134,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected boolean mAllowOverScroll = true;
protected int mUnboundedScrollX;
protected int[] mTempVisiblePagesRange = new int[2];
protected boolean mForceDrawAllChildrenNextFrame;
// mOverScrollX is equal to getScrollX() when we're within the normal scroll range. Otherwise
// it is equal to the scaled overscroll position. We use a separate value so as to prevent
@@ -797,13 +798,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// View.INVISIBLE, preventing re-drawing of their hardware layer
for (int i = getChildCount() - 1; i >= 0; i--) {
final View v = getPageAt(i);
if (leftScreen <= i && i <= rightScreen && shouldDrawChild(v)) {
if (mForceDrawAllChildrenNextFrame ||
(leftScreen <= i && i <= rightScreen && shouldDrawChild(v))) {
v.setVisibility(VISIBLE);
drawChild(canvas, v, drawingTime);
} else {
v.setVisibility(INVISIBLE);
}
}
mForceDrawAllChildrenNextFrame = false;
canvas.restore();
}
}