Removing new object creating during scroll/draw
Change-Id: I627832c1659ac332d0ea3279dffba9d3c71ec2af
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index c73b3ee..a069c56 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -813,23 +813,14 @@
if (getPageCount() == 0 || getPageAt(0).getMeasuredWidth() == 0) {
return;
}
- CurveProperties curveProperties = mOrientationHandler
- .getCurveProperties(this, mInsets);
- int scroll = curveProperties.scroll;
- final int halfPageSize = curveProperties.halfPageSize;
- final int screenCenter = curveProperties.screenCenter;
- final int halfScreenSize = curveProperties.halfScreenSize;
- final int pageSpacing = mPageSpacing;
- mScrollState.scrollFromEdge = mIsRtl ? scroll : (mMaxScroll - scroll);
+ mOrientationHandler.getCurveProperties(this, mInsets, mScrollState);
+ mScrollState.scrollFromEdge =
+ mIsRtl ? mScrollState.scroll : (mMaxScroll - mScrollState.scroll);
final int pageCount = getPageCount();
for (int i = 0; i < pageCount; i++) {
View page = getPageAt(i);
- float pageCenter = mOrientationHandler.getViewCenterPosition(page) + halfPageSize;
- float distanceFromScreenCenter = screenCenter - pageCenter;
- float distanceToReachEdge = halfScreenSize + halfPageSize + pageSpacing;
- mScrollState.linearInterpolation = Math.min(1,
- Math.abs(distanceFromScreenCenter) / distanceToReachEdge);
+ mScrollState.updateInterpolation(mOrientationHandler.getChildStart(page), mPageSpacing);
((PageCallbacks) page).onPageScroll(mScrollState);
}
}
@@ -1201,7 +1192,7 @@
default void onPageScroll(ScrollState scrollState) {}
}
- public static class ScrollState {
+ public static class ScrollState extends CurveProperties {
/**
* The progress from 0 to 1, where 0 is the center
@@ -1213,6 +1204,17 @@
* The amount by which all the content is scrolled relative to the end of the list.
*/
public float scrollFromEdge;
+
+ /**
+ * Updates linearInterpolation for the provided child position
+ */
+ public void updateInterpolation(int childStart, int pageSpacing) {
+ float pageCenter = childStart + halfPageSize;
+ float distanceFromScreenCenter = screenCenter - pageCenter;
+ float distanceToReachEdge = halfScreenSize + halfPageSize + pageSpacing;
+ linearInterpolation = Math.min(1,
+ Math.abs(distanceFromScreenCenter) / distanceToReachEdge);
+ }
}
public void setIgnoreResetTask(int taskId) {
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 1db65b9..6715bc1 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -16,8 +16,11 @@
package com.android.launcher3.touch;
+import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
+import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
+import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;
+
import android.content.res.Resources;
-import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -32,13 +35,8 @@
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.PagedView;
import com.android.launcher3.Utilities;
-import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.util.OverScroller;
-import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
-import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
-import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;
-
public class LandscapePagedViewHandler implements PagedOrientationHandler {
@Override
@@ -67,12 +65,11 @@
}
@Override
- public CurveProperties getCurveProperties(PagedView pagedView, Rect mInsets) {
- int scroll = pagedView.getScrollY();
- final int halfPageSize = pagedView.getNormalChildHeight() / 2;
- final int screenCenter = mInsets.top + pagedView.getPaddingTop() + scroll + halfPageSize;
- final int halfScreenSize = pagedView.getMeasuredHeight() / 2;
- return new CurveProperties(scroll, halfPageSize, screenCenter, halfScreenSize);
+ public void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out) {
+ out.scroll = view.getScrollY();
+ out.halfPageSize = view.getNormalChildHeight() / 2;
+ out.halfScreenSize = view.getMeasuredHeight() / 2;
+ out.screenCenter = mInsets.top + view.getPaddingTop() + out.scroll + out.halfPageSize;
}
@Override
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index b4802cd..24fa815 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -83,7 +83,7 @@
void delegateScrollTo(PagedView pagedView, int primaryScroll);
void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y);
void scrollerStartScroll(OverScroller scroller, int newPosition);
- CurveProperties getCurveProperties(PagedView pagedView, Rect insets);
+ void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out);
boolean isGoingUp(float displacement);
/**
@@ -92,18 +92,12 @@
*/
void adjustFloatingIconStartVelocity(PointF velocity);
- class CurveProperties {
- public final int scroll;
- public final int halfPageSize;
- public final int screenCenter;
- public final int halfScreenSize;
- public CurveProperties(int scroll, int halfPageSize, int screenCenter, int halfScreenSize) {
- this.scroll = scroll;
- this.halfPageSize = halfPageSize;
- this.screenCenter = screenCenter;
- this.halfScreenSize = halfScreenSize;
- }
+ class CurveProperties {
+ public int scroll;
+ public int halfPageSize;
+ public int screenCenter;
+ public int halfScreenSize;
}
class ChildBounds {
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 22eee49..6d903b3 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -16,8 +16,11 @@
package com.android.launcher3.touch;
+import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
+import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
+import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;
+
import android.content.res.Resources;
-import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -32,13 +35,8 @@
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.PagedView;
import com.android.launcher3.Utilities;
-import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.util.OverScroller;
-import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
-import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
-import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;
-
public class PortraitPagedViewHandler implements PagedOrientationHandler {
@Override
@@ -67,12 +65,11 @@
}
@Override
- public CurveProperties getCurveProperties(PagedView pagedView, Rect mInsets) {
- int scroll = pagedView.getScrollX();
- final int halfPageSize = pagedView.getNormalChildWidth() / 2;
- final int screenCenter = mInsets.left + pagedView.getPaddingLeft() + scroll + halfPageSize;
- final int halfScreenSize = pagedView.getMeasuredWidth() / 2;
- return new CurveProperties(scroll, halfPageSize, screenCenter, halfScreenSize);
+ public void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out) {
+ out.scroll = view.getScrollX();
+ out.halfPageSize = view.getNormalChildWidth() / 2;
+ out.halfScreenSize = view.getMeasuredWidth() / 2;
+ out.screenCenter = mInsets.left + view.getPaddingLeft() + out.scroll + out.halfPageSize;
}
@Override