7 messages in com.googlegroups.android-developersRe: [android-developers] Re: Another ...| From | Sent On | Attachments |
|---|---|---|
| Rui Martins | 25 Feb 2008 17:18 | |
| Romain Guy | 25 Feb 2008 17:27 | |
| Rui Martins | 25 Feb 2008 21:37 | |
| Romain Guy | 25 Feb 2008 22:03 | |
| Rui Martins | 26 Feb 2008 06:52 | |
| Romain Guy | 26 Feb 2008 08:20 | |
| Rui Martins | 27 Feb 2008 03:22 |
| Subject: | Re: [android-developers] Re: Another Animation Bug!?![]() |
|---|---|
| From: | Romain Guy (roma...@google.com) |
| Date: | 02/25/2008 10:03:33 PM |
| List: | com.googlegroups.android-developers |
Maybe what is missing is explaining in the Animation documentation, a simple flow of how to use an animation, so that we don't miss these small details. Something like a context introduction, like there is in Activity for example.
It's pretty simple: just call startAnimation(Animation) on a View. There are several examples of this in the ApiDemos.
You don't have to allocate a new transformation on every draw.
Really ? What should I use a Global Object ?
Just a field in your class:
private Transformation mTransformation = new Transformation();
protected void onDraw(Canvas c) { // ... animation.getTransformation(mTransformation); }
Exactly, for each new call to onDraw we allocate a new Transformation And then copy each specific transform into it, one at a time (calling getTransformation(...)), so that we can use it to draw on canvas. But to do that, we need to extract the Matrix from it.
You don't neet to allocate a new Transformation. As I said, the framework currently uses only *one* Transformation to animate a indefinite number of children.
We can't use that transformation directly, we have to extract the Matrix, so that we can use it. That is another (unrequired) copy.
No there is no copy. The animation just sets the value of the Transformation's Matrix and the drawing code just reads the Matrix.
mobile each extra object or copy takes valuable CPU/time resources. So the API should be done in such a way to avoid extra allocations and to avoid copys.
We know this and that's why no copy or allocation is required.
-- Romain Guy www.curious-creature.org




