Example usage for android.view.animation Interpolator Interpolator

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

Introduction

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

Prototype

Interpolator

Source Link

Usage

From source file:com.wordplat.ikvstockchart.InteractiveKLineView.java

public InteractiveKLineView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    viewRect = new RectF();
    viewPadding = ViewUtils.dpTopx(context, 10);

    render = new KLineRender(context);

    gestureDetector.setIsLongpressEnabled(true);

    int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    gestureCompat.setTouchSlop(touchSlop);

    final Interpolator interpolator = new Interpolator() {
        public float getInterpolation(float t) {
            t -= 1.0f;/*from  w  w w  . j av  a2s .c  om*/
            return t * t * t * t * t + 1.0f;
        }
    };

    scroller = ScrollerCompat.create(context, interpolator);

    render.setSizeColor(ViewUtils.getSizeColor(context, attrs, defStyleAttr));
}

From source file:com.bq.robotic.robopad.RoboPad.java

/**
 * Change the visibility of some views as the connect/disconnect button depending on the
 * bluetooth connection state The state of the bluetooth connection
 *
 * @param connectionState the state of the current bluetooth connection
 *//*from w  w  w  . ja v a 2s  . c o  m*/
private void changeViewsVisibility(int connectionState) {

    switch (connectionState) {

    case Droid2InoConstants.STATE_CONNECTED:
        findViewById(R.id.bluetooth_spinner_view).setVisibility(View.INVISIBLE);
        findViewById(R.id.bluetooth_spinner_view).clearAnimation();

        connectButton.setVisibility(View.GONE);
        disconnectButton.setVisibility(View.VISIBLE);
        break;

    case Droid2InoConstants.STATE_CONNECTING:

        if (anim != null) {
            anim.setInterpolator(new Interpolator() {
                private final int frameCount = 8;

                @Override
                public float getInterpolation(float input) {
                    return (float) Math.floor(input * frameCount) / frameCount;
                }
            });

            findViewById(R.id.bluetooth_spinner_view).setVisibility(View.VISIBLE);
            findViewById(R.id.bluetooth_spinner_view).startAnimation(anim);
        } else {
            Log.e(LOG_TAG, "Anim null!!!");
        }

        break;

    case Droid2InoConstants.STATE_LISTEN:
    case Droid2InoConstants.STATE_NONE:
        findViewById(R.id.bluetooth_spinner_view).setVisibility(View.INVISIBLE);
        findViewById(R.id.bluetooth_spinner_view).clearAnimation();

        connectButton.setVisibility(View.VISIBLE);
        disconnectButton.setVisibility(View.GONE);

        break;
    }
}