Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator.

Prototype

public DecelerateInterpolator() 

Source Link

Usage

From source file:com.github.jorgecastillo.FillableLoader.java

private void init() {
    drawingState = State.NOT_STARTED;

    initDashPaint();/*w w  w .ja v  a2s.co  m*/
    initFillPaint();

    animInterpolator = new DecelerateInterpolator();
    setLayerType(LAYER_TYPE_SOFTWARE, null);
}

From source file:com.liuguangqiang.ripplelayout.sample.TargetActivity.java

private void startOutAnimation() {
    layoutTop.animate().translationY(-layoutTop.getHeight()).alpha(0.0f).setDuration(400)
            .setInterpolator(new DecelerateInterpolator());

    layoutBottom.animate().translationY(layoutBottom.getHeight()).alpha(0.0f).setDuration(400)
            .setInterpolator(new DecelerateInterpolator());
}

From source file:com.woxthebox.draglistview.DragItem.java

void startDrag(View startFromView, float touchX, float touchY) {
    show();/*from  w w  w  .j av  a  2s .  c o m*/
    onBindDragView(startFromView, mDragView);
    onMeasureDragView(startFromView, mDragView);
    onStartDragAnimation(mDragView);

    float startX = ViewCompat.getX(startFromView)
            - (mDragView.getMeasuredWidth() - startFromView.getMeasuredWidth()) / 2
            + mDragView.getMeasuredWidth() / 2;
    float startY = ViewCompat.getY(startFromView)
            - (mDragView.getMeasuredHeight() - startFromView.getMeasuredHeight()) / 2
            + mDragView.getMeasuredHeight() / 2;

    if (mSnapToTouch) {
        mPosTouchDx = 0;
        mPosTouchDy = 0;
        setPosition(touchX, touchY);
        setAnimationDx(startX - touchX);
        setAnimationDY(startY - touchY);

        PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("AnimationDx", mAnimationDx, 0);
        PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("AnimationDY", mAnimationDy, 0);
        ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(this, pvhX, pvhY);
        anim.setInterpolator(new DecelerateInterpolator());
        anim.setDuration(ANIMATION_DURATION);
        anim.start();
    } else {
        mPosTouchDx = startX - touchX;
        mPosTouchDy = startY - touchY;
        setPosition(touchX, touchY);
    }
}

From source file:com.softminds.matrixcalculator.base_activities.faqs.java

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
    case MotionEvent.ACTION_DOWN:
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20);
        animator.setDuration(200);/*from   w ww  . ja  v  a  2 s  .co m*/
        animator.setInterpolator(new DecelerateInterpolator());
        animator.start();
        view.performClick();
        return true;
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationZ", 0);
        animator2.setDuration(200);
        animator2.setInterpolator(new AccelerateInterpolator());
        animator2.start();
        return true;
    default:
        return false;
    }
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * Second part of the click animation./*from   w  w  w  . j a va  2  s .  co m*/
 *
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimUp(View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = root.findViewById(R.id.rect_view_id);
    if (rectView != null) {
        AlphaAnimation rectAnim = new AlphaAnimation(0.4f, 0f);
        rectAnim.setFillAfter(true);
        rectAnim.setInterpolator(new DecelerateInterpolator());
        rectAnim.setDuration(150);
        rectAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        ViewGroup parent = (ViewGroup) rectView.getParent();
                        rectView.setVisibility(View.GONE);
                        if (parent != null)
                            parent.removeView(rectView);
                    }
                });
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        rectView.clearAnimation();
        rectView.startAnimation(rectAnim);
    }
}

From source file:com.example.android.animationsdemo.MainActivity.java

private void setViewPagerAnimationSpeed() {
    try {/* w ww.j a  v  a2 s. c  o  m*/
        Field mScroller;
        mScroller = ViewPager.class.getDeclaredField("mScroller");
        mScroller.setAccessible(true);
        Interpolator sInterpolator = new DecelerateInterpolator();
        FixedSpeedScroller scroller = new FixedSpeedScroller(pager.getContext(), sInterpolator);
        // scroller.setFixedDuration(5000);
        mScroller.set(pager, scroller);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
    }
}

From source file:com.woxthebox.draglistview.DragItem.java

void endDrag(View endToView, AnimatorListenerAdapter listener) {
    onEndDragAnimation(mDragView);//w ww .j ava  2s  . c om

    float endX = ViewCompat.getX(endToView) - (mDragView.getMeasuredWidth() - endToView.getMeasuredWidth()) / 2
            + mDragView.getMeasuredWidth() / 2;
    float endY = ViewCompat.getY(endToView)
            - (mDragView.getMeasuredHeight() - endToView.getMeasuredHeight()) / 2
            + mDragView.getMeasuredHeight() / 2;
    PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("X", mPosX, endX);
    PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("Y", mPosY, endY);
    ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(this, pvhX, pvhY);
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(ANIMATION_DURATION);
    anim.addListener(listener);
    anim.start();
}

From source file:com.fastbootmobile.encore.app.ArtistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artist);

    mHandler = new Handler();

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT);

    if (savedInstanceState == null) {
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = getIntent().getExtras();
    } else {//  w  ww  .  ja  v  a  2s  . c  o m
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new ArtistFragment();
        fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit();
    }

    mActiveFragment.setArguments(mHero, mInitialIntent);

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View fab = mActiveFragment.findViewById(R.id.fabPlay);
                fab.setVisibility(View.VISIBLE);

                // get the center for the clipping circle
                int cx = fab.getMeasuredWidth() / 2;
                int cy = fab.getMeasuredHeight() / 2;

                // get the final radius for the clipping circle
                final int finalRadius = fab.getWidth();

                // create and start the animator for this view
                // (the start radius is zero)
                Animator anim;
                if (mIsEntering) {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius);
                } else {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0);
                }
                anim.setInterpolator(new DecelerateInterpolator());
                anim.start();

                fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f);
                fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f);
                fab.animate().translationX(0.0f).translationY(0.0f)
                        .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime))
                        .setInterpolator(new DecelerateInterpolator()).start();

                final View artistName = mActiveFragment.findViewById(R.id.tvArtist);
                if (artistName != null) {
                    cx = artistName.getMeasuredWidth() / 4;
                    cy = artistName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy);

                    if (mIsEntering) {
                        artistName.setVisibility(View.INVISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300);
                    } else {
                        artistName.setVisibility(View.VISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0);
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:pl.mg6.android.maps.extensions.demo.AnimateMarkersActivity.java

private Interpolator randomInterpolator() {
    int val = random.nextInt(14);
    switch (val) {
    case 0:/*  w w w . j a  v a 2  s.c o  m*/
        return new LinearInterpolator();
    case 1:
        return new AccelerateDecelerateInterpolator();
    case 2:
        return new AccelerateInterpolator();
    case 3:
        return new AccelerateInterpolator(6.0f);
    case 4:
        return new DecelerateInterpolator();
    case 5:
        return new DecelerateInterpolator(6.0f);
    case 6:
        return new BounceInterpolator();
    case 7:
        return new AnticipateOvershootInterpolator();
    case 8:
        return new AnticipateOvershootInterpolator(6.0f);
    case 9:
        return new AnticipateInterpolator();
    case 10:
        return new AnticipateInterpolator(6.0f);
    case 11:
        return new OvershootInterpolator();
    case 12:
        return new OvershootInterpolator(6.0f);
    case 13:
        return new CycleInterpolator(1.25f);
    }
    throw new RuntimeException();
}

From source file:com.oceansky.yellow.app.ArtistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artist);

    mHandler = new Handler();

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT);

    if (savedInstanceState == null) {
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = getIntent().getExtras();
    } else {/* w ww .  j a v a 2 s  .com*/
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new ArtistFragment();
        fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit();
    }

    try {
        mActiveFragment.setArguments(mHero, mInitialIntent);
    } catch (IllegalStateException e) {
        Log.e(TAG, "Invalid artist!", e);
    }

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View fab = mActiveFragment.findViewById(R.id.fabPlay);
                fab.setVisibility(View.VISIBLE);

                // get the center for the clipping circle
                int cx = fab.getMeasuredWidth() / 2;
                int cy = fab.getMeasuredHeight() / 2;

                // get the final radius for the clipping circle
                final int finalRadius = fab.getWidth();

                // create and start the animator for this view
                // (the start radius is zero)
                Animator anim;
                if (mIsEntering) {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius);
                } else {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0);
                }
                anim.setInterpolator(new DecelerateInterpolator());
                anim.start();

                fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f);
                fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f);
                fab.animate().translationX(0.0f).translationY(0.0f)
                        .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime))
                        .setInterpolator(new DecelerateInterpolator()).start();

                final View artistName = mActiveFragment.findViewById(R.id.tvArtist);
                if (artistName != null) {
                    cx = artistName.getMeasuredWidth() / 4;
                    cy = artistName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy);

                    if (mIsEntering) {
                        artistName.setVisibility(View.INVISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300);
                    } else {
                        artistName.setVisibility(View.VISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0);
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}