Example usage for android.animation ObjectAnimator setInterpolator

List of usage examples for android.animation ObjectAnimator setInterpolator

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setInterpolator.

Prototype

@Override
public void setInterpolator(TimeInterpolator value) 

Source Link

Document

The time interpolator used in calculating the elapsed fraction of this animation.

Usage

From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java

@Override
public void show() {
    super.show();
    int rootWidth = getRootView().getWidth();
    float endFabX;

    if (getFab().getLeft() > rootWidth / 2f) {
        endFabX = getFab().getLeft() - getFab().getWidth();
    } else {//from  w ww.j a v  a2 s. c  o  m
        endFabX = getFab().getLeft() + getFab().getWidth();
    }

    PropertyValuesHolder xProperty = PropertyValuesHolder.ofFloat(View.X, endFabX);
    PropertyValuesHolder yProperty = PropertyValuesHolder.ofFloat(View.Y, getFloatingToolbar().getY() * 0.95f);
    PropertyValuesHolder scaleXProperty = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
    PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getFab(), xProperty, yProperty,
            scaleXProperty, scaleYProperty);
    animator.setDuration(FAB_MORPH_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();

    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(getFloatingToolbar(), "scaleX", 1f);
    objectAnimator.setDuration(CIRCULAR_REVEAL_DURATION);
    objectAnimator.setStartDelay(CIRCULAR_REVEAL_DELAY);
    objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    objectAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            getFloatingToolbar().setVisibility(View.VISIBLE);
            getFab().setVisibility(View.INVISIBLE);
        }
    });
    objectAnimator.start();
}

From source file:com.imczy.customactivitytransition.transition.ShareElemReturnChangePosition.java

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (null == startValues || null == endValues) {
        return null;
    }/*from   w w w  .  j  ava 2  s .  c o m*/

    if (startValues.view.getId() > 0) {
        Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION);
        Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION);

        final View view = endValues.view;

        Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(),
                endRect.centerX(), endRect.centerY() - endRect.height() / 2);

        ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, new PropPosition(PointF.class, "position",
                new PointF(startRect.centerX(), startRect.centerY())), null, changePosPath);
        objectAnimator.setInterpolator(new FastOutSlowInInterpolator());

        return objectAnimator;
    }
    return null;

}

From source file:es.wolfi.app.passman.CredentialDisplay.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        Vault v = (Vault) SingleTon.getTon().getExtra(SettingValues.ACTIVE_VAULT.toString());
        credential = v.findCredentialByGUID(getArguments().getString(CREDENTIAL));
    }/*from   ww w  . j  a v a 2s.  c  om*/

    handler = new Handler();
    otp_refresh = new Runnable() {
        @Override
        public void run() {
            int progress = (int) (System.currentTimeMillis() / 1000) % 30;
            otp_progress.setProgress(progress * 100);

            ObjectAnimator animation = ObjectAnimator.ofInt(otp_progress, "progress", (progress + 1) * 100);
            animation.setDuration(1000);
            animation.setInterpolator(new LinearInterpolator());
            animation.start();

            otp.setText(TOTPHelper.generate(new Base32().decode(credential.getOtp())));
            handler.postDelayed(this, 1000);
        }
    };
}

From source file:com.h6ah4i.android.example.materialshadowninepatch.ZPositionAnimationDemoFragment.java

@Override
public void onClick(View v) {
    if (v == mCompatShadowItem) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(mCompatShadowItemContainer,
                MaterialShadowContainerViewProperties.SHADOW_TRANSLATION_Z, mDisplayDensity * 0.0f,
                mDisplayDensity * 8.0f);
        animator.setDuration(500);/*from   w  ww.  ja  v  a2 s. c o  m*/
        animator.setInterpolator(new CycleInterpolator(0.5f));
        animator.start();
    }
}

From source file:com.stepstone.stepper.internal.widget.ColorableProgressBar.java

public void setProgressCompat(int progress, boolean animate) {
    if (animate) {
        final ObjectAnimator animator = ObjectAnimator.ofInt(this, PROGRESS_PROPERTY, getProgress(),
                progress * PROGRESS_RANGE_MULTIPLIER);
        animator.setDuration(PROGRESS_ANIM_DURATION);
        animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
        animator.start();/*  w w  w.  j a va 2s.co m*/
    } else {
        setProgress(progress * PROGRESS_RANGE_MULTIPLIER);
    }

}

From source file:com.imczy.customactivitytransition.transition.ChangePosition.java

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (null == startValues || null == endValues) {
        return null;
    }/*from w  w w  .ja  v  a 2s.  c om*/

    if (startValues.view.getId() > 0) {
        Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION);
        Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION);

        final View view = endValues.view;

        Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(),
                endRect.centerX(), endRect.centerY());

        int radius = startRect.centerY() - endRect.centerY();

        ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view,
                new PropPosition(PointF.class, "position", new PointF(endRect.centerX(), endRect.centerY())),
                null, changePosPath);
        objectAnimator.setInterpolator(new FastOutSlowInInterpolator());

        return objectAnimator;
    }
    return null;

}

From source file:com.zandbee.floatingtitlebar.FloatingTitleBarActivity.java

@Override
public void onScrollChanged(int deltaX, int deltaY) {
    final int scrollY = scrollView.getScrollY();

    /** title is going up and has not yet collided with a toolbar */
    if (getLocationYonScreen(bodyLayout) <= (toolbarHeight + titleViewHeight)) {
        titleLayout.setTranslationY(scrollY);
        quasiFab.setTranslationY(scrollY + toolbarHeight + titleViewHeight - quasiFabCenterHeight);

        // TODO try without delta
        if (!titleInUpperPosition
        //&& deltaY > 0
        ) {/*from ww  w  . j  a  va  2 s.  com*/
            titleInUpperPosition = true;
            final ObjectAnimator animPd = ObjectAnimator.ofFloat(titleBackDrawable, "progress",
                    titleBackDrawable.max - titleViewHeight, 0f);
            animPd.setInterpolator(new DecelerateInterpolator(2f));
            animPd.setDuration(200).start();
        }
    }

    /** title is going down */
    if (titleInUpperPosition && getLocationYonScreen(titleView) > toolbarHeight
    // + getLocationYonScreen(toolbar)
            && deltaY < 0) {
        titleInUpperPosition = false;
        final ObjectAnimator animPd = ObjectAnimator.ofFloat(titleBackDrawable, "progress", 0f,
                titleBackDrawable.max - titleViewHeight);
        animPd.setInterpolator(new AccelerateDecelerateInterpolator());
        animPd.setDuration(250).start();
    }

    imageView.setTranslationY(scrollY * 0.5f);
}

From source file:com.google.android.apps.muzei.util.AnimatedMuzeiLogoFragment.java

@Override
public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) {
    mSubtitleView = view.findViewById(R.id.logo_subtitle);

    mLogoView = (AnimatedMuzeiLogoView) view.findViewById(R.id.animated_logo);
    mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() {
        @Override/*from w  ww.j a  v  a  2 s . c om*/
        public void onStateChange(int state) {
            if (state == AnimatedMuzeiLogoView.STATE_FILL_STARTED) {
                mSubtitleView.setAlpha(0);
                mSubtitleView.setVisibility(View.VISIBLE);
                mSubtitleView.setTranslationY(-mSubtitleView.getHeight());

                // Bug in older versions where set.setInterpolator didn't work
                AnimatorSet set = new AnimatorSet();
                Interpolator interpolator = new OvershootInterpolator();
                ObjectAnimator a1 = ObjectAnimator.ofFloat(mLogoView, View.TRANSLATION_Y, 0);
                ObjectAnimator a2 = ObjectAnimator.ofFloat(mSubtitleView, View.TRANSLATION_Y, 0);
                ObjectAnimator a3 = ObjectAnimator.ofFloat(mSubtitleView, View.ALPHA, 1);
                a1.setInterpolator(interpolator);
                a2.setInterpolator(interpolator);
                set.setDuration(500).playTogether(a1, a2, a3);
                set.start();

                if (mOnFillStartedCallback != null) {
                    mOnFillStartedCallback.run();
                }
            }
        }
    });
    if (savedInstanceState == null) {
        reset();
    }
}

From source file:com.gigigo.vuforiaimplementation.VuforiaActivity.java

private void startBoringAnimation() {
    scanLine.setVisibility(View.VISIBLE);
    // Create animators for y axe
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        int yMax = 0;
        yMax = getResources().getDisplayMetrics().heightPixels; //mVuforiaView.getDisplay().getHeight();
        yMax = (int) (yMax * 0.9);// 174;

        ObjectAnimator oay = ObjectAnimator.ofFloat(scanLine, "translationY", 0, yMax);
        oay.setRepeatCount(Animation.INFINITE);
        oay.setDuration(ANIM_DURATION);// w w  w .  ja va2  s .  c  om
        oay.setRepeatMode(Animation.REVERSE);

        oay.setInterpolator(new LinearInterpolator());
        oay.start();

        //for draw points near scanline
        markFakeFeaturePoint.setObjectAnimator(oay);
    }

    //scanAnimation.

}

From source file:com.example.google.maps.folding_map.MainActivity.java

public void animateFold() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldingLayout, "foldFactor",
            mFoldingLayout.getFoldFactor(), 1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(1);//w w w .j av a  2s  . c  om
    animator.setDuration(FOLD_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}