On 11 Lut, 19:21, momo <[email protected]> wrote:
> hey pskink,
>
> i tried that pure-Handler approach you first suggested, and it works a
> treat - in fact i was able to omit the delay entirely, just
> sendEmptyMessage (and use a simple time keeper class to determine the
> delta) - very smooth, very simple.  thanks a lot for your help.

glad to hear it, but if you have 10 minutes or so you could test
Animation based approach

see ViewGroup#drawChild(Canvas canvas, View child, long drawingTime)

what they do is more or less:

Animation a = child.getAnimation();
if (a != null) {
        // aha: we are animating the child
        more = a.getTransformation(drawingTime, mChildTransformation);
        if (more) {
                invalidate();
        }
}

child.draw(canvas);

if (a != null && !more) {
        finishAnimatingView(child, a);
}


so you could do similar thing in your onDraw method:

// no other anims so force cast
MyAnim a = (MyAnim) getAnimation();
if (a != null) {
        // we can pass null Transormation: we dont use it in
MyAnim#applyTransformation
        more = a.getTransformation(drawingTime, null);
        if (more) {
                float interpolatedTime = a.mTime;
                // draw animation frame based on interpolatedTime
                ...
        }
}


where MyAnim is as follows:

class MyAnim extends Animation {
        float mTime;
        protected void applyTransformation(float interpolatedTime,
Transformation t) {
                mTime = interpolatedTime;
        }
}

pskink

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to