List of usage examples for android.animation ObjectAnimator addUpdateListener
public void addUpdateListener(AnimatorUpdateListener listener)
From source file:com.srinath.hcfab.under25hack.media.MediaFragment.java
public void onFabPressed(View view) { final float startX = mFab.getX(); AnimatorPath path = new AnimatorPath(); path.moveTo(0, 0);//from w ww. ja v a2 s. c o m path.curveTo(-200, 200, -400, 100, -600, 50); final ObjectAnimator anim = ObjectAnimator.ofObject(this, "fabLoc", new PathEvaluator(), path.getPoints().toArray()); anim.setInterpolator(new AccelerateInterpolator()); anim.setDuration(ANIMATION_DURATION); anim.start(); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (Math.abs(startX - mFab.getX()) > MINIMUN_X_DISTANCE) { if (!mRevealFlag) { mFabContainer.setY(mFabContainer.getY() + mFabSize / 2); mFab.animate().scaleXBy(SCALE_FACTOR).scaleYBy(SCALE_FACTOR).setListener(mEndRevealListener) .setDuration(ANIMATION_DURATION); mRevealFlag = true; } } } }); }
From source file:com.telenav.expandablepager.SlidingContainer.java
/** * Animate translationY to the next stopValue * @param amount translationY amount//from ww w . ja v a 2 s . c om * @param duration animation duration * @param interpolator animation interpolator */ private void animate(final float amount, int duration, Interpolator interpolator) { ObjectAnimator oa = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, amount).setDuration(duration); oa.setInterpolator(interpolator); oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { notifySlideEvent(Math.round(((Float) animation.getAnimatedValue()))); } }); oa.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { onSettled(stopValueIndex); } }); oa.start(); }
From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java
private static ObjectAnimator getFadeOutAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { final ObjectAnimator animator = ObjectAnimator.ofInt(target, "value", startAlpha, endAlpha); animator.setDuration(FADE_OUT_DURATION); animator.addUpdateListener(updateListener); return animator; }
From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { final float delayMultiplier = 0.25f; final float transitionDurationMultiplier = 1f; final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier); final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration; final Keyframe kf0, kf1, kf2; kf0 = Keyframe.ofInt(0f, startAlpha); kf1 = Keyframe.ofInt(delayPoint, startAlpha); kf2 = Keyframe.ofInt(1f, endAlpha);// w w w .j a v a 2 s . com final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2); final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn); animator.setDuration(totalDuration); animator.addUpdateListener(updateListener); return animator; }
From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static ObjectAnimator getFadeOutAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { final ObjectAnimator animator = ObjectAnimator.ofInt(target, "value", startAlpha, endAlpha); animator.setDuration(FADE_OUT_DURATION); animator.addUpdateListener(updateListener); return animator; }
From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { final float delayMultiplier = 0.25f; final float transitionDurationMultiplier = 1f; final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier); final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration; final Keyframe kf0, kf1, kf2; kf0 = Keyframe.ofInt(0f, startAlpha); kf1 = Keyframe.ofInt(delayPoint, startAlpha); kf2 = Keyframe.ofInt(1f, endAlpha);// www . j ava2s . co m final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2); final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn); animator.setDuration(totalDuration); animator.addUpdateListener(updateListener); return animator; }
From source file:com.example.google.maps.flyover.MainActivity.java
public void animateRoute() { LinkedList<Animator> animators = new LinkedList<Animator>(); // For each segment of the route, create one heading adjustment animator // and one segment fly-over animator. for (int i = 0; i < ROUTE.length - 1; i++) { // If it the first segment, ensure the camera is rotated properly. float h1; if (i == 0) { h1 = mMap.getCameraPosition().bearing; } else {// w ww .jav a 2s .c om h1 = (float) SphericalUtil.computeHeading(ROUTE[i - 1], ROUTE[i]); } float h2 = (float) SphericalUtil.computeHeading(ROUTE[i], ROUTE[i + 1]); ValueAnimator va = ValueAnimator.ofFloat(h1, h2); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override public void onAnimationUpdate(ValueAnimator animation) { float bearing = (Float) animation.getAnimatedValue(); CameraPosition pos = CameraPosition.builder(mMap.getCameraPosition()).bearing(bearing).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos)); } }); // Use the change in degrees of the heading for the animation // duration. long d = Math.round(Math.abs(h1 - h2)); va.setDuration(d * CAMERA_HEADING_CHANGE_RATE); animators.add(va); ObjectAnimator oa = ObjectAnimator.ofObject(mMarker, "position", new LatLngEvaluator(ROUTE[i], ROUTE[i + 1]), ROUTE[i], ROUTE[i + 1]); oa.setInterpolator(new LinearInterpolator()); oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LatLng target = (LatLng) animation.getAnimatedValue(); mMap.moveCamera(CameraUpdateFactory.newLatLng(target)); } }); // Use the distance of the route segment for the duration. double dist = SphericalUtil.computeDistanceBetween(ROUTE[i], ROUTE[i + 1]); oa.setDuration(Math.round(dist) * 10); animators.add(oa); } mAnimatorSet = new AnimatorSet(); mAnimatorSet.playSequentially(animators); mAnimatorSet.start(); mAnimatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationCancel(Animator animation) { mMenu.findItem(R.id.action_animation).setIcon(R.drawable.ic_action_replay); } @Override public void onAnimationEnd(Animator animation) { mMenu.findItem(R.id.action_animation).setIcon(R.drawable.ic_action_replay); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationStart(Animator animation) { mMenu.findItem(R.id.action_animation).setIcon(R.drawable.ic_action_stop); } }); }
From source file:com.cuelogic.android.WheelIndicatorView.java
public void startItemsAnimation() { ObjectAnimator animation = ObjectAnimator.ofInt(WheelIndicatorView.this, "filledPercent", 0, filledPercent); animation.setDuration(ANIMATION_DURATION); animation.setInterpolator(PathInterpolatorCompat.create(0.4F, 0.0F, 0.2F, 1.0F)); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w.j a v a2s . c om*/ public void onAnimationUpdate(ValueAnimator animation) { recalculateItemsAngles(); invalidate(); } }); animation.start(); }
From source file:us.phyxsi.gameshelf.ui.FeedAdapter.java
private void bindBoardgameHolder(final Boardgame game, final BoardgameHolder holder) { final int[] imageSize = { 400, 400 }; Glide.with(host).load("http:" + game.image).listener(new RequestListener<String, GlideDrawable>() { @Override//from www.java 2 s. com public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { if (!game.hasFadedIn) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( if (holder.image.getDrawable() != null) { holder.image.getDrawable().setColorFilter(new ColorMatrixColorFilter(cm)); } } }); saturation.setDuration(1000); saturation.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.setHasTransientState(false); } }); saturation.start(); game.hasFadedIn = true; } return false; } @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[holder.getAdapterPosition() % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(imageSize[0], imageSize[1]) .into(new BoardgameTarget(holder.image, false)); }
From source file:io.doist.datetimepicker.time.RadialTimePickerView.java
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { Keyframe kf0, kf1, kf2;/*from w w w.j a v a2 s. com*/ int duration = 500; // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; kf0 = Keyframe.ofInt(0f, startAlpha); kf1 = Keyframe.ofInt(delayPoint, startAlpha); kf2 = Keyframe.ofInt(1f, endAlpha); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn).setDuration(totalDuration); animator.addUpdateListener(updateListener); return animator; }