Code example for TimeAnimator

Methods: setTimeListener

0
            } 
 
            if (mAnim != null) {
                mAnim.cancel();
            } 
            mAnim = new TimeAnimator();
            mAnim.setTimeListener(new TimeAnimator.TimeListener() {
                private long lastPrint = 0;
                public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
                    if (DEBUG && totalTime - lastPrint > 5000) {
                        lastPrint = totalTime;
                        for (int i=0; i<getChildCount(); i++) {
                            android.util.Log.d("UnicornSack", "unicorn " + i + ": " + getChildAt(i));
                        } 
                    } 
 
                    for (int i=0; i<getChildCount(); i++) {
                        View v = getChildAt(i);
                        if (!(v instanceof Unicorn)) continue;
                        Unicorn nv = (Unicorn) v;
                        nv.update(deltaTime / 1000f);