Example usage for android.animation ValueAnimator getAnimatedValue

List of usage examples for android.animation ValueAnimator getAnimatedValue

Introduction

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

Prototype

public Object getAnimatedValue() 

Source Link

Document

The most recent value calculated by this ValueAnimator when there is just one property being animated.

Usage

From source file:com.hippo.widget.Slider.java

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
    mContext = context;/*from   ww  w .  ja  v  a  2 s . co  m*/
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextAlign(Paint.Align.CENTER);

    Resources resources = context.getResources();
    mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width);
    mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height);

    mBubble = new BubbleView(context, textPaint);
    mBubble.setScaleX(0.0f);
    mBubble.setScaleY(0.0f);
    AbsoluteLayout absoluteLayout = new AbsoluteLayout(context);
    absoluteLayout.addView(mBubble);
    absoluteLayout.setBackgroundDrawable(null);
    mPopup = new PopupWindow(absoluteLayout);
    mPopup.setOutsideTouchable(false);
    mPopup.setTouchable(false);
    mPopup.setFocusable(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider);
    textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE));
    textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12));

    updateTextSize();

    setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0));
    setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0));
    mThickness = a.getDimension(R.styleable.Slider_thickness, 2);
    mRadius = a.getDimension(R.styleable.Slider_radius, 6);
    setColor(a.getColor(R.styleable.Slider_color, Color.BLACK));

    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000);

    a.recycle();

    mProgressAnimation = new ValueAnimator();
    mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawPercent = value;
            mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value));
            updateBubblePosition();
            mBubble.setProgress(mDrawProgress);
            invalidate();
        }
    });

    mBubbleScaleAnimation = new ValueAnimator();
    mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawBubbleScale = value;
            mBubble.setScaleX(value);
            mBubble.setScaleY(value);
            invalidate();
        }
    });
}

From source file:com.android.contacts.activities.ActionBarAdapter.java

private void animateTabHeightChange(int start, int end) {
    if (mPortraitTabs == null) {
        return;/*from  ww w  .j  a va2s . co  m*/
    }
    final ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int value = (Integer) valueAnimator.getAnimatedValue();
            setPortraitTabHeight(value);
        }
    });
    animator.setDuration(100).start();
}

From source file:com.insalyon.les24heures.view.DrawerArrowDrawable.java

public void animateToSandwich() {
    final DrawerArrowDrawable self = this;
    ValueAnimator animation = ValueAnimator.ofFloat(1f, 0f);
    animation.setDuration(500);/*from  w  ww .  j a  v  a  2  s. c  om*/
    animation.start();
    animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            self.setParameter((Float) animation.getAnimatedValue());
        }
    });
    this.setParameter(0);
}

From source file:com.insalyon.les24heures.view.DrawerArrowDrawable.java

public void animateToArrow() {
    final DrawerArrowDrawable self = this;
    ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
    animation.setDuration(500);/*from w w  w  .  j av  a 2s  . c o  m*/
    animation.start();
    animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            self.setParameter((Float) animation.getAnimatedValue());
        }
    });

    this.setFlip(true);
}

From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java

private void animateScanMediaMessage() {
    TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0);
    anim.setDuration(900);/*from  www.ja v a  2 s  . 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:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private void animateShadesColor(int toColor) {
    cancelRunningAnimator(mColorAnimator);

    int fromColor = mView.getColorTempProgress();

    mColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    mColorAnimator.setDuration(FADE_DURATION_MS);
    mColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/* w  w w .  ja v  a  2 s .  com*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mView.setColorTempProgress((Integer) valueAnimator.getAnimatedValue());
        }
    });

    mColorAnimator.start();
}

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private void animateDimLevel(int toDimLevel, Animator.AnimatorListener listener) {
    cancelRunningAnimator(mDimAnimator);

    int fromDimLevel = mView.getFilterDimLevel();

    mDimAnimator = ValueAnimator.ofInt(fromDimLevel, toDimLevel);
    mDimAnimator.setDuration(FADE_DURATION_MS);
    mDimAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/* ww  w  .j  a  va2 s. c om*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mView.setFilterDimLevel((Integer) valueAnimator.getAnimatedValue());
        }
    });

    if (listener != null) {
        mDimAnimator.addListener(listener);
    }

    mDimAnimator.start();
}

From source file:com.telenav.nodeflow.NodeFlowLayout.java

/**
 * perform a fade in animation for showing node content
 *
 * @param node active node// w  w w . j ava  2  s.c o  m
 */
private void fadeIn(final Node<?> node) {
    ValueAnimator animator = ValueAnimator.ofFloat(1);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            for (int i = getChildCount()
                    - (node.hasChildren() ? node.getChildCount() : 1); i < getChildCount(); ++i) {
                getChildAt(i).setAlpha(((Float) animation.getAnimatedValue()));
            }
        }
    });
    animator.setDuration(duration);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.start();
}

From source file:io.github.trulyfree.easyaspi.MainActivity.java

/**
 *
 *//*from   w w w  .  j av  a  2  s . c  om*/
private void resetConfigReturned() {
    final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned);
    LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config);
    EditText moduleName = (EditText) findViewById(R.id.module_returned_configname);
    EditText moduleVersion = (EditText) findViewById(R.id.module_returned_configversion);
    EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl);
    EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl);
    LinearLayout moduleDependencies = (LinearLayout) findViewById(R.id.module_returned_dependencies);
    Button validate = (Button) findViewById(R.id.module_returned_validate);
    Button cancel = (Button) findViewById(R.id.module_returned_cancel);
    moduleName.setText(R.string.module_returned_configname);
    moduleVersion.setText(R.string.module_returned_configversion);
    moduleConfigUrl.setText(R.string.module_returned_configurl);
    moduleJarUrl.setText(R.string.module_returned_jarurl);
    moduleDependencies.removeAllViewsInLayout();
    validate.setOnClickListener(null);
    cancel.setOnClickListener(null);
    final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear);
    final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(ANIMATION_DURATION);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    layout.setClickable(false);
    configResponseBlock.setVisibility(View.VISIBLE);
    colorAnimation.start();
}

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private void animateIntensityLevel(int toIntensityLevel, Animator.AnimatorListener listener) {
    cancelRunningAnimator(mIntensityAnimator);

    int fromIntensityLevel = mView.getFilterIntensityLevel();

    mIntensityAnimator = ValueAnimator.ofInt(fromIntensityLevel, toIntensityLevel);
    mIntensityAnimator.setDuration(FADE_DURATION_MS);
    mIntensityAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*  w  ww.jav a2s . c  o  m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mView.setFilterIntensityLevel((Integer) valueAnimator.getAnimatedValue());
        }
    });

    if (listener != null) {
        mIntensityAnimator.addListener(listener);
    }

    mIntensityAnimator.start();
}