use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.
the class MenuCircleShowingAnimation method setOpenAnimation.
/**
* Set open animation for single button
*
* @param promotedAction
* @param position
* @return objectAnimator
*/
private ObjectAnimator setOpenAnimation(ImageButton promotedAction, int position) {
ObjectAnimator objectAnimator;
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_Y, 0f, -px * (promotedActions.size() - position));
objectAnimator.setRepeatCount(0);
objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
} else {
objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_X, 0f, -px * (promotedActions.size() - position));
objectAnimator.setRepeatCount(0);
objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
}
return objectAnimator;
}
use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.
the class MenuCircleShowingAnimation method setCloseAnimation.
/**
* Set close animation for single button
*
* @param promotedAction
* @param position
* @return objectAnimator
*/
private ObjectAnimator setCloseAnimation(ImageButton promotedAction, int position) {
ObjectAnimator objectAnimator;
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_Y, -px * (promotedActions.size() - position), 0f);
objectAnimator.setRepeatCount(0);
objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
} else {
objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_X, -px * (promotedActions.size() - position), 0f);
objectAnimator.setRepeatCount(0);
objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
}
return objectAnimator;
}
use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.
the class Ripple method enter.
/**
* Starts the enter animation.
*/
public void enter() {
cancel();
final int radiusDuration = (int) (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);
final ObjectAnimator radius = ObjectAnimator.ofFloat(this, "radiusGravity", 1);
radius.setAutoCancel(true);
radius.setDuration(radiusDuration);
radius.setInterpolator(LINEAR_INTERPOLATOR);
radius.setStartDelay(RIPPLE_ENTER_DELAY);
final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
cX.setAutoCancel(true);
cX.setDuration(radiusDuration);
cX.setInterpolator(LINEAR_INTERPOLATOR);
cX.setStartDelay(RIPPLE_ENTER_DELAY);
final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
cY.setAutoCancel(true);
cY.setDuration(radiusDuration);
cY.setInterpolator(LINEAR_INTERPOLATOR);
cY.setStartDelay(RIPPLE_ENTER_DELAY);
mAnimRadius = radius;
mAnimX = cX;
mAnimY = cY;
// Enter animations always run on the UI thread, since it's unlikely
// that anything interesting is happening until the user lifts their
// finger.
radius.start();
cX.start();
cY.start();
}
use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.
the class RippleBackground method exitSoftware.
private void exitSoftware(int opacityDuration, int inflectionDuration, int inflectionOpacity) {
final ObjectAnimator outerOpacityAnim;
if (inflectionDuration > 0) {
// Outer opacity continues to increase for a bit.
outerOpacityAnim = ObjectAnimator.ofFloat(this, "outerOpacity", inflectionOpacity / 255.0f);
outerOpacityAnim.setAutoCancel(true);
outerOpacityAnim.setDuration(inflectionDuration);
outerOpacityAnim.setInterpolator(LINEAR_INTERPOLATOR);
// Chain the outer opacity exit animation.
final int outerDuration = opacityDuration - inflectionDuration;
if (outerDuration > 0) {
outerOpacityAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
final ObjectAnimator outerFadeOutAnim = ObjectAnimator.ofFloat(RippleBackground.this, "outerOpacity", 0);
outerFadeOutAnim.setAutoCancel(true);
outerFadeOutAnim.setDuration(outerDuration);
outerFadeOutAnim.setInterpolator(LINEAR_INTERPOLATOR);
outerFadeOutAnim.addListener(mAnimationListener);
mAnimOuterOpacity = outerFadeOutAnim;
outerFadeOutAnim.start();
}
@Override
public void onAnimationCancel(Animator animation) {
animation.removeListener(this);
}
});
} else {
outerOpacityAnim.addListener(mAnimationListener);
}
} else {
outerOpacityAnim = ObjectAnimator.ofFloat(this, "outerOpacity", 0);
outerOpacityAnim.setAutoCancel(true);
outerOpacityAnim.setDuration(opacityDuration);
outerOpacityAnim.addListener(mAnimationListener);
}
mAnimOuterOpacity = outerOpacityAnim;
outerOpacityAnim.start();
}
use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.
the class DynamicGridModification method animateBounds.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void animateBounds(final View mobileView) {
TypeEvaluator<Rect> sBoundEvaluator = new TypeEvaluator<Rect>() {
public Rect evaluate(float fraction, Rect startValue, Rect endValue) {
return new Rect(interpolate(startValue.left, endValue.left, fraction), interpolate(startValue.top, endValue.top, fraction), interpolate(startValue.right, endValue.right, fraction), interpolate(startValue.bottom, endValue.bottom, fraction));
}
public int interpolate(int start, int end, float fraction) {
return (int) (start + fraction * (end - start));
}
};
ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds);
hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
invalidate();
}
});
hoverViewAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mHoverAnimation = true;
updateEnableState();
}
@Override
public void onAnimationEnd(Animator animation) {
mHoverAnimation = false;
updateEnableState();
reset(mobileView);
}
});
hoverViewAnimator.start();
}
Aggregations