Example usage for android.view.animation BounceInterpolator BounceInterpolator

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

Introduction

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

Prototype

public BounceInterpolator() 

Source Link

Usage

From source file:Main.java

/**
 *    move the background view(translate animation).
 * //from  ww w  . j a va 2  s .  c  o m
 * @param view
 *          the view will be moved
 * @param durationMillis
 *          translate animation duration
 * @param fromX
 *          from X coordinate
 * @param toX
 *          to X coordinate
 * @param fromY
 *          from Y coordinate
 * @param toY
 *          to Y coordinate
 */
public static void translateFromAbove(final Context context, final View view, final long durationMillis,
        boolean fillAfter, float fromX, float toX, final float fromY, final float toY) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromX, toX, fromY, toY + 5);
    translateAnimation.setInterpolator(new BounceInterpolator());
    translateAnimation.setDuration(durationMillis);
    translateAnimation.setFillAfter(fillAfter);//this animation performed will persist when it is finished
    view.startAnimation(translateAnimation);
}

From source file:com.marshalchen.ultimaterecyclerview.animators.BounceInAnimator.java

@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
    ViewCompat.animate(holder.itemView).alpha(1).setDuration(getAddDuration())
            .setListener(new DefaultAddVpaListener(holder)).setInterpolator(new BounceInterpolator()).start();
    mAddAnimations.add(holder);//w w w. jav a  2  s  .c o m
}

From source file:com.bobomee.android.navigator.expandable.Utils.java

/**
 * Creates interpolator./*from  w  w  w. j  a v  a  2  s . c o  m*/
 * @return  a timeinterpolator
 * @param interpolatorType a int value from 0 to 10
 */
public static TimeInterpolator createInterpolator(@IntRange(from = 0, to = 10) final int interpolatorType) {
    switch (interpolatorType) {
    case ACCELERATE_DECELERATE_INTERPOLATOR:
        return new AccelerateDecelerateInterpolator();
    case ACCELERATE_INTERPOLATOR:
        return new AccelerateInterpolator();
    case ANTICIPATE_INTERPOLATOR:
        return new AnticipateInterpolator();
    case ANTICIPATE_OVERSHOOT_INTERPOLATOR:
        return new AnticipateOvershootInterpolator();
    case BOUNCE_INTERPOLATOR:
        return new BounceInterpolator();
    case DECELERATE_INTERPOLATOR:
        return new DecelerateInterpolator();
    case FAST_OUT_LINEAR_IN_INTERPOLATOR:
        return new FastOutLinearInInterpolator();
    case FAST_OUT_SLOW_IN_INTERPOLATOR:
        return new FastOutSlowInInterpolator();
    case LINEAR_INTERPOLATOR:
        return new LinearInterpolator();
    case LINEAR_OUT_SLOW_IN_INTERPOLATOR:
        return new LinearOutSlowInInterpolator();
    case OVERSHOOT_INTERPOLATOR:
        return new OvershootInterpolator();
    default:
        return new LinearInterpolator();
    }
}

From source file:co.uk.aging.mabel.places.placepicker.cardstream.CardActionButton.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: {
        setPressed(true);//from  w  ww. j  a va 2 s  . c om
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            animate().scaleX(0.98f).scaleY(0.98f).setDuration(100)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            ViewCompat.setElevation(this, 8.f);
        }
        break;
    }
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL: {
        setPressed(false);
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            animate().scaleX(1.f).scaleY(1.f).setDuration(50).setInterpolator(new BounceInterpolator());
        } else {
            ViewCompat.setElevation(this, 0.f);
        }
        break;
    }
    }

    return super.onTouchEvent(event);
}

From source file:cardstream.CardActionButton.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: {
        setPressed(true);// w  w w .j av a 2s  .  c o m
        Log.d("", "click");
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            animate().scaleX(0.98f).scaleY(0.98f).setDuration(100)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            ViewCompat.setElevation(this, 8.f);
        }
        break;
    }
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL: {
        setPressed(false);
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            animate().scaleX(1.f).scaleY(1.f).setDuration(50).setInterpolator(new BounceInterpolator());
        } else {
            ViewCompat.setElevation(this, 0.f);
        }
        break;
    }
    }

    return super.onTouchEvent(event);
}

From source file:com.tubb.smrv.demo.GridRvActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    mContext = this;
    users = getUsers();//from www  .  j a  va 2 s . c  o  m
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show();
            swipeRefreshLayout.setRefreshing(false);
        }
    });
    mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView);
    mRecyclerView.addItemDecoration(new GridSpaceItemDecoration(3, 3));
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    mRecyclerView.setOpenInterpolator(new BounceInterpolator());
    mRecyclerView.setCloseInterpolator(new BounceInterpolator());
    mAdapter = new AppAdapter(this, users);
    mRecyclerView.setAdapter(mAdapter);
}

From source file:com.tubb.smrv.demo.DifferentRvActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    mContext = this;
    users = getUsers();/*from w  w w. j  a  va2  s  . c  om*/
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show();
            swipeRefreshLayout.setRefreshing(false);
        }
    });
    mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    // interpolator setting
    mRecyclerView.setOpenInterpolator(new BounceInterpolator());
    mRecyclerView.setCloseInterpolator(new BounceInterpolator());
    mAdapter = new AppAdapter(this, users);
    mRecyclerView.setAdapter(mAdapter);
}

From source file:com.tubb.smrv.demo.SimpleRvActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    mContext = this;
    users = getUsers();//from ww  w .  j  a  v a2  s . c  o  m
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show();
            swipeRefreshLayout.setRefreshing(false);
        }
    });
    mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView);
    mRecyclerView.addItemDecoration(new VerticalSpaceItemDecoration(3));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    // interpolator setting
    mRecyclerView.setOpenInterpolator(new BounceInterpolator());
    mRecyclerView.setCloseInterpolator(new BounceInterpolator());
    mAdapter = new AppAdapter(this, users);
    mRecyclerView.setAdapter(mAdapter);
}

From source file:com.savvasdalkitsis.betwixt.Interpolators.java

/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * An interpolator where the change bounces at the end.
 *//*  w w w  . jav a 2  s . c  o  m*/
@NonNull
public static Interpolator bounce() {
    return new BounceInterpolator();
}

From source file:com.tubb.smrv.demo.StaggeredGridRvActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    mContext = this;
    users = getUsers();//from   w  w w .j  av  a 2  s .  c o m
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Toast.makeText(mContext, "Refresh success", Toast.LENGTH_LONG).show();
            swipeRefreshLayout.setRefreshing(false);
        }
    });
    mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.listView);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.addItemDecoration(new StaggeredSpaceItemDecoration(15, 0, 15, 45));
    // interpolator setting
    mRecyclerView.setOpenInterpolator(new BounceInterpolator());
    mRecyclerView.setCloseInterpolator(new BounceInterpolator());
    mAdapter = new AppAdapter(this, users);
    mRecyclerView.setAdapter(mAdapter);
}