List of usage examples for android.animation ValueAnimator setDuration
@Override public ValueAnimator setDuration(long duration)
From source file:com.huyn.demogroup.zoomageview.view.PhotoViewAttacher.java
private void reverseFromDrag() { final float translationY = mImageView.getTranslationY(); final float translationX = mImageView.getTranslationX(); final float startScale = mImageView.getScaleX(); ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); animator.setDuration(200); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w ww. j a va 2 s.co m*/ public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); float y = translationY * (1 - value); float x = translationX * (1 - value); float scale = startScale + (1 - startScale) * value; mImageView.setTranslationY(y); mImageView.setTranslationX(x); mImageView.setScaleY(scale); mImageView.setScaleX(scale); } }); animator.start(); if (translationY >= mDragToFinishDistance / 2 && mDragToFinishListener != null && mEnableDragToFinish) { //doReverse(); mDragToFinish = true; //mDragToFinishListener.onDismiss(); System.out.println("+++++++++change mDragToFinish:" + mDragToFinish); View parent = (View) mImageView.getParent(); if (parent instanceof PhotoLayout) ((PhotoLayout) parent).reverse(); } }
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.jav 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); } }); }
From source file:com.telenav.nodeflow.NodeFlowLayout.java
/** * perform a fade out animation for hiding node content * * @param node active node/* w w w . j av a 2 s .c om*/ */ private void fadeOut(final Node<?> node) { ValueAnimator animator = ValueAnimator.ofFloat(1, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = 1; i < getChildCount(); ++i) { getChildAt(i).setAlpha(((Float) animation.getAnimatedValue())); } } }); animator.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { animateDrillOut(node); } }); animator.setDuration(duration / 2); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.start(); }
From source file:bottombar.BottomBarTab.java
private void setTopPaddingAnimated(int start, int end) { if (type == Type.TABLET) { return;// w ww . ja v a2 s . co m } ValueAnimator paddingAnimator = ValueAnimator.ofInt(start, end); paddingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { iconView.setPadding(iconView.getPaddingLeft(), (Integer) animation.getAnimatedValue(), iconView.getPaddingRight(), iconView.getPaddingBottom()); } }); paddingAnimator.setDuration(ANIMATION_DURATION); paddingAnimator.start(); }
From source file:com.musenkishi.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations.//from ww w . ja va 2 s . c om */ private void toggleZoomImage() { int animationDuration = 400; if (isInFullscreen()) { scrollView.smoothScrollTo(0, (Integer) scrollView.getTag()); photoViewAttacher.setScale(1.0f, true); } else { scrollView.setTag(scrollView.getScrollY()); scrollView.smoothScrollTo(0, 0); } if (getSupportActionBar() != null) { getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight()) .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f) .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start(); int minimumAllowedHeight = getToolbar().getMeasuredHeight() + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); if (imageSize.getHeight() < minimumAllowedHeight) { int topFrom; int topTo; if (isInFullscreen()) { topFrom = 0; topTo = getToolbar().getMeasuredHeight(); } else { topFrom = photoLayoutHolder.getPaddingTop(); topTo = 0; } ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo); topValueAnimator.setDuration(animationDuration); topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val, photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom()); } }); topValueAnimator.start(); } if (photoLayoutHolder.getTranslationY() > 0.0f) { photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator()) .setDuration(animationDuration).start(); } WindowManager win = getWindowManager(); Display d = win.getDefaultDisplay(); int from = photoView.getMeasuredHeight(); int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight(); ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to); valueAnimator.setDuration(animationDuration); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView .getLayoutParams(); toolbarParams.height = val; photoView.setLayoutParams(toolbarParams); } }); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { photoViewAttacher.setZoomable(true); photoView.setZoomable(true); photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v2) { toggleZoomImage(); } }); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); valueAnimator.start(); int scrollTo = isInFullscreen() ? 0 : d.getHeight(); scrollView.animate().y(scrollTo).setDuration(animationDuration) .setInterpolator(new EaseInOutBezierInterpolator()).start(); isInFullscreen = !isInFullscreen; }
From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java
private void animateScanMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0); anim.setDuration(900);//from w w w. j av a 2s. co m messageContainer.startAnimation(anim); messageContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(initialCourseListPadding, messageContainer.getMeasuredHeight()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { courseList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); courseList.setSelectionAfterHeaderView(); } }); animator.setStartDelay(200); animator.setDuration(700); animator.start(); }
From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java
public void collapseLeftPane(int speed) { int targetWidth = mMinLeftWidth; ValueAnimator animator = ValueAnimator.ofObject(new WidthEvaluator(mLeftPane), mLeftPane.getWidth(), targetWidth);//from w w w . java2 s .c o m animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mLeftName.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mLeftView.setVisibility(View.GONE); mIsLeftCollapsed = true; } }); animator.setInterpolator(new DecelerateInterpolator()); animator.setDuration(speed); animator.start(); }
From source file:ca.zadrox.dota2esportticker.ui.TeamDetailActivity.java
private void createCompatReveal() { mHeaderTeamLogo.setVisibility(View.VISIBLE); mHeaderTeamLogo.setImageBitmap(mTeam.logo); mHeaderTeamLogo.setTranslationY(-UIUtils.calculateActionBarSize(this) - mHeaderTeamLogo.getHeight()); mHeaderTeamLogo.animate().translationY(0).setDuration(100) .setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new Animator.AnimatorListener() { @Override/* ww w.j ava2s . c om*/ public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mHeaderTeamName.animate().alpha(1).setDuration(150) .setInterpolator(new AccelerateDecelerateInterpolator()).start(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), getResources().getColor(R.color.theme_primary), mTeam.palette.getDarkVibrantColor(getResources().getColor(R.color.theme_primary))); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { mHeaderBox.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setDuration(150); colorAnimation.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }).start(); }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations./* ww w. j a v a 2 s.c o m*/ * @param visibility if VISIBLE, expands toolbar. */ private void animateToolbar(int visibility) { float from; float to; int toolbarOffset; int fabOffset; if (visibility == View.VISIBLE) { from = 0.0f; to = 1.0f; fabOffset = 200; toolbarOffset = 0; } else { from = 1.0f; to = 0.0f; fabOffset = 0; toolbarOffset = 200; } buttonFullscreen.animate().scaleX(to).scaleY(to).setDuration(400).setStartDelay(fabOffset) .setInterpolator(new EaseInOutBezierInterpolator()).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { buttonFullscreen.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }).start(); int toolbarFrom; int toolbarTo; if (from > 0.0f) { toolbarFrom = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height); toolbarTo = 0; } else { toolbarFrom = 0; toolbarTo = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height); } ValueAnimator valueAnimator = ValueAnimator.ofInt(toolbarFrom, toolbarTo); valueAnimator.setDuration(400); valueAnimator.setStartDelay(toolbarOffset); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) toolbar.getLayoutParams(); toolbarParams.height = val; toolbar.setLayoutParams(toolbarParams); } }); valueAnimator.start(); }
From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java
private void animateIdleStateButtonAfterClick() { int textColorChangeDuration = 10; ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()), mIdleStateTextColorAfterClick); colorAnim.setDuration(textColorChangeDuration); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start();// www . j a v a2s.com ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick, getNormalColor(this.getTextColors())); colorAnim1.setDuration(0); colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration); colorAnim1.setEvaluator(new ArgbEvaluator()); colorAnim1.setInterpolator(new BounceInterpolator()); colorAnim1.start(); ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState), mIdleStateBackgroundColorAfterClick); bgAnim.setDuration(0); bgAnim.setEvaluator(new ArgbEvaluator()); bgAnim.start(); int textSizeAnimationDuration = 150; ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4); animator.setDuration(textSizeAnimationDuration); animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); setTextSize(animatedValue); } }); animator.start(); }