animations

32 views
Skip to first unread message

Chris Blume

unread,
Jul 19, 2013, 5:45:12 PM7/19/13
to android...@googlegroups.com
I have a STITCHed listview where one element is supposed to be an animation.
It is a loading indicator. Once loaded, I populate an ArrayListObservable and hide the animation.
At least, that was the idea.

For normal animations, I need to get access to the drawable (normally by findViewById) and call .start() on that AnimationDrawable.
But I'm not sure I am able to use findViewById to get the element inside this listview, can I?

How do you suggest I have an animated item inside the listview?

Thanks!

Andy Tsui

unread,
Jul 19, 2013, 9:40:00 PM7/19/13
to android...@googlegroups.com
Auto start animation is not yet implemented. But I think it's achievable, please refer to the AFTERCOMMAND to how to trigger the animation:


Andy

--
You received this message because you are subscribed to the Google Groups "AndroidBinding" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbindin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Blume

unread,
Jul 20, 2013, 6:55:34 AM7/20/13
to android...@googlegroups.com
I appreciate the help.

I'm not sure I follow. I'm unsure how to have an AFTERCOMMAND auto-fire.
Additionally, is this only for those transition-type animations like the nods and shakes? I am looking for something for the animation-list so my loading indicator can show its spinning animation.

(PS I apologize for double-posting two questions. I had checked back and was under the impression they didn't get sent for some reason. I had asked from another email address.)

Thanks again.

Andy Tsui

unread,
Jul 20, 2013, 8:18:15 AM7/20/13
to android...@googlegroups.com
I have to apologize that Animation is not full documented and developed (mainly due to lack of feedback from users :)

Currently, the binding:animation will make something I called "animation trigger" which contains a "fire" method. I am thinking a custom converter, which auto trigger the "fire" when it is created, could make what you needed. 

Andy

Chris Blume

unread,
Jul 20, 2013, 5:53:00 PM7/20/13
to android...@googlegroups.com
I will research the custom converter triggering the fire when created....but I will do it once I get home tonight.
Would that be fairly well documented? Is it something you could provide a quick snippet for and I can figure out the rest? (IE just point me in the right direction? Is "custom converter" + "fire method" enough pointing?)

Thanks again for everything. A-B is really great and I'm glad you're here, helping us all with it.

Andy Tsui

unread,
Jul 24, 2013, 11:57:58 PM7/24/13
to android...@googlegroups.com
I think animation trigger is the key. 

Yeah, if I have time I will write more articles/documents on those. 

Andy Tsui

unread,
Jul 25, 2013, 10:30:50 PM7/25/13
to android...@googlegroups.com
Hi,

I haven't experiment if this works, but I think you may modify this:


in the calculateValue method:


@Override
public AnimationTrigger calculateValue(Object... args) throws Exception {
if (args.length<2) return null;
if (!(args[0] instanceof Integer)){
return null;
}
mTrigger.setAnimationId((Integer)args[0]);
mTrigger.notifyAnimationFire();

return mTrigger;
}

It should fire the animation automatically once it is binded to the view.

Chris Blume

unread,
Aug 5, 2013, 4:23:17 PM8/5/13
to android...@googlegroups.com
I don't understand how to use AFTERCOMMAND for an onLoad-type event.
But I found a work-around.
It is a bad work-around...it isn't very cool...but it at least works.

I have this:

public class LoadingIndicatorModel {
public final Observable LoadingImage = new Observable(Drawable.class);
private final int TOTAL_STEPS = 16;
private Thread LoadingThread;

public LoadingIndicatorModel(final Activity context) {
LoadingThread = new Thread(new Runnable() {
private int Step;

@Override
public void run() {
Step = 0;
while (context != null) {
try {
updateLoadingImage(context, getImageId(Step));
Step++;
if (Step == TOTAL_STEPS) {
Step = 0;
}
Thread.sleep(40);
} catch (InterruptedException e) {}
}
}
});
LoadingThread.start();
}

private int getImageId(int stepNumber) {
switch (stepNumber) {
case 0:
return R.drawable.load01;
case 1:
return R.drawable.load02;
case 2:
return R.drawable.load03;
case 3:
return R.drawable.load04;
case 4:
return R.drawable.load05;
case 5:
return R.drawable.load06;
case 6:
return R.drawable.load07;
case 7:
return R.drawable.load08;
case 8:
return R.drawable.load09;
case 9:
return R.drawable.load10;
case 10:
return R.drawable.load11;
case 11:
return R.drawable.load12;
case 12:
return R.drawable.load13;
case 13:
return R.drawable.load14;
case 14:
return R.drawable.load15;
default:
return R.drawable.load16;
}
}

private void updateLoadingImage(final Activity context, final int drawableId) {
context.runOnUiThread(new Runnable() {
@Override
public void run() {
LoadingImage.set(drawableId);
}
});
}
}

That lets me add an item to the list view via STITCHing and animate them. But it requires creating a thread and posting to the UI thread and...it's just not the preferred method. It basically mimics an animation-list and AnimationDrawable.start()

I would prefer to use the animation-list and be able to call AnimationDrawable.start(). Does the AFTERCOMMAND give me the ImageView somehow? I need to 1.) get access to the ImageView, and 2.) be able to trigger it when created/displayed

Andy Tsui

unread,
Aug 6, 2013, 11:18:12 AM8/6/13
to android...@googlegroups.com
no, Converter cannot directly get the ImageView. 

I am thinking a custom ViewAttribute would be much better, and it can give you access to ImageView

Andy
Reply all
Reply to author
Forward
0 new messages