Example usage for android.animation ValueAnimator start

List of usage examples for android.animation ValueAnimator start

Introduction

In this page you can find the example usage for android.animation ValueAnimator start.

Prototype

@Override
    public void start() 

Source Link

Usage

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

public void fadeOut() {
    int colorFrom = Color.parseColor("#40000000");
    int colorTo = Color.parseColor("#00000000");
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(250); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override//  w w w . ja  va 2 s.  c om
        public void onAnimationUpdate(ValueAnimator animator) {
            setBackgroundColor((int) animator.getAnimatedValue());
        }

    });
    colorAnimation.start();
}

From source file:arun.com.chromer.browsing.article.view.ElasticDragDismissFrameLayout.java

@Override
public void onStopNestedScroll(View child) {
    if (enabled) {
        if (Math.abs(totalDrag) >= dragDismissDistance) {
            dispatchDismissCallback();/*from ww  w  .  j  a v  a2 s .  c  o m*/
        } else { // settle back to natural position
            if (fastOutSlowInInterpolator == null) {
                fastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
                        android.R.interpolator.fast_out_slow_in);
            }
            getChildAt(0).animate().translationY(0f).scaleX(1f).scaleY(1f).setDuration(200L)
                    .setInterpolator(fastOutSlowInInterpolator).setListener(null).start();

            ValueAnimator animator = null;
            if (draggingUp) {
                animator = ValueAnimator.ofFloat(draggingBackground.top, draggingBackground.bottom);
                animator.addUpdateListener(valueAnimator -> {
                    draggingBackground.top = (float) valueAnimator.getAnimatedValue();
                    invalidate();
                });
            } else if (draggingDown) {
                animator = ValueAnimator.ofFloat(draggingBackground.bottom, draggingBackground.top);
                animator.addUpdateListener(valueAnimator -> {
                    draggingBackground.bottom = (float) valueAnimator.getAnimatedValue();
                    invalidate();
                });
            }

            if (animator != null) {
                animator.setInterpolator(fastOutSlowInInterpolator);
                animator.setDuration(200L);
                animator.start();
            }

            totalDrag = 0;
            draggingDown = draggingUp = false;
            dispatchDragCallback(0f, 0f, 0f, 0f);
        }
    }
}

From source file:com.liujs.library.view.refresh.BGAStickinessRefreshView.java

public void smoothToIdle() {
    ValueAnimator animator = ValueAnimator.ofInt(mCurrentBottomHeight, 0);
    animator.setDuration(mStickinessRefreshViewHolder.getTopAnimDuration());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override// www .  j  a  va 2 s.  c om
        public void onAnimationUpdate(ValueAnimator animation) {
            mCurrentBottomHeight = (int) animation.getAnimatedValue();
            postInvalidate();
        }
    });
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mIsRotating = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animator.start();
}

From source file:com.jsibbold.zoomage.ZoomageView.java

private void animateMatrixIndex(final int index, final float to) {
    ValueAnimator animator = ValueAnimator.ofFloat(mValues[index], to);
    animator.addUpdateListener(new AnimatorUpdateListener() {

        final float[] values = new float[9];
        Matrix current = new Matrix();

        @Override/*from www  .  ja  v  a 2 s . c om*/
        public void onAnimationUpdate(ValueAnimator animation) {
            current.set(getImageMatrix());
            current.getValues(values);
            values[index] = (Float) animation.getAnimatedValue();
            current.setValues(values);
            setImageMatrix(current);
        }
    });
    animator.setDuration(RESET_DURATION);
    animator.start();
}

From source file:com.example.volunteerhandbook.MainActivity.java

void loop_what_I_thought() {
    thoughts = getResources().getStringArray(R.array.what_I_thought);
    int lines = thoughts.length / 4;
    container = (FrameLayout) findViewById(R.id.main_content_frame);
    LinearLayout[] textBox = new LinearLayout[3];
    endY = container.getHeight() - 100f;
    h = (float) container.getHeight();
    hBox = 0;/*w  w  w.ja va  2 s. co  m*/
    /*
    for (int k=0; k<3; k++){
       textBox[k]=new LinearLayout(this);
       textBox[k].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    textBox[k].setOrientation(1);
    }
    */
    //LinearLayout tmp=(LinearLayout) getLayoutInflater().inflate(R.layout.one_line, null);
    //TextView  tmpTxt=(TextView)tmp.findViewById(R.id.oneLine);
    //tmp.removeView(tmpTxt);
    int[] color = new int[4];
    color[3] = Color.parseColor("#66FF66");
    color[1] = Color.parseColor("#FF9900");
    color[2] = Color.parseColor("#0099FF");
    color[0] = Color.parseColor("#00FF00");
    toMove = new TextView[thoughts.length];
    int textSize = 24;
    for (int i = 0; i < thoughts.length; i++) {
        toMove[i] = new TextView(this);
        toMove[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        toMove[i].setText(thoughts[i]);
        toMove[i].setTextSize(textSize);
        toMove[i].getPaint().setFakeBoldText(true);
        toMove[i].setTextColor(color[1] - 0x20202 * i);
        //textBox.addView(toMove);
    }
    int boxHeight = (lines + 1) * (int) (textSize * 1.5);
    for (int k = 0; k < 3; k++) {
        textBox[k].removeAllViews();
        for (int i = 0; i < thoughts.length / 4; i++) {
            TextView v = toMove[iTh++ % thoughts.length];
            v.setTextColor(color[k]);
            textBox[k].addView(v);
        }
        //toMove.setTranslationY(600);
        //container.addView(textBox);
        container.addView(textBox[k]);
        textBox[k].setX(20);
        textBox[k].setY(2 * boxHeight + hBox);
        hBox += boxHeight; //textBox[k].getHeight();
        float startY = textBox[k].getY();
        endY = (-1) * boxHeight;
        int duration = (int) (((startY - endY) / (3 * boxHeight)) * 20000);
        ValueAnimator bounceAnim = ObjectAnimator.ofFloat(textBox[k], "y", startY, endY);
        bounceAnim.setDuration(duration);
        bounceAnim.setInterpolator(new LinearInterpolator());
        final LinearLayout iBox = textBox[k];
        bounceAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                loopNewBox(iBox);
            }
        });
        bounceAnim.start();
    }

}

From source file:com.waz.zclient.pages.main.conversation.views.row.footer.FooterViewController.java

private void expand() {
    if (container.getExpandedView() != null && container.getExpandedView() != this) {
        container.getExpandedView().close();
    }/*from  www . j ava 2 s  .  c o m*/
    container.setExpandedMessageId(message.getId());
    container.setExpandedView(this);
    view.setVisibility(View.VISIBLE);
    if (shouldShowLikeButton()) {
        likeButton.setVisibility(View.VISIBLE);
    }

    View parent = (View) view.getParent();
    final int widthSpec;
    if (parent == null) {
        // needed for tests
        widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    } else {
        widthSpec = View.MeasureSpec.makeMeasureSpec(
                parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(),
                View.MeasureSpec.AT_MOST);
    }
    final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    view.measure(widthSpec, heightSpec);
    ValueAnimator animator = createHeightAnimator(view, 0, view.getMeasuredHeight());

    if (!message.isLiked() && !message.getUser().isMe() && !container.getControllerFactory()
            .getUserPreferencesController().hasPerformedAction(IUserPreferencesController.LIKED_MESSAGE)) {
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mainHandler.removeCallbacksAndMessages(null);
                mainHandler.postDelayed(showMessageStatusRunnable, LIKE_HINT_VISIBILITY_MIL_SEC);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                showLikeDetails();
            }
        });
    }
    animator.start();
}

From source file:com.ze.client.projecto.activity.MainActivity.java

private void animateToolbarColorResource(@ColorRes int fromColorRes, @ColorRes final int toColorRes) {
    @ColorInt/* ww w  . j  av a2 s .co  m*/
    int fromColor = ResourcesCompat.getColor(getResources(), fromColorRes, getTheme());
    @ColorInt
    int toColor = ResourcesCompat.getColor(getResources(), toColorRes, getTheme());

    if (((ColorDrawable) mToolbar.getBackground()).getColor() == toColor) {
        return;
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        ValueAnimator anim = ValueAnimator.ofArgb(fromColor, toColor);
        anim.addUpdateListener(
                valueAnimator -> mToolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()));
        anim.addUpdateListener(
                valueAnimator -> mInfoLayout.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()));

        @ColorInt
        int fromStatusColor = getWindow().getStatusBarColor();
        @ColorInt
        int toStatusColor = ColorUtils.scrimify(toColor, true, 0.2f);
        ValueAnimator anim2 = ValueAnimator.ofArgb(fromStatusColor, toStatusColor);
        anim2.addUpdateListener(
                valueAnimator -> getWindow().setStatusBarColor(((Integer) valueAnimator.getAnimatedValue())));

        anim.setDuration(300);
        anim2.setDuration(300);
        anim.start();
        anim2.start();
    } else {
        mToolbar.setBackgroundColor(toColor);
        mInfoLayout.setBackgroundColor(toColor);
    }
}

From source file:com.advaitaworld.widgets.SlidingTabLayout.java

private void updateTitleColors(int prevSelectedPosition, int newSelectedPosition) {
    if (mSelectedTabColor == 0 && mDefaultTabColor == 0) {
        return;//from  ww w.j  av  a 2s. co m
    }
    View tabViewPrev = mTabStrip.getChildAt(prevSelectedPosition);
    View tabViewNew = mTabStrip.getChildAt(newSelectedPosition);
    final TextView tabTitlePrev = getTabTitleView(tabViewPrev);
    final TextView tabTitleNew = getTabTitleView(tabViewNew);

    ArgbEvaluator evaluator = new ArgbEvaluator();
    ValueAnimator anim1 = new ValueAnimator();
    anim1.setIntValues(mDefaultTabColor, mSelectedTabColor);
    anim1.setEvaluator(evaluator);
    anim1.setDuration(300);
    anim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitleNew.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    ValueAnimator anim2 = new ValueAnimator();
    anim2.setIntValues(mSelectedTabColor, mDefaultTabColor);
    anim2.setEvaluator(evaluator);
    anim2.setDuration(300);
    anim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitlePrev.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim1.start();
    anim2.start();
}

From source file:org.mythtv.client.ui.BackendStatusFragment.java

private void animateCardLinearLayout(final LinearLayout linearLayout, long startDelay) {
    linearLayout.setAlpha(1);//ww  w. j  av  a  2  s  .  com

    // animator that translates linearlayout
    AnimatorUpdateListener translationAnimatorListener = new AnimatorUpdateListener() {

        /* (non-Javadoc)
         * @see android.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(android.animation.ValueAnimator)
         */
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Float w = (Float) animation.getAnimatedValue();
            linearLayout.setTranslationY(w);
        }

    };

    ValueAnimator scaleAnimator = ValueAnimator.ofFloat(linearLayout.getTranslationY(), 0f);
    scaleAnimator.setDuration(500);
    scaleAnimator.setRepeatCount(0);
    scaleAnimator.setStartDelay(startDelay);
    scaleAnimator.addUpdateListener(translationAnimatorListener);

    scaleAnimator.start();
}

From source file:nl.thehyve.transmartclient.MainActivity.java

private void animateToArrow(boolean toArrow) {
    int start, stop;
    if (toArrow) {
        start = 0;/*w ww .jav a  2 s  . c  om*/
        stop = 1;
    } else {
        start = 1;
        stop = 0;
    }
    ValueAnimator anim = ValueAnimator.ofFloat(start, stop);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float slideOffset = (Float) valueAnimator.getAnimatedValue();
            toggle.onDrawerSlide(drawer, slideOffset);
        }
    });
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(300);
    anim.start();
}