List of usage examples for android.animation ValueAnimator addUpdateListener
public void addUpdateListener(AnimatorUpdateListener listener)
From source file:im.ene.ribbon.TabletActionTabView.java
@Override protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) { if (!animate) { updateLayoutOnAnimation(1, expanded); return;/* w w w .ja v a 2s . co m*/ } final ValueAnimator animator = ObjectAnimator.ofFloat(0, 1); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { updateLayoutOnAnimation(animation.getAnimatedFraction(), expanded); } }); animator.setDuration(animationDuration); animator.setInterpolator(interpolator); animator.start(); }
From source file:com.facebook.react.modules.statusbar.StatusBarModule.java
@ReactMethod public void setColor(final int color, final boolean animated, final Promise res) { final Activity activity = getCurrentActivity(); if (activity == null) { res.reject(ERROR_NO_ACTIVITY, ERROR_NO_ACTIVITY_MESSAGE); return;/*from w ww . j a v a2 s . c o m*/ } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { UiThreadUtil.runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { if (animated) { int curColor = activity.getWindow().getStatusBarColor(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), curColor, color); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { activity.getWindow().setStatusBarColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setDuration(300).setStartDelay(0); colorAnimation.start(); } else { activity.getWindow().setStatusBarColor(color); } res.resolve(null); } }); } else { res.resolve(null); } }
From source file:org.hawkular.client.android.util.ViewTransformer.java
@UiThread public void expand() { view.setVisibility(View.VISIBLE); ValueAnimator animator = ValueAnimator.ofInt(0, Views.measureHeight(view)); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setDuration(Durations.MEDIUM); animator.addUpdateListener(this); animator.start();//from w ww.j av a 2 s . c om }
From source file:com.dycody.android.idealnote.NavigationDrawerFragment.java
void animateBurger(int targetShape) { if (mDrawerToggle != null) { if (targetShape != BURGER && targetShape != ARROW) return; ValueAnimator anim = ValueAnimator.ofFloat((targetShape + 1) % 2, targetShape); anim.addUpdateListener(valueAnimator -> { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset); });/*from w w w . ja v a 2s. co m*/ anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(500); anim.start(); } }
From source file:org.hawkular.client.android.util.ViewTransformer.java
@UiThread public void collapse() { ValueAnimator animator = ValueAnimator.ofInt(Views.measureHeight(view), 0); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setDuration(Durations.MEDIUM); animator.addUpdateListener(this); animator.addListener(new AnimatorListenerAdapter() { @Override// www .jav a 2 s. com public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); animator.start(); }
From source file:liam.franco.selene.fragments.SuperNotesFragment.java
@Subscribe public void newNotesCount(NotesCount notesCount) { boolean hasNotes = notesCount.getSize() > 0; int paddingBottom = -1; if (parentLayout != null) { if (hasNotes) { if (parentLayout.getPaddingBottom() > 0) { paddingBottom = 0;// w ww .ja va 2s . c om } } else { if (parentLayout.getPaddingBottom() <= 0) { paddingBottom = (int) UIUtils.convertDpToPixel(208, App.CONTEXT); } } if (paddingBottom > -1) { ValueAnimator animator = ValueAnimator.ofInt(parentLayout.getPaddingBottom(), paddingBottom); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { if (parentLayout != null) { parentLayout.setPadding(parentLayout.getPaddingLeft(), parentLayout.getPaddingTop(), parentLayout.getPaddingRight(), (Integer) valueAnimator.getAnimatedValue()); } } }); animator.setDuration(500); animator.start(); } } }
From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java
private void animateBackgroundColor(int from, int to, Interpolator interpolator) { final ValueAnimator anim = new ValueAnimator(); anim.setIntValues(from, to);/*from ww w. j ava2s. c om*/ anim.setEvaluator(new ArgbEvaluator()); anim.setInterpolator(interpolator); anim.addUpdateListener(valueAnimator -> { toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingBackground = false; } }); anim.setDuration(ANIMATION_DURATION); anim.start(); isUpdatingBackground = true; }
From source file:xyz.klinker.android.article.ArticleScrollListener.java
private void animateBackgroundColor(int from, int to, Interpolator interpolator) { final ValueAnimator anim = new ValueAnimator(); anim.setIntValues(from, to);/*from w w w . j a v a 2 s . c o m*/ anim.setEvaluator(new ArgbEvaluator()); anim.setInterpolator(interpolator); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingBackground = false; } }); anim.setDuration(ANIMATION_DURATION); anim.start(); isUpdatingBackground = true; }
From source file:com.angelatech.yeyelive.view.PeriscopeLayout.java
private ValueAnimator getBezierValueAnimator(View target) { //??- - /* w ww .j a v a2 s. c o m*/ BezierEvaluator evaluator = new BezierEvaluator(getPointF(2), getPointF(1)); // ? ValueAnimator animator = ValueAnimator.ofObject(evaluator, new PointF((mWidth - dWidth) / 2, mHeight - dHeight), new PointF(random.nextInt(getWidth()), 0)); animator.addUpdateListener(new BezierListenr(target)); animator.setTarget(target); animator.setDuration(1500); 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 {/*from w w w . j a v a2s . c o m*/ 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); } }); }