Example usage for android.view.animation TranslateAnimation startNow

List of usage examples for android.view.animation TranslateAnimation startNow

Introduction

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

Prototype

public void startNow() 

Source Link

Document

Convenience method to start the animation at the current time in milliseconds.

Usage

From source file:us.shandian.blacklight.ui.statuses.TimeLineFragment.java

@Override
public boolean onTouch(View v, MotionEvent ev) {

    switch (ev.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        mLastY = ev.getY();/*from  w  w w  .  j  av  a2  s. co  m*/
        break;
    case MotionEvent.ACTION_MOVE:
        if (mLastY == -1.0f)
            break;

        float y = ev.getY();

        if (!mNewHidden && y < mLastY) {
            mNew.clearAnimation();

            TranslateAnimation anim = new TranslateAnimation(0, 0, 0, mList.getHeight() - mNew.getTop());
            anim.setFillAfter(true);
            anim.setDuration(400);

            mNew.setAnimation(anim);
            anim.startNow();

            mNewHidden = true;
        } else if (mNewHidden && y > mLastY) {
            mNew.clearAnimation();

            TranslateAnimation anim = new TranslateAnimation(0, 0, mList.getHeight() - mNew.getTop(), 0);
            anim.setFillAfter(true);
            anim.setDuration(400);

            mNew.setAnimation(anim);
            anim.startNow();

            mNewHidden = false;
        }

        mLastY = y;
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        mLastY = -1.0f;
        break;
    }

    return false;
}