B4A Library NineOldAndroids

This is my version of the NineOldAndroids lib for B4A. It's free and provided with the Java source code.

This library offers more possibilities of animation than AnimationPlus (rotation or translation on more than one axis for 3D effect, animation step by step with events for each step, synchronization between animations, ability to change the view size and contents during the animation, etc.).

It works with all versions of Android >= 2 and with all views, even custom ones.

v0.92: Initial release.
v0.92b: I changed the package name and repackaged the source to ease its compilation.
v0.93: I fixed a bug in noaObjectAnimator.InitializeFloat.
 

Attachments

  • NineOldAndroids v0.93.zip
    328 KB · Views: 1,842
  • BasicTranslationExample.zip
    6.8 KB · Views: 847
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Do you mean I have to create a new animation, adding getTranslationX?

Yes, this works:
B4X:
mCurrX = mnoaViewHelper.getTranslationX(ImageView1)
mCurrY = mnoaViewHelper.getTranslationY(ImageView1)
mnoaAnimTranslX.InitializeFloat(ImageView1, mnoaAnimTranslX.PROPERTY_TRANSLATION_X, mCurrX, mCurrX + 200dip, "animX")
mnoaAnimTranslY.InitializeFloat(ImageView1, mnoaAnimTranslY.PROPERTY_TRANSLATION_Y, mCurrY, mCurrY + 100dip, "animY")
mAnimatorSet.Start

but then there are 3 views in the activity. Each animation adds a new view.
 

Informatix

Expert
Licensed User
Longtime User
Yes, this works:
B4X:
mCurrX = mnoaViewHelper.getTranslationX(ImageView1)
mCurrY = mnoaViewHelper.getTranslationY(ImageView1)
mnoaAnimTranslX.InitializeFloat(ImageView1, mnoaAnimTranslX.PROPERTY_TRANSLATION_X, mCurrX, mCurrX + 200dip, "animX")
mnoaAnimTranslY.InitializeFloat(ImageView1, mnoaAnimTranslY.PROPERTY_TRANSLATION_Y, mCurrY, mCurrY + 100dip, "animY")
mAnimatorSet.Start

but then there are 3 views in the activity. Each animation adds a new view.
NoA does not add any view.
 

ArminKH

Well-Known Member
hi @Informatix
i have 2 animation(Alpha and Scale) which are played together by using noaAnimatorSet and it's okay
but i have a problem
when (Private NOA_AS As noaAnimatorSet) is decleared at Class_Globals then this variable(NOA_AS) just works for 1 time
in other word my animations are started then played and at last finished then all animations come back to their default value by Reverse
but when next time i want to play again this animations together by NOA_AS this error printed in the log windows
upload_2016-3-7_15-1-54.png


i have not any problem when NOA_AS is dimmed again but what is this? it's a bug? or is how this lib works?
 

Informatix

Expert
Licensed User
Longtime User
hi @Informatix
i have 2 animation(Alpha and Scale) which are played together by using noaAnimatorSet and it's okay
but i have a problem
when (Private NOA_AS As noaAnimatorSet) is decleared at Class_Globals then this variable(NOA_AS) just works for 1 time
in other word my animations are started then played and at last finished but when next time i want to play again this animations together by NOA_AS this error printed in the log windows
View attachment 42234

i have not any problem when NOA_AS is dimmed again but what is this? it's a bug? or is how this lib works?
Difficult to say without the code. But according to the error, it seems you add animations to the same already existing animations, which creates a circular dependency (e.g. a1 is played before a2 which is played before a1...).
 

ArminKH

Well-Known Member
Difficult to say without the code. But according to the error, it seems you add animations to the same already existing animations, which creates a circular dependency (e.g. a1 is played before a2 which is played before a1...).
attached is small sample which is reproduce above error
at first click on btn1 animations will be played
then click on btn2 animations will be reversed
now click on btn1 !! errrrrror
upload_2016-3-7_15-52-14.png
 

Attachments

  • sa.zip
    6.5 KB · Views: 201

Informatix

Expert
Licensed User
Longtime User
attached is small sample which is reproduce above error
at first click on btn1 animations will be played
then click on btn2 animations will be reversed
now click on btn1 !! errrrrror
View attachment 42238
Okay, the error is there:
Noa_AS.PlayTogether(Array(Noa_Scale, Noa_L))
Noa_AS.Start

You add two animations to the list of animations with PlayTogether and play them with Start. By reclicking the button, you re-add the same animations. Add this line before PlayTogether to make things more obvious:
Log(Noa_AS.ChildAnimations)
 

ArminKH

Well-Known Member
Okay, the error is there:
Noa_AS.PlayTogether(Array(Noa_Scale, Noa_L))
Noa_AS.Start

You add two animations to the list of animations with PlayTogether and play them with Start. By reclicking the button, you re-add the same animations. Add this line before PlayTogether to make things more obvious:
Log(Noa_AS.ChildAnimations)
ok now what i can to do?
i need this Noa_AS.PlayTogether(Array(Noa_Scale, Noa_L)) because in my project Noa_Scale and Noa_L will be reinitialized based on their(TargetView) position
is there any way to clear animations which are added to Noa_AS ?
if not the last way is dim Noa_AS again?
thanx in advance
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
ok now what i can to do?
i need this Noa_AS.PlayTogether(Array(Noa_Scale, Noa_L)) because in my peoject Noa_Scale and Noa_L will be reinitialized based on their position
is there any way to clear animations which are added to Noa_AS ?
if not the last way is dim Noa_AS again?
thanx in advance
The best thing is to initialize the animator set when you need it. I can't see why it is a global variable.
 

ArminKH

Well-Known Member
I can't see why it is a global variable.
because i dont want to dim and dim again and again because this animation will be played more than 50 60 time
The best thing is to initialize the animator set when you need it
all of them are needed for my project
this sample just is a small and logic code to reproduce error
my animations is for achieve to material animations for example for SimpleMenu which have Alpha,Translate,IncreaseWidth,IncreaseHeight and also an Alpha animation for each item so if u think u know this is about 10 15 animation which played together for this reason i dont want to dim a new one each time to show menu
i dont know i just fear from memory leak
any way thank u for sharing this great lib
 

Informatix

Expert
Licensed User
Longtime User
because i dont want to dim and dim again and again because this animation will be played more than 50 60 time

all of them are needed for my project
this sample just is a small and logic code to reproduce error
my animations is for achieve to material animations for example for SimpleMenu which have Alpha,Translate,IncreaseWidth,IncreaseHeight and also an Alpha animation for each item so if u think u know this is about 10 15 animation which played together for this reason i dont want to dim a new one each time to show menu
i dont know i just fear from memory leak
any way thank u for sharing this great lib
Then you should separate the initialization (initialize+playtogether) from the use (start) and do the initialization only once.
 

Jackie111

New Member
Licensed User
Longtime User
I would like to play together 2 noaAnimatorSet-s:
AnimSet3.PlayTogether(AnimSet1,AnimSet2) - Returns "To many parameters"
Would you please write down a simple example how to use .PlayTogether()

Thanks!
 

DonManfred

Expert
Licensed User
Longtime User
I would like to play together 2 noaAnimatorSet-s:
AnimSet3.PlayTogether(AnimSet1,AnimSet2) - Returns "To many parameters"
I do not use this lib regularly but based on the source provided in post #1
i would try it like this

B4X:
AnimSet3.PlayTogether(Array As Object(AnimSet1,AnimSet2))

See docu in zip in post #1

  • PlayTogether (items() As Object)
    Sets up this AnimatorSet to play all of the supplied animations at the same time. items: The animations that will be started simultaneously.
 

clydebamford

Member
Licensed User
Longtime User
Just trying to get my head around noa animations and wondering if anyone has some real simple code examples? Ive been trying to simplify the provided examples, and I'm sure I'll get there but..still waiting for that lightbulb moment....
 

wimpie3

Well-Known Member
Licensed User
Longtime User
I'm getting lots of Unexpected event (missing RaiseSynchronousEvents) messages in the logs when using this library. Is this expected behaviour?
 
Top