Example usage for android.animation ValueAnimator setDuration

List of usage examples for android.animation ValueAnimator setDuration

Introduction

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

Prototype

@Override
public ValueAnimator setDuration(long duration) 

Source Link

Document

Sets the length of the animation.

Usage

From source file:com.rong.library.widget.mapsearchbar.MapSearchBar.java

private void animateSuggestionList(int from, int to) {
    suggestionsVisible = (to > 0);/*from  www . j a  va 2 s .  c o  m*/

    final ViewGroup.LayoutParams lp = containerSuggestion.getLayoutParams();
    if (to == 0 && lp.height == 0)
        return; // already collapsed

    if (to == 0)
        from = lp.height;

    ValueAnimator animator = ValueAnimator.ofInt(from, to);
    animator.setDuration(200);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            lp.height = (int) animation.getAnimatedValue();
            containerSuggestion.setLayoutParams(lp);
        }
    });

    animator.start();
}

From source file:com.arsy.maps_library.MapRipple.java

private void startAnimation(final int numberOfRipple) {
    ValueAnimator animator = ValueAnimator.ofInt(0, (int) mDistance);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setRepeatMode(ValueAnimator.RESTART);
    animator.setDuration(mRippleDuration);
    animator.setEvaluator(new IntEvaluator());
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from   w  w w  . j  a  v a 2  s  .c o  m
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int animated = (int) valueAnimator.getAnimatedValue();
            mGroundOverlays[numberOfRipple].setDimensions(animated);
            if (mDistance - animated <= 10) {
                if (mLatLng != mPrevLatLng) {
                    mGroundOverlays[numberOfRipple].setPosition(mLatLng);
                }
            }
        }
    });
    animator.start();
    mAnimators[numberOfRipple] = animator;
}

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;//  ww  w .  j a  v a  2s  .  c o  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.angelatech.yeyelive.view.PeriscopeLayout.java

private ValueAnimator getBezierValueAnimator(View target) {
    //??- - //  ww  w .j a v  a  2 s  . com
    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:net.margaritov.preference.colorpicker.ColorPickerDialog.java

private ValueAnimator createColorTransitionAnimator(float start, float end) {
    ValueAnimator animator = ValueAnimator.ofFloat(start, end);

    animator.setDuration(500);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from  www  .j a va 2  s  .c  o  m
        public void onAnimationUpdate(ValueAnimator animation) {
            float position = animation.getAnimatedFraction();
            if (mIsPanelButtons) {
                int[] blended = new int[8];
                for (int i = 0; i < mPanelViewButtons.length; i++) {
                    blended[i] = blendColors(mPanelViewButtons[i].getColor(), mPaletteColors[mPalette][i],
                            position);
                    mPanelViewButtons[i].setColor(blended[i]);
                }
            } else {
                int blended = blendColors(mNewColor.getColor(), mNewColorValue, position);
                mNewColor.setColor(blended);
            }
        }
    });
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsPanelButtons) {
                mIsPanelButtons = true;
            }
        }
    });
    return animator;
}

From source file:org.catrobat.paintroid.ui.BottomBar.java

private void delayedAnimateSelectedTool(int startDelay) {
    ImageButton button = getToolButtonByToolType(mCurrentToolType);
    int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated);
    int fadedColor = color & 0x00ffffff;
    ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(500);
    valueAnimator.setRepeatCount(5);/*  ww w  .ja v a2s . c o  m*/
    valueAnimator.setRepeatMode(ValueAnimator.REVERSE);
    valueAnimator.setStartDelay(startDelay);
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (PaintroidApplication.currentTool != null) {
                setActivatedToolButton(PaintroidApplication.currentTool.getToolType());
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    valueAnimator.start();
}

From source file:com.mishiranu.dashchan.util.DrawerToggle.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void setDrawerIndicatorMode(int mode) {
    if (this.mode != mode) {
        this.mode = mode;
        ActionBar actionBar = activity.getActionBar();
        if (mode == MODE_DISABLED) {
            if (C.API_JELLY_BEAN_MR2) {
                actionBar.setHomeAsUpIndicator(null);
            }//  w  ww.j av  a 2 s.co  m
            actionBar.setDisplayHomeAsUpEnabled(false);
        } else {
            actionBar.setDisplayHomeAsUpEnabled(true);
            if (C.API_LOLLIPOP) {
                activity.getActionBar().setHomeAsUpIndicator(arrowDrawable);
                boolean open = drawerLayout.isDrawerOpen(Gravity.START) && arrowDrawable.position == 1f;
                if (!open) {
                    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
                    animator.setDuration(DRAWER_CLOSE_DURATION);
                    animator.addUpdateListener(new StateArrowAnimatorListener(mode == MODE_DRAWER));
                    animator.start();
                }
            } else {
                setActionBarUpIndicatorObsolete(mode == MODE_DRAWER ? slideDrawable : homeAsUpIndicator);
            }
        }
    }
}

From source file:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java

private void setupAnimators() {
    AnimatorSet set = new AnimatorSet();
    for (int i = 0; i < mSpinnerCount; i++) {
        final int index = i;
        final ValueAnimator sweepAnimator = ValueAnimator.ofFloat(0, MAX_SWEEP_ANGLE);
        sweepAnimator.setInterpolator(SWEEP_ANIMATOR_INTERPOLATOR);
        sweepAnimator.setDuration(mSweepAnimatorDuration);
        sweepAnimator.setRepeatMode(ValueAnimator.RESTART);
        sweepAnimator.setRepeatCount(ValueAnimator.INFINITE);
        sweepAnimator.setStartDelay(index * SWEEP_ANIMATOR_DELAY);
        sweepAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override//  w w  w  .j a v a2 s .com
            public void onAnimationUpdate(ValueAnimator animation) {
                mSpinners[index].sweepAngle = (float) animation.getAnimatedValue();
                mSpinners[index].updatePath();
                invalidateSelf();
            }
        });
        sweepAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationRepeat(Animator animation) {
                mSpinners[index].sweepAngleOffset = (mSpinners[index].sweepAngleOffset + MAX_SWEEP_ANGLE) % 360;
                mSpinners[index].updatePath();
            }
        });
        set.playTogether(sweepAnimator);
    }
    mSweepAnimator = set;

    mAngleAnimator = ValueAnimator.ofFloat(0, 360);
    mAngleAnimator.setInterpolator(ANGLE_ANIMATOR_INTERPOLATOR);
    mAngleAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mAngleAnimator.setRepeatMode(ValueAnimator.RESTART);
    mAngleAnimator.setDuration(ANGLE_ANIMATOR_DURATION);
    mAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mGlobalAngle = (float) animation.getAnimatedValue();
            updatePath();
            invalidateSelf();
        }
    });
}

From source file:net.margaritov.preference.colorpicker.ColorPickerDialog.java

private ValueAnimator createAlphaAnimator(int start, int end) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);

    animator.setDuration(500);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from  w ww. j  av  a  2s. com*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int value = (Integer) valueAnimator.getAnimatedValue();
            float currentAlpha = value / 100f;
            mActionBarMain.setAlpha(1f - currentAlpha);
            mActionBarEditHex.setAlpha(currentAlpha);
            mDivider.setAlpha(currentAlpha);
        }
    });
    if (mHideEditHexBar) {
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                mActionBarMain.setVisibility(View.VISIBLE);
                ViewCompat.jumpDrawablesToCurrentState(mActionBarMain);
            }
        });
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mActionBarEditHex.setVisibility(View.GONE);
                mDivider.setVisibility(View.GONE);
            }
        });
    } else {
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                mActionBarEditHex.setVisibility(View.VISIBLE);
                ViewCompat.jumpDrawablesToCurrentState(mActionBarEditHex);
                mDivider.setVisibility(View.VISIBLE);
            }
        });
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mActionBarMain.setVisibility(View.GONE);
            }
        });
    }
    return animator;
}

From source file:cn.com.hgh.view.SlideSwitch.java

public void moveToDest(final boolean toRight) {
    ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left);
    toDestAnim.setDuration(500);
    toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    //      toDestAnim.start();
    toDestAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override/*from  w ww  .  ja v a  2  s. c  om*/
        public void onAnimationUpdate(ValueAnimator animation) {
            //            frontRect_left = (Integer) animation.getAnimatedValue();
            //            alpha = (int) (255 * (float) frontRect_left / (float) max_left);
            //            invalidateView();
        }
    });
    toDestAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null)
                    listener.open();
                frontRect_left_begin = max_left;
            } else {
                isOpen = false;
                if (listener != null)
                    listener.close();
                frontRect_left_begin = min_left;
            }

        }
    });
}