am cf6125c2: Improving performance of state transitions
* commit 'cf6125c2d30ce02d8ab6cbe8e37a20f6a831e216': Improving performance of state transitions
This commit is contained in:
@@ -26,6 +26,7 @@ import android.graphics.Paint;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.Bitmap.Config;
|
import android.graphics.Bitmap.Config;
|
||||||
import android.graphics.PorterDuff.Mode;
|
import android.graphics.PorterDuff.Mode;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@@ -52,6 +53,15 @@ public class CachedViewGroup extends ViewGroup implements VisibilityChangedListe
|
|||||||
|
|
||||||
public CachedViewGroup(Context context) {
|
public CachedViewGroup(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CachedViewGroup(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
mBackgroundRect = new Rect();
|
mBackgroundRect = new Rect();
|
||||||
mCacheRect = new Rect();
|
mCacheRect = new Rect();
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
@@ -124,14 +134,13 @@ public class CachedViewGroup extends ViewGroup implements VisibilityChangedListe
|
|||||||
float alpha = getAlpha();
|
float alpha = getAlpha();
|
||||||
setAlpha(1.0f);
|
setAlpha(1.0f);
|
||||||
isUpdatingCache = true;
|
isUpdatingCache = true;
|
||||||
draw(mCacheCanvas);
|
drawChildren(mCacheCanvas);
|
||||||
isUpdatingCache = false;
|
isUpdatingCache = false;
|
||||||
setAlpha(alpha);
|
setAlpha(alpha);
|
||||||
|
|
||||||
mIsCacheDirty = false;
|
mIsCacheDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void drawChildren(Canvas canvas) {
|
public void drawChildren(Canvas canvas) {
|
||||||
super.dispatchDraw(canvas);
|
super.dispatchDraw(canvas);
|
||||||
}
|
}
|
||||||
@@ -148,11 +157,6 @@ public class CachedViewGroup extends ViewGroup implements VisibilityChangedListe
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeViewWithoutMarkingCells(View view) {
|
|
||||||
super.removeView(view);
|
|
||||||
invalidateCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeView(View view) {
|
public void removeView(View view) {
|
||||||
super.removeView(view);
|
super.removeView(view);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import android.view.animation.LayoutAnimationController;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class CellLayout extends ViewGroup {
|
public class CellLayout extends CachedViewGroup {
|
||||||
static final String TAG = "CellLayout";
|
static final String TAG = "CellLayout";
|
||||||
|
|
||||||
private int mCellWidth;
|
private int mCellWidth;
|
||||||
@@ -363,14 +363,6 @@ public class CellLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableCacheUpdates() {
|
|
||||||
mChildren.disableCacheUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableCacheUpdates() {
|
|
||||||
mChildren.enableCacheUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
|
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
|
||||||
@@ -542,7 +534,7 @@ public class CellLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeViewWithoutMarkingCells(View view) {
|
public void removeViewWithoutMarkingCells(View view) {
|
||||||
mChildren.removeViewWithoutMarkingCells(view);
|
mChildren.removeView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ package com.android.launcher2;
|
|||||||
|
|
||||||
import android.app.WallpaperManager;
|
import android.app.WallpaperManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.MeasureSpec;
|
||||||
|
|
||||||
public class CellLayoutChildren extends CachedViewGroup {
|
public class CellLayoutChildren extends ViewGroup {
|
||||||
static final String TAG = "CellLayoutChildren";
|
static final String TAG = "CellLayoutChildren";
|
||||||
|
|
||||||
// These are temporary variables to prevent having to allocate a new object just to
|
// These are temporary variables to prevent having to allocate a new object just to
|
||||||
@@ -94,7 +95,6 @@ public class CellLayoutChildren extends CachedViewGroup {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
super.onLayout(changed, l, t, r, b);
|
|
||||||
int count = getChildCount();
|
int count = getChildCount();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final View child = getChildAt(i);
|
final View child = getChildAt(i);
|
||||||
|
|||||||
@@ -2783,10 +2783,12 @@ public final class Launcher extends Activity
|
|||||||
PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.0f));
|
PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.0f));
|
||||||
alphaAnim.setDuration(res.getInteger(R.integer.config_allAppsFadeOutTime));
|
alphaAnim.setDuration(res.getInteger(R.integer.config_allAppsFadeOutTime));
|
||||||
alphaAnim.setInterpolator(new DecelerateInterpolator(2.0f));
|
alphaAnim.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||||
|
fromView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
alphaAnim.addListener(new AnimatorListenerAdapter() {
|
alphaAnim.addListener(new AnimatorListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
fromView.setVisibility(View.GONE);
|
fromView.setVisibility(View.GONE);
|
||||||
|
fromView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user