Merge "Reduce unnecessary layout passes" into ics-mr1
This commit is contained in:
committed by
Android (Google) Code Review
commit
e6dcf26512
@@ -63,7 +63,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<!-- The icon of the widget. -->
|
||||
<ImageView
|
||||
<com.android.launcher2.PagedViewWidgetImageView
|
||||
android:id="@+id/widget_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -977,7 +977,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
|
||||
// Generate a preview image if we couldn't load one
|
||||
if (drawable == null) {
|
||||
Resources resources = mLauncher.getResources();
|
||||
// TODO: This actually uses the apps customize cell layout params, where as we make want
|
||||
// the Workspace params for more accuracy.
|
||||
int targetWidth = mWidgetSpacingLayout.estimateCellWidth(cellHSpan);
|
||||
|
||||
@@ -102,9 +102,6 @@ public class CellLayout extends ViewGroup {
|
||||
private Drawable mOverScrollRight;
|
||||
private Rect mBackgroundRect;
|
||||
private Rect mForegroundRect;
|
||||
private Rect mGlowBackgroundRect;
|
||||
private float mGlowBackgroundScale;
|
||||
private float mGlowBackgroundAlpha;
|
||||
private int mForegroundPadding;
|
||||
|
||||
// If we're actively dragging something over this screen, mIsDragOverlapping is true
|
||||
@@ -258,9 +255,6 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
mBackgroundRect = new Rect();
|
||||
mForegroundRect = new Rect();
|
||||
mGlowBackgroundRect = new Rect();
|
||||
setHoverScale(1.0f);
|
||||
setHoverAlpha(1.0f);
|
||||
|
||||
mChildren = new CellLayoutChildren(context);
|
||||
mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
|
||||
@@ -351,68 +345,6 @@ public class CellLayout extends ViewGroup {
|
||||
return mIsDragOverlapping;
|
||||
}
|
||||
|
||||
private void updateGlowRect() {
|
||||
float marginFraction = (mGlowBackgroundScale - 1.0f) / 2.0f;
|
||||
int marginX = (int) (marginFraction * (mBackgroundRect.right - mBackgroundRect.left));
|
||||
int marginY = (int) (marginFraction * (mBackgroundRect.bottom - mBackgroundRect.top));
|
||||
mGlowBackgroundRect.set(mBackgroundRect.left - marginX, mBackgroundRect.top - marginY,
|
||||
mBackgroundRect.right + marginX, mBackgroundRect.bottom + marginY);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setHoverScale(float scaleFactor) {
|
||||
if (scaleFactor != mGlowBackgroundScale) {
|
||||
mGlowBackgroundScale = scaleFactor;
|
||||
updateGlowRect();
|
||||
if (getParent() != null) {
|
||||
((View) getParent()).invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getHoverScale() {
|
||||
return mGlowBackgroundScale;
|
||||
}
|
||||
|
||||
public float getHoverAlpha() {
|
||||
return mGlowBackgroundAlpha;
|
||||
}
|
||||
|
||||
public void setHoverAlpha(float alpha) {
|
||||
mGlowBackgroundAlpha = alpha;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void animateDrop() {
|
||||
Resources res = getResources();
|
||||
float onDropScale = res.getInteger(R.integer.config_screenOnDropScalePercent) / 100.0f;
|
||||
ObjectAnimator scaleUp = ObjectAnimator.ofFloat(this, "hoverScale", onDropScale);
|
||||
scaleUp.setDuration(res.getInteger(R.integer.config_screenOnDropScaleUpDuration));
|
||||
ObjectAnimator scaleDown = ObjectAnimator.ofFloat(this, "hoverScale", 1.0f);
|
||||
scaleDown.setDuration(res.getInteger(R.integer.config_screenOnDropScaleDownDuration));
|
||||
ObjectAnimator alphaFadeOut = ObjectAnimator.ofFloat(this, "hoverAlpha", 0.0f);
|
||||
|
||||
alphaFadeOut.setStartDelay(res.getInteger(R.integer.config_screenOnDropAlphaFadeDelay));
|
||||
alphaFadeOut.setDuration(res.getInteger(R.integer.config_screenOnDropAlphaFadeDuration));
|
||||
|
||||
AnimatorSet bouncer = new AnimatorSet();
|
||||
bouncer.play(scaleUp).before(scaleDown);
|
||||
bouncer.play(scaleUp).with(alphaFadeOut);
|
||||
bouncer.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
setIsDragOverlapping(true);
|
||||
}
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
setIsDragOverlapping(false);
|
||||
setHoverScale(1.0f);
|
||||
setHoverAlpha(1.0f);
|
||||
}
|
||||
});
|
||||
bouncer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
|
||||
@@ -939,7 +871,6 @@ public class CellLayout extends ViewGroup {
|
||||
mBackgroundRect.set(0, 0, w, h);
|
||||
mForegroundRect.set(mForegroundPadding, mForegroundPadding,
|
||||
w - 2 * mForegroundPadding, h - 2 * mForegroundPadding);
|
||||
updateGlowRect();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2503,8 +2503,6 @@ public final class Launcher extends Activity
|
||||
void addExternalItemToScreen(ItemInfo itemInfo, final CellLayout layout) {
|
||||
if (!mWorkspace.addExternalItemToScreen(itemInfo, layout)) {
|
||||
showOutOfSpaceMessage();
|
||||
} else {
|
||||
layout.animateDrop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1790,7 +1790,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
updateScrollingIndicatorPosition();
|
||||
cancelScrollingIndicatorAnimations();
|
||||
if (immediately) {
|
||||
mScrollIndicator.setVisibility(View.GONE);
|
||||
mScrollIndicator.setVisibility(View.INVISIBLE);
|
||||
mScrollIndicator.setAlpha(0f);
|
||||
} else {
|
||||
mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 0f);
|
||||
@@ -1804,7 +1804,7 @@ public abstract class PagedView extends ViewGroup {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (!cancelled) {
|
||||
mScrollIndicator.setVisibility(View.GONE);
|
||||
mScrollIndicator.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,10 +136,13 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
||||
}
|
||||
|
||||
void applyPreview(FastBitmapDrawable preview, int index, boolean scale) {
|
||||
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
|
||||
final PagedViewWidgetImageView image =
|
||||
(PagedViewWidgetImageView) findViewById(R.id.widget_preview);
|
||||
if (preview != null) {
|
||||
image.mAllowRequestLayout = false;
|
||||
image.setImageDrawable(preview);
|
||||
image.setScaleType(scale ? ImageView.ScaleType.FIT_START : ImageView.ScaleType.MATRIX);
|
||||
image.mAllowRequestLayout = true;
|
||||
image.setAlpha(0f);
|
||||
image.animate()
|
||||
.alpha(1f)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
|
||||
|
||||
class PagedViewWidgetImageView extends ImageView {
|
||||
public boolean mAllowRequestLayout = true;
|
||||
|
||||
public PagedViewWidgetImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public void requestLayout() {
|
||||
if (mAllowRequestLayout) {
|
||||
super.requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
|
||||
mDropTargetBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mDropTargetBar.setVisibility(View.GONE);
|
||||
mDropTargetBar.setVisibility(View.INVISIBLE);
|
||||
mDropTargetBar.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
});
|
||||
@@ -136,7 +136,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
|
||||
mQSBSearchBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mQSBSearchBar.setVisibility(View.GONE);
|
||||
mQSBSearchBar.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
|
||||
if (animated) {
|
||||
mQSBSearchBarFadeOutAnim.start();
|
||||
} else {
|
||||
mQSBSearchBar.setVisibility(View.GONE);
|
||||
mQSBSearchBar.setVisibility(View.INVISIBLE);
|
||||
mQSBSearchBar.setAlpha(0f);
|
||||
}
|
||||
mIsSearchBarHidden = true;
|
||||
|
||||
@@ -2978,7 +2978,6 @@ public class Workspace extends SmoothPagedView
|
||||
addInScreen(view, container, screen, mTargetCell[0], mTargetCell[1], info.spanX,
|
||||
info.spanY, insertAtFirst);
|
||||
cellLayout.onDropChild(view);
|
||||
cellLayout.animateDrop();
|
||||
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
|
||||
cellLayout.getChildrenLayout().measureChild(view);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user