use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.
the class SlideInAnimationHandler method animateMenuClosing.
@Override
public void animateMenuClosing(Point center) {
super.animateMenuOpening(center);
setAnimating(true);
Animator lastAnimation = null;
for (int i = 0; i < menu.getSubActionItems().size(); i++) {
// PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, - (menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2));
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, DIST_Y);
// PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
// PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0);
final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhY, pvhA);
animation.setDuration(DURATION);
animation.setInterpolator(new AccelerateInterpolator());
animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING));
if (i == 0) {
lastAnimation = animation;
}
if (i <= menu.getSubActionItems().size() / 2) {
animation.setStartDelay(i * LAG_BETWEEN_ITEMS);
} else {
animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
}
animation.start();
}
if (lastAnimation != null) {
lastAnimation.addListener(new LastAnimationListener());
}
}
use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.
the class ArcLayout method bindChildAnimation.
private void bindChildAnimation(final View child, final int index, final long duration) {
final boolean expanded = mExpanded;
final int centerX = getWidth() / 2;
final int centerY = getHeight() / 2;
final int radius = expanded ? 0 : mRadius;
final int childCount = getChildCount();
final float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1);
Rect frame = computeChildFrame(centerX, centerY, radius, mFromDegrees + index * perDegrees, mChildSize);
final int toXDelta = frame.left - child.getLeft();
final int toYDelta = frame.top - child.getTop();
Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (isLast) {
postDelayed(new Runnable() {
@Override
public void run() {
onAllAnimationsEnd();
}
}, 0);
}
}
});
child.setAnimation(animation);
}
use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.
the class RayLayout method bindChildAnimation.
private void bindChildAnimation(final View child, final int index, final long duration) {
final boolean expanded = mExpanded;
final int childCount = getChildCount();
Rect frame = computeChildFrame(!expanded, mLeftHolderWidth, index, mChildGap, mChildSize);
final int toXDelta = frame.left - child.getLeft();
final int toYDelta = frame.top - child.getTop();
Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (isLast) {
postDelayed(new Runnable() {
@Override
public void run() {
onAllAnimationsEnd();
}
}, 0);
}
}
});
child.setAnimation(animation);
}
use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.
the class CardContainer method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mTopCard == null) {
return false;
}
if (mGestureDetector.onTouchEvent(event)) {
return true;
}
Log.d("Touch Event", MotionEvent.actionToString(event.getActionMasked()) + " ");
final int pointerIndex;
final float x, y;
final float dx, dy;
switch(event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mTopCard.getHitRect(childRect);
pointerIndex = event.getActionIndex();
x = event.getX(pointerIndex);
y = event.getY(pointerIndex);
if (!childRect.contains((int) x, (int) y)) {
return false;
}
mLastTouchX = x;
mLastTouchY = y;
mActivePointerId = event.getPointerId(pointerIndex);
float[] points = new float[] { x - mTopCard.getLeft(), y - mTopCard.getTop() };
mTopCard.getMatrix().invert(mMatrix);
mMatrix.mapPoints(points);
mTopCard.setPivotX(points[0]);
mTopCard.setPivotY(points[1]);
break;
case MotionEvent.ACTION_MOVE:
pointerIndex = event.findPointerIndex(mActivePointerId);
x = event.getX(pointerIndex);
y = event.getY(pointerIndex);
dx = x - mLastTouchX;
dy = y - mLastTouchY;
if (Math.abs(dx) > mTouchSlop || Math.abs(dy) > mTouchSlop) {
mDragging = true;
}
if (!mDragging) {
return true;
}
mTopCard.setTranslationX(mTopCard.getTranslationX() + dx);
mTopCard.setTranslationY(mTopCard.getTranslationY() + dy);
mTopCard.setRotation(40 * mTopCard.getTranslationX() / (getWidth() / 2.f));
mLastTouchX = x;
mLastTouchY = y;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (!mDragging) {
return true;
}
mDragging = false;
mActivePointerId = INVALID_POINTER_ID;
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mTopCard, PropertyValuesHolder.ofFloat("translationX", 0), PropertyValuesHolder.ofFloat("translationY", 0), PropertyValuesHolder.ofFloat("rotation", (float) Math.toDegrees(mRandom.nextGaussian() * DISORDERED_MAX_ROTATION_RADIANS)), PropertyValuesHolder.ofFloat("pivotX", mTopCard.getWidth() / 2.f), PropertyValuesHolder.ofFloat("pivotY", mTopCard.getHeight() / 2.f)).setDuration(250);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
break;
case MotionEvent.ACTION_POINTER_UP:
pointerIndex = event.getActionIndex();
final int pointerId = event.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mLastTouchX = event.getX(newPointerIndex);
mLastTouchY = event.getY(newPointerIndex);
mActivePointerId = event.getPointerId(newPointerIndex);
}
break;
}
return true;
}
use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.
the class SpanVariableGridView method translateChild.
protected final void translateChild(View v, Point prev, Point now) {
TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, -now.x + prev.x, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -now.y + prev.y, Animation.ABSOLUTE, 0);
translate.setInterpolator(new AccelerateInterpolator(4f));
translate.setDuration(350);
translate.setFillEnabled(false);
translate.setFillAfter(false);
v.clearAnimation();
v.startAnimation(translate);
}
Aggregations