List of usage examples for android.animation ValueAnimator setDuration
@Override public ValueAnimator setDuration(long duration)
From source file:com.songcode.materialnotes.ui.NoteEditActivity.java
private void animateRevealHide(final View targetview, View startView) { if (isActionInsertOrEdit()) { int cx = startView.getLeft() + (startView.getWidth() / 2); //middle of button int cy = startView.getTop() + (startView.getHeight() / 2); //middle of button int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left Animator anim = ViewAnimationUtils.createCircularReveal(targetview, cx, cy, radius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override//www. ja v a2s.c om public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); targetview.setVisibility(View.INVISIBLE); } }); //anim.setInterpolator(new AccelerateInterpolator()); anim.setDuration(ANIM_DURATION); anim.start(); Integer colorTo = getResources().getColor(R.color.primaryColor); Integer colorFrom = getResources().getColor(android.R.color.white); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { targetview.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setInterpolator(new AccelerateInterpolator(2)); colorAnimation.setDuration(ANIM_DURATION); colorAnimation.start(); } else if (isActionActionView()) { mAnimBackGroudView.animate().scaleX(1).scaleY(1).alpha(1).translationY(0).setDuration(ANIM_DURATION) .setInterpolator(new AccelerateInterpolator()).start(); mNoteEditor.animate().alpha(0).setDuration(100).start(); } }
From source file:com.telenav.nodeflow.NodeFlowLayout.java
/** * perform opening animation for the specified node * * @param node node to be animated//from w ww. j a v a2 s . c om */ private void animateDrillIn(final Node<?> node) { final int index = activeNode.getIndex() + (activeNode.getDepth() > 1 ? 1 : 0); ValueAnimator animator = ValueAnimator.ofFloat(1); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = 0; i < getChildCount(); ++i) { if (i < index) { getChildAt(i).setTranslationY( headerHeight * i - ((Float) animation.getAnimatedValue()) * headerHeight * index); } else if (i > index) { getChildAt(i).setTranslationY(headerHeight * i + ((Float) animation.getAnimatedValue()) * (getHeight() - headerHeight * index)); } else { getChildAt(i).setTranslationY( headerHeight * i - ((Float) animation.getAnimatedValue()) * headerHeight * index); // move active item } } } }); animator.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { updateViews(node, true); } }); animator.setDuration(duration); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.start(); animateDrillAlpha(index + 1, getChildCount(), 0); }
From source file:org.odk.collect.android.views.ODKView.java
public void highlightWidget(FormIndex formIndex) { QuestionWidget qw = getQuestionWidget(formIndex); if (qw != null) { // postDelayed is needed because otherwise scrolling may not work as expected in case when // answers are validated during form finalization. new Handler().postDelayed(() -> { findViewById(R.id.odk_view_container).scrollTo(0, qw.getTop()); ValueAnimator va = new ValueAnimator(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { va.setIntValues(getResources().getColor(R.color.red_500), getDrawingCacheBackgroundColor()); } else { // Avoid fading to black on certain devices and Android versions that may not support transparency TypedValue typedValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true); if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) { va.setIntValues(getResources().getColor(R.color.red_500), typedValue.data); } else { va.setIntValues(getResources().getColor(R.color.red_500), getDrawingCacheBackgroundColor()); }/*from w ww.j ava2 s . c om*/ } va.setEvaluator(new ArgbEvaluator()); va.addUpdateListener( valueAnimator -> qw.setBackgroundColor((int) valueAnimator.getAnimatedValue())); va.setDuration(2500); va.start(); }, 100); } }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Start Refresh// w w w . j a v a2 s .c o m * @param headerViewHeight */ private void startRefresh(int headerViewHeight) { mRefreshing = true; ValueAnimator animator = ValueAnimator.ofFloat(headerViewHeight, refreshViewHeight); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LayoutParams lp = (LayoutParams) headerView.getLayoutParams(); lp.height = (int) ((Float) animation.getAnimatedValue()).floatValue(); headerView.setLayoutParams(lp); moveTargetView(lp.height); } }); animator.addListener(new WXRefreshAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { headerView.startAnimation(); //TODO updateLoadText if (onRefreshListener != null) { onRefreshListener.onRefresh(); } } }); animator.setDuration(300); animator.start(); }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Start loadmore/*from w w w . j a va 2 s .c o m*/ * @param headerViewHeight */ private void startLoadmore(int headerViewHeight) { mRefreshing = true; ValueAnimator animator = ValueAnimator.ofFloat(headerViewHeight, loadingViewHeight); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LayoutParams lp = (LayoutParams) footerView.getLayoutParams(); lp.height = (int) ((Float) animation.getAnimatedValue()).floatValue(); footerView.setLayoutParams(lp); moveTargetView(-lp.height); } }); animator.addListener(new WXRefreshAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { footerView.startAnimation(); //TODO updateLoadText if (onLoadingListener != null) { onLoadingListener.onLoading(); } } }); animator.setDuration(300); animator.start(); }
From source file:com.waz.zclient.pages.main.participants.dialog.ParticipantsDialogFragment.java
private void updateParticipantsDialogSizeAndPos(boolean keyboardIsVisible, int minParticipantsDialogHeight, int keyboardHeight) { // Expand / collapse when needed final boolean shouldExpand = !keyboardIsVisible && isParticipantsDialogMinimized(); final boolean shouldCollapse = keyboardIsVisible && !isParticipantsDialogMinimized() && ViewUtils.isInLandscape(getActivity()); final ValueAnimator sizeAnimator; if (shouldExpand) { sizeAnimator = ValueAnimator.ofObject(new HeightEvaluator(dialogFrameLayout), dialogFrameLayout.getMeasuredHeight(), regularParticipantsDialogHeight); } else if (shouldCollapse) { sizeAnimator = ValueAnimator.ofObject(new HeightEvaluator(dialogFrameLayout), dialogFrameLayout.getMeasuredHeight(), minParticipantsDialogHeight); } else {/*from ww w. java2 s. c o m*/ sizeAnimator = null; } if (sizeAnimator != null) { sizeAnimator.setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); sizeAnimator.start(); } // Update vertical position if (keyboardIsVisible && !isParticipantsDialogShiftedUp()) { final int navigationBarHeight = ViewUtils.getNavigationBarHeight(getActivity()); int dialogDY; int markerDY; if (selfGravity == Gravity.TOP) { dialogDY = navigationBarHeight - keyboardHeight + participantDialogPadding; markerDY = navigationBarHeight - keyboardHeight + participantDialogPadding; } else { dialogDY = -keyboardHeight; markerDY = -keyboardHeight; } if (shouldCollapse) { dialogDY += dialogFrameLayout.getMeasuredHeight() - minParticipantsDialogHeight; } dialogFrameLayout.animate().translationYBy(dialogDY) .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)) .withEndAction(new Runnable() { @Override public void run() { if (getView() == null) { return; } // Invalidate to avoid view being incorrectly drawn multiple times due to animation getView().invalidate(); } }).start(); marker.animate().translationYBy(markerDY) .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)).start(); } else if (!keyboardIsVisible && isParticipantsDialogShiftedUp()) { dialogFrameLayout.animate().translationY(dialogTranslationY) .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)) .withEndAction(new Runnable() { @Override public void run() { if (getView() == null) { return; } // Invalidate to avoid view being incorrectly drawn multiple times due to animation getView().invalidate(); } }).start(); marker.animate().translationY(markerTranslationY) .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)).start(); } }
From source file:com.tengio.FloatingSearchView.java
private void fadeInBackground() { ValueAnimator anim = ValueAnimator.ofInt(BACKGROUND_DRAWABLE_ALPHA_SEARCH_NOT_FOCUSED, BACKGROUND_DRAWABLE_ALPHA_SEARCH_FOCUSED); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w. ja v a 2s.co m public void onAnimationUpdate(ValueAnimator animation) { int value = (Integer) animation.getAnimatedValue(); } }); anim.setDuration(BACKGROUND_FADE_ANIM_DURATION); anim.start(); }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Resize a view to a given width and height. If a parameter is -1 then that dimension is not changed", example = "") @APIParam(params = { "View", "width", "height" }) public void resize(final View v, int h, int w) { boolean animated = false; if (!animated) { if (h != -1) { v.getLayoutParams().height = h; }/*from w ww. j av a2s . c o m*/ if (w != -1) { v.getLayoutParams().width = w; } v.setLayoutParams(v.getLayoutParams()); } else { int initHeight = v.getLayoutParams().height; // v.setLayoutParams(v.getLayoutParams()); ValueAnimator anim = ValueAnimator.ofInt(initHeight, h); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); v.getLayoutParams().height = val; v.setLayoutParams(v.getLayoutParams()); } }); anim.setDuration(200); anim.start(); } }
From source file:com.hippo.widget.lockpattern.LockPatternView.java
private void startSizeAnimation(float start, float end, long duration, Interpolator interpolator, final CellState state, final Runnable endRunnable) { ValueAnimator valueAnimator = ValueAnimator.ofFloat(start, end); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//w w w . jav a 2 s . c o m public void onAnimationUpdate(ValueAnimator animation) { state.size = (float) animation.getAnimatedValue(); invalidate(); } }); if (endRunnable != null) { valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { endRunnable.run(); } }); } valueAnimator.setInterpolator(interpolator); valueAnimator.setDuration(duration); valueAnimator.start(); }
From source file:com.tengio.FloatingSearchView.java
private void refreshLeftIcon(boolean showAnim) { int leftActionWidthAndMarginLeft = Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START); int queryTranslationX = 0; mLeftAction.setVisibility(VISIBLE);/*from w w w. ja v a 2 s .co m*/ switch (mLeftActionMode) { case LEFT_ACTION_MODE_SHOW_HAMBURGER: if (showAnim && mMenuBtnDrawable.getProgress() == 1.0f) { ValueAnimator anim = ValueAnimator.ofFloat(1.0f, 0.0f); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mMenuBtnDrawable.setProgress(value); } }); anim.setDuration(MENU_ICON_ANIM_DURATION); anim.start(); break; } mLeftAction.setImageDrawable(mMenuBtnDrawable); mMenuBtnDrawable.setProgress(0.0f); break; case LEFT_ACTION_MODE_SHOW_SEARCH: mLeftAction.setImageDrawable(mIconSearch); break; case LEFT_ACTION_MODE_SHOW_HOME: if (showAnim && mMenuBtnDrawable.getProgress() == 0.0f) { ValueAnimator anim = ValueAnimator.ofFloat(0.0f, 1.0f); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mMenuBtnDrawable.setProgress(value); } }); anim.setDuration(MENU_ICON_ANIM_DURATION); anim.start(); break; } mLeftAction.setImageDrawable(mMenuBtnDrawable); mMenuBtnDrawable.setProgress(1.0f); break; case LEFT_ACTION_MODE_NO_LEFT_ACTION: mLeftAction.setVisibility(View.INVISIBLE); queryTranslationX = -leftActionWidthAndMarginLeft; break; } mSearchInputParent.setTranslationX(queryTranslationX); }