summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/DragLayer.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-19 19:07:29 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-05-19 19:07:45 -0700
commitb135956e95d2d7479290af89d618892ed0e7327d (patch)
treea7a17877a509791aef58c958b7abd9576df07f96 /src/com/android/launcher3/DragLayer.java
parent39b83c62566f6914f9169cd9ee5f1edb44815109 (diff)
downloadandroid_packages_apps_Trebuchet-b135956e95d2d7479290af89d618892ed0e7327d.tar.gz
android_packages_apps_Trebuchet-b135956e95d2d7479290af89d618892ed0e7327d.tar.bz2
android_packages_apps_Trebuchet-b135956e95d2d7479290af89d618892ed0e7327d.zip
Avoiding object allocation during draw
Change-Id: I94c146e0f4ad7386a31782f0e63e5228a2fa0442
Diffstat (limited to 'src/com/android/launcher3/DragLayer.java')
-rw-r--r--src/com/android/launcher3/DragLayer.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index e25e6152c..a85c42648 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -48,34 +48,35 @@ import java.util.ArrayList;
*/
public class DragLayer extends InsettableFrameLayout {
+ public static final int ANIMATION_END_DISAPPEAR = 0;
+ public static final int ANIMATION_END_FADE_OUT = 1;
+ public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
+
// Scrim color without any alpha component.
private static final int SCRIM_COLOR = Color.BLACK & 0x00FFFFFF;
+ private final int[] mTmpXY = new int[2];
+
@Thunk DragController mDragController;
- private int[] mTmpXY = new int[2];
private int mXDown, mYDown;
private Launcher mLauncher;
// Variables relating to resizing widgets
- private final ArrayList<AppWidgetResizeFrame> mResizeFrames =
- new ArrayList<AppWidgetResizeFrame>();
+ private final ArrayList<AppWidgetResizeFrame> mResizeFrames = new ArrayList<>();
private final boolean mIsRtl;
private AppWidgetResizeFrame mCurrentResizeFrame;
// Variables relating to animation of views after drop
private ValueAnimator mDropAnim = null;
private ValueAnimator mFadeOutAnim = null;
- private TimeInterpolator mCubicEaseOutInterpolator = new DecelerateInterpolator(1.5f);
+ private final TimeInterpolator mCubicEaseOutInterpolator = new DecelerateInterpolator(1.5f);
@Thunk DragView mDropView = null;
@Thunk int mAnchorViewInitialScrollX = 0;
@Thunk View mAnchorView = null;
private boolean mHoverPointClosesFolder = false;
- private Rect mHitRect = new Rect();
- public static final int ANIMATION_END_DISAPPEAR = 0;
- public static final int ANIMATION_END_FADE_OUT = 1;
- public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
+ private final Rect mHitRect = new Rect();
private TouchCompleteListener mTouchCompleteListener;
@@ -87,6 +88,7 @@ public class DragLayer extends InsettableFrameLayout {
private float mBackgroundAlpha = 0;
// Related to adjacent page hints
+ private final Rect mScrollChildPosition = new Rect();
private boolean mInScrollArea;
private boolean mShowPageHints;
private Drawable mLeftHoverDrawable;
@@ -914,6 +916,9 @@ public class DragLayer extends InsettableFrameLayout {
void showPageHints() {
mShowPageHints = true;
+ Workspace workspace = mLauncher.getWorkspace();
+ getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.getChildCount() - 1),
+ mScrollChildPosition);
invalidate();
}
@@ -937,10 +942,6 @@ public class DragLayer extends InsettableFrameLayout {
if (mShowPageHints) {
Workspace workspace = mLauncher.getWorkspace();
int width = getMeasuredWidth();
- Rect childRect = new Rect();
- getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.getChildCount() - 1),
- childRect);
-
int page = workspace.getNextPage();
CellLayout leftPage = (CellLayout) workspace.getChildAt(mIsRtl ? page + 1 : page - 1);
CellLayout rightPage = (CellLayout) workspace.getChildAt(mIsRtl ? page - 1 : page + 1);
@@ -948,15 +949,15 @@ public class DragLayer extends InsettableFrameLayout {
if (leftPage != null && leftPage.isDragTarget()) {
Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ?
mLeftHoverDrawableActive : mLeftHoverDrawable;
- left.setBounds(0, childRect.top,
- left.getIntrinsicWidth(), childRect.bottom);
+ left.setBounds(0, mScrollChildPosition.top,
+ left.getIntrinsicWidth(), mScrollChildPosition.bottom);
left.draw(canvas);
}
if (rightPage != null && rightPage.isDragTarget()) {
Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ?
mRightHoverDrawableActive : mRightHoverDrawable;
right.setBounds(width - right.getIntrinsicWidth(),
- childRect.top, width, childRect.bottom);
+ mScrollChildPosition.top, width, mScrollChildPosition.bottom);
right.draw(canvas);
}
}