The idea of the opening post has a logic, but considering that the Sleep command (even Sleep(0) ) will give back the flow to the calling point.............. maybe it's better to have it separated as now to better manage it.
1. It is not possible to add parameters to existing methods. You can request to add another method SetVisibleAnimated2 with the sleep parameter.
2. As I see it, adding such a method is a huge mistake. There are many SetXXXAnimated methods. There is no sense in adding this parameter to SetVisibleAnimated and not the others.
It also leads developers to the wrong conclusion that a sleep is required after calling a "set animated" method. The only case where it is required is if you want to do something only after the animated ends. This is not 90% of the cases. It is maybe 1% of the cases.
I wrote this class (and test project) in just a few minutes (just because it's very easy and it's even easier thanks to B4X ), so I put in the first animations I found, without thinking too much.
The main reason was... to avoid doing more important and urgent things ?
As I wrote, you could make a B4Xlib library out of it.
There is an opportunity here to explain a bit about resumable subs and why it is not really possible to create a simple SetVisibleAnimatedAndSleep method. It is possible with ugly compiler changes or by calling it with: Wait For (v.SetVisibleAnimatedAndSleep(...)) Complete
I will leave the explanation task for @agraham.
This got me thinking that I should have suggested that you create such a sub yourself:
B4X:
Public Sub SetVisibleAnimatedAndSleep(v As B4XView, Visible As Boolean, Duration) As ResumableSub
v.SetVisibleAnimated(Visible, Duration)
Sleep(Duration)
Return True
End Sub
'use it:
Wait For (Utils.SetVisibleAnimatedAndSleep(xPage, True, 1000)) Complete (Unused As Boolean)
There is an opportunity here to explain a bit about resumable subs and why it is not really possible to create a simple SetVisibleAnimatedAndSleep method. It is possible with ugly compiler changes or by calling it with: Wait For (v.SetVisibleAnimatedAndSleep(...)) Complete
I will leave the explanation task for @agraham.
This got me thinking that I should have suggested that you create such a sub yourself:
B4X:
Public Sub SetVisibleAnimatedAndSleep(v As B4XView, Visible As Boolean, Duration) As ResumableSub
v.SetVisibleAnimated(Visible, Duration)
Sleep(Duration)
Return True
End Sub
'use it:
Wait For (Utils.SetVisibleAnimatedAndSleep(xPage, True, 1000)) Complete (Unused As Boolean)
There is an opportunity here to explain a bit about resumable subs and why it is not really possible to create a simple SetVisibleAnimatedAndSleep method. It is possible with ugly compiler changes or by calling it with: Wait For (v.SetVisibleAnimatedAndSleep(...)) Complete
I will leave the explanation task for @agraham.
This got me thinking that I should have suggested that you create such a sub yourself:
B4X:
Public Sub SetVisibleAnimatedAndSleep(v As B4XView, Visible As Boolean, Duration) As ResumableSub
v.SetVisibleAnimated(Visible, Duration)
Sleep(Duration)
Return True
End Sub
'use it:
Wait For (Utils.SetVisibleAnimatedAndSleep(xPage, True, 1000)) Complete (Unused As Boolean)
Thanks, Erel(s). I did something similar. I am going for the "movie credit" effect and could not find something like that. I also want the Star Wars Intro scrolling, shrinking, leaving the display, text.