am 523a129c: Merge "Use one method to change bounds in ChangeBounds." into lmp-mr1-dev
* commit '523a129ced08a41468f3d52cf16ebb237f280e39': Use one method to change bounds in ChangeBounds.
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.transition;
|
package android.transition;
|
||||||
|
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
|
||||||
@@ -31,7 +32,6 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.IntProperty;
|
|
||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -77,6 +77,32 @@ public class ChangeBounds extends Transition {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Property<ViewBounds, PointF> TOP_LEFT_PROPERTY =
|
||||||
|
new Property<ViewBounds, PointF>(PointF.class, "topLeft") {
|
||||||
|
@Override
|
||||||
|
public void set(ViewBounds viewBounds, PointF topLeft) {
|
||||||
|
viewBounds.setTopLeft(topLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointF get(ViewBounds viewBounds) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final Property<ViewBounds, PointF> BOTTOM_RIGHT_PROPERTY =
|
||||||
|
new Property<ViewBounds, PointF>(PointF.class, "bottomRight") {
|
||||||
|
@Override
|
||||||
|
public void set(ViewBounds viewBounds, PointF bottomRight) {
|
||||||
|
viewBounds.setBottomRight(bottomRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointF get(ViewBounds viewBounds) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int[] tempLocation = new int[2];
|
int[] tempLocation = new int[2];
|
||||||
boolean mResizeClip = false;
|
boolean mResizeClip = false;
|
||||||
boolean mReparent = false;
|
boolean mReparent = false;
|
||||||
@@ -189,36 +215,20 @@ public class ChangeBounds extends Transition {
|
|||||||
}
|
}
|
||||||
if (numChanges > 0) {
|
if (numChanges > 0) {
|
||||||
if (!mResizeClip) {
|
if (!mResizeClip) {
|
||||||
Animator anim;
|
view.setLeftTopRightBottom(startLeft, startTop, startRight, startBottom);
|
||||||
if (startWidth == endWidth && startHeight == endHeight) {
|
ViewBounds viewBounds = new ViewBounds(view);
|
||||||
view.offsetLeftAndRight(startLeft - view.getLeft());
|
Path topLeftPath = getPathMotion().getPath(startLeft, startTop,
|
||||||
view.offsetTopAndBottom(startTop - view.getTop());
|
endLeft, endTop);
|
||||||
Path positionPath = getPathMotion().getPath(0, 0, endLeft - startLeft,
|
ObjectAnimator topLeftAnimator = ObjectAnimator
|
||||||
endTop - startTop);
|
.ofObject(viewBounds, TOP_LEFT_PROPERTY, null, topLeftPath);
|
||||||
anim = ObjectAnimator.ofInt(view, new HorizontalOffsetProperty(),
|
|
||||||
new VerticalOffsetProperty(), positionPath);
|
Path bottomRightPath = getPathMotion().getPath(startRight, startBottom,
|
||||||
} else {
|
endRight, endBottom);
|
||||||
if (startLeft != endLeft) view.setLeft(startLeft);
|
ObjectAnimator bottomRightAnimator = ObjectAnimator.ofObject(viewBounds,
|
||||||
if (startTop != endTop) view.setTop(startTop);
|
BOTTOM_RIGHT_PROPERTY, null, bottomRightPath);
|
||||||
if (startRight != endRight) view.setRight(startRight);
|
AnimatorSet anim = new AnimatorSet();
|
||||||
if (startBottom != endBottom) view.setBottom(startBottom);
|
anim.playTogether(topLeftAnimator, bottomRightAnimator);
|
||||||
ObjectAnimator topLeftAnimator = null;
|
|
||||||
if (startLeft != endLeft || startTop != endTop) {
|
|
||||||
Path topLeftPath = getPathMotion().getPath(startLeft, startTop,
|
|
||||||
endLeft, endTop);
|
|
||||||
topLeftAnimator = ObjectAnimator
|
|
||||||
.ofInt(view, "left", "top", topLeftPath);
|
|
||||||
}
|
|
||||||
ObjectAnimator bottomRightAnimator = null;
|
|
||||||
if (startRight != endRight || startBottom != endBottom) {
|
|
||||||
Path bottomRightPath = getPathMotion().getPath(startRight, startBottom,
|
|
||||||
endRight, endBottom);
|
|
||||||
bottomRightAnimator = ObjectAnimator.ofInt(view, "right", "bottom",
|
|
||||||
bottomRightPath);
|
|
||||||
}
|
|
||||||
anim = TransitionUtils.mergeAnimators(topLeftAnimator,
|
|
||||||
bottomRightAnimator);
|
|
||||||
}
|
|
||||||
if (view.getParent() instanceof ViewGroup) {
|
if (view.getParent() instanceof ViewGroup) {
|
||||||
final ViewGroup parent = (ViewGroup) view.getParent();
|
final ViewGroup parent = (ViewGroup) view.getParent();
|
||||||
parent.suppressLayout(true);
|
parent.suppressLayout(true);
|
||||||
@@ -357,47 +367,41 @@ public class ChangeBounds extends Transition {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class OffsetProperty extends IntProperty<View> {
|
private static class ViewBounds {
|
||||||
int mPreviousValue;
|
private int mLeft;
|
||||||
|
private int mTop;
|
||||||
|
private int mRight;
|
||||||
|
private int mBottom;
|
||||||
|
private boolean mIsTopLeftSet;
|
||||||
|
private boolean mIsBottomRightSet;
|
||||||
|
private View mView;
|
||||||
|
|
||||||
public OffsetProperty(String name) {
|
public ViewBounds(View view) {
|
||||||
super(name);
|
mView = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setTopLeft(PointF topLeft) {
|
||||||
public void setValue(View view, int value) {
|
mLeft = Math.round(topLeft.x);
|
||||||
int offset = value - mPreviousValue;
|
mTop = Math.round(topLeft.y);
|
||||||
offsetBy(view, offset);
|
mIsTopLeftSet = true;
|
||||||
mPreviousValue = value;
|
if (mIsBottomRightSet) {
|
||||||
|
setLeftTopRightBottom();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setBottomRight(PointF bottomRight) {
|
||||||
public Integer get(View object) {
|
mRight = Math.round(bottomRight.x);
|
||||||
return null;
|
mBottom = Math.round(bottomRight.y);
|
||||||
|
mIsBottomRightSet = true;
|
||||||
|
if (mIsTopLeftSet) {
|
||||||
|
setLeftTopRightBottom();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void offsetBy(View view, int by);
|
private void setLeftTopRightBottom() {
|
||||||
}
|
mView.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom);
|
||||||
|
mIsTopLeftSet = false;
|
||||||
private static class HorizontalOffsetProperty extends OffsetProperty {
|
mIsBottomRightSet = false;
|
||||||
public HorizontalOffsetProperty() {
|
|
||||||
super("offsetLeftAndRight");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void offsetBy(View view, int by) {
|
|
||||||
view.offsetLeftAndRight(by);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class VerticalOffsetProperty extends OffsetProperty {
|
|
||||||
public VerticalOffsetProperty() {
|
|
||||||
super("offsetTopAndBottom");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void offsetBy(View view, int by) {
|
|
||||||
view.offsetTopAndBottom(by);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15699,6 +15699,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as setFrame, but public and hidden. For use in {@link android.transition.ChangeBounds}.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setLeftTopRightBottom(int left, int top, int right, int bottom) {
|
||||||
|
setFrame(left, top, right, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
private void sizeChange(int newWidth, int newHeight, int oldWidth, int oldHeight) {
|
private void sizeChange(int newWidth, int newHeight, int oldWidth, int oldHeight) {
|
||||||
onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
|
onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
|
||||||
if (mOverlay != null) {
|
if (mOverlay != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user