Code example for TimeAnimator

Methods: setTimeListener, start

0
        // On JB, we rely on TimeAnimator to send events tied with vsync. 
        return new Runnable() {
            @Override 
            public void run() { 
                mTimeAnimator = new TimeAnimator();
                mTimeAnimator.setTimeListener(new TimeListener() {
                    @Override 
                    public void onTimeUpdate(TimeAnimator animation, long totalTime,
                            long deltaTime) {
                        if (!sendEvent(mDownTime + totalTime)) {
                            mTimeAnimator.end();
                        } 
                    } 
                }); 
                mTimeAnimator.start();
            } 
        }; 
    } 
 
    private Runnable createPreJBRunnable() {
        // Pre-JB there's no TimeAnimator, so we keep posting messages.