use of android.animation.Animator.AnimatorListener in project Signal-Android by WhisperSystems.
the class Tweener method to.
@SuppressLint("NewApi")
public static Tweener to(Object object, long duration, Object... vars) {
long delay = 0;
AnimatorUpdateListener updateListener = null;
AnimatorListener listener = null;
TimeInterpolator interpolator = null;
// Iterate through arguments and discover properties to animate
ArrayList<PropertyValuesHolder> props = new ArrayList<PropertyValuesHolder>(vars.length / 2);
for (int i = 0; i < vars.length; i += 2) {
if (!(vars[i] instanceof String)) {
throw new IllegalArgumentException("Key must be a string: " + vars[i]);
}
String key = (String) vars[i];
Object value = vars[i + 1];
if ("simultaneousTween".equals(key)) {
// TODO
} else if ("ease".equals(key)) {
// TODO: multiple interpolators?
interpolator = (TimeInterpolator) value;
} else if ("onUpdate".equals(key) || "onUpdateListener".equals(key)) {
updateListener = (AnimatorUpdateListener) value;
} else if ("onComplete".equals(key) || "onCompleteListener".equals(key)) {
listener = (AnimatorListener) value;
} else if ("delay".equals(key)) {
delay = ((Number) value).longValue();
} else if ("syncWith".equals(key)) {
// TODO
} else if (value instanceof float[]) {
props.add(PropertyValuesHolder.ofFloat(key, ((float[]) value)[0], ((float[]) value)[1]));
} else if (value instanceof Number) {
float floatValue = ((Number) value).floatValue();
props.add(PropertyValuesHolder.ofFloat(key, floatValue));
} else {
throw new IllegalArgumentException("Bad argument for key \"" + key + "\" with value " + value.getClass());
}
}
// Re-use existing tween, if present
Tweener tween = sTweens.get(object);
ObjectAnimator anim = null;
if (tween == null) {
anim = ObjectAnimator.ofPropertyValuesHolder(object, props.toArray(new PropertyValuesHolder[props.size()]));
tween = new Tweener(anim);
sTweens.put(object, tween);
if (DEBUG)
Log.v(TAG, "Added new Tweener " + tween);
} else {
anim = sTweens.get(object).animator;
// Cancel all animators for given object
replace(props, object);
}
if (interpolator != null) {
anim.setInterpolator(interpolator);
}
// Update animation with properties discovered in loop above
anim.setStartDelay(delay);
anim.setDuration(duration);
if (updateListener != null) {
// There should be only one
anim.removeAllUpdateListeners();
anim.addUpdateListener(updateListener);
}
if (listener != null) {
// There should be only one.
anim.removeAllListeners();
anim.addListener(listener);
}
anim.addListener(mCleanupListener);
anim.start();
return tween;
}
use of android.animation.Animator.AnimatorListener in project Leonids by plattysoft.
the class ParticleSystem method startAnimator.
private void startAnimator(Interpolator interpolator, long animnationTime) {
mAnimator = ValueAnimator.ofInt(0, (int) animnationTime);
mAnimator.setDuration(animnationTime);
mAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int miliseconds = (Integer) animation.getAnimatedValue();
onUpdate(miliseconds);
}
});
mAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
cleanupAnimation();
}
@Override
public void onAnimationCancel(Animator animation) {
cleanupAnimation();
}
});
mAnimator.setInterpolator(interpolator);
mAnimator.start();
}
use of android.animation.Animator.AnimatorListener in project android-tooltips by rharter.
the class ToolTipLayout method dismiss.
/**
* Dismisses all tooltips currently being displayed.
*
* @param animate True to animate the transition.
*/
public void dismiss(boolean animate) {
mToolTips.clear();
if (animate) {
final List<View> viewsToRemove = new ArrayList<>();
List<Animator> a = new ArrayList<>();
for (int i = 0; i < getChildCount(); i++) {
a.add(ObjectAnimator.ofFloat(getChildAt(i), View.ALPHA, 0));
viewsToRemove.add(getChildAt(i));
}
AnimatorSet s = new AnimatorSet();
s.playTogether(a);
s.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
for (View v : viewsToRemove) {
removeView(v);
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
s.start();
} else {
removeAllViews();
}
}
use of android.animation.Animator.AnimatorListener in project android-different-loading-animations by raweng.
the class AllAnimation method windowsAnimation.
public void windowsAnimation() {
final ValueAnimator valueTvOne_x = ObjectAnimator.ofFloat(windowsTvOne, "x", windowsTvOne.getX() - 40, windowsTvOne.getX() - 50, (screenWidth / 2) + 10f, (screenWidth / 2) + 25f, //,(screenWidth / 2)+55f//,(screenWidth / 2)+80f//,(screenWidth/2 )+25f,(screenWidth / 2) +30f//, (screenWidth / 2)+35f,(screenWidth / 2)+40f,(screenWidth / 2)+45f //,(screenWidth / 2)+6.6f,(screenWidth / 2)+7.7f,(screenWidth / 2)+8.8f //, (screenWidth / 2)+9,(screenWidth / 2)+10,
(screenWidth / 2) + 50f, screenWidth * .92f, screenWidth + 5);
valueTvOne_x.setDuration(5200);
valueTvOne_x.setRepeatCount(0);
valueTvOne_x.setRepeatMode(ValueAnimator.REVERSE);
valueTvOne_x.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
windowsTvOne.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
final ValueAnimator valueTvTwo_x = //, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
ObjectAnimator.ofFloat(//, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
windowsTvTwo, //, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
"x", //, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
windowsTvTwo.getX() - 50, //, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
(screenWidth / 2.1f) + 10f, //, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
(screenWidth / 2.1f) + 25f, //, (screenWidth / 2.1f) +55f//, (screenWidth / 2.1f) +80f//, (screenWidth / 2.1f) +25f,(screenWidth / 2.1f) +30f
(screenWidth / 2.1f) + 50f, screenWidth * .94f, screenWidth + 5);
valueTvTwo_x.setDuration(6000);
valueTvTwo_x.setRepeatCount(0);
valueTvTwo_x.setStartDelay(200);
valueTvTwo_x.setRepeatMode(ValueAnimator.REVERSE);
valueTvTwo_x.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
windowsTvTwo.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
final ValueAnimator valueTvThree_x = //,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
ObjectAnimator.ofFloat(//,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
windowsTvThree, //,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
"x", //,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
windowsTvThree.getX() - 50, //,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
(screenWidth / 2.2f) + 10f, //,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
(screenWidth / 2.2f) + 25f, //,(screenWidth / 2.2f) +55f//,(screenWidth / 2.2f) +80f//,(screenWidth / 2.2f) +25f,(screenWidth / 2.2f) +30f
(screenWidth / 2.2f) + 50f, screenWidth * .94f, screenWidth + 5);
valueTvThree_x.setDuration(6500);
valueTvThree_x.setRepeatCount(0);
valueTvTwo_x.setStartDelay(500);
valueTvThree_x.setRepeatMode(ValueAnimator.REVERSE);
valueTvThree_x.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
windowsTvThree.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
windowsAnimatorSet = new AnimatorSet();
windowsAnimatorSet.playTogether(valueTvTwo_x, valueTvThree_x, valueTvOne_x);
windowsAnimatorSet.start();
windowsAnimatorSet.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
windowsAnimatorSet.start();
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
}
use of android.animation.Animator.AnimatorListener in project android-app by spark.
the class Pin method animateYourself.
public void animateYourself() {
final ViewGroup parent = (ViewGroup) view.getParent();
if (pinBackgroundAnim != null) {
pinBackgroundAnim.end();
pinBackgroundAnim = null;
}
pinBackgroundAnim = (ObjectAnimator) AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_start);
pinBackgroundAnim.setTarget(parent);
pinBackgroundAnim.setEvaluator(new ArgbEvaluator());
pinBackgroundAnim.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// NO OP
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
endAnimation = getCancelAnimator();
endAnimation.start();
}
});
pinBackgroundAnim.start();
}
Aggregations