Page 1 of 1

Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 2:53 am
by lemodizon
Hello Everyone,

I was trying to created a splash card using a widget “spinner” via android Application. At first the widget spinner works well it does spin. After a couple of runs it doesn’t spin anymore. Below is my code.

Code: Select all

on preOpenStack
show widget “MySpinner”
wait 5 sec
hide widget “MySpinner”
go to cd “LoginCard”
end preOpenStack
Is there another way to create a simple splash card? Or is there a problem on the widget “spinner”?

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 10:23 am
by Klaus
Hi Lemodizon,

not sure, but "on preopenstack" does not seem the right place/time,
try "on opencard" of your first card!

Best

Klaus

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 3:54 pm
by SparkOut
Not sure either, but probably the widget uses messages to send to itself to advance the spinner. Your "wait 5 seconds" is blocking and may prevent the screen updates for the spinner animation.
Try

Code: Select all

wait 5 seconds with messages
as well as what Klausimausi says. (It is true that preOpenCard fires before the actual screen is rendered, so you really would need to have one card drawn already for the widget to be rendered on the top.)

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 4:01 pm
by Klaus
Well, I tried the original script and, go figure, it was spinning even during the WAIT 5 SECS! :D
But WAIT 5 SECS WITH MESSAGES seems a good idea nevertheless.

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 4:45 pm
by lemodizon
Hi Klaus & SparkOut,

Thanks guys, aside from widget spinner can i use a gif in my splash card? I will download a free gif and try to my splash card. are they the same code?

Code: Select all

on OpenCard
show img "sample gif”
wait 5 sec with message
hide img  "sample gif”
go to cd “LoginCard”
end OpenCard

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 5:00 pm
by lemodizon
SparkOut wrote:
Sat Dec 19, 2020 3:54 pm
Not sure either, but probably the widget uses messages to send to itself to advance the spinner. Your "wait 5 seconds" is blocking and may prevent the screen updates for the spinner animation.
Try

Code: Select all

wait 5 seconds with messages
as well as what Klausimausi says. (It is true that preOpenCard fires before the actual screen is rendered, so you really would need to have one card drawn already for the widget to be rendered on the top.)
Hi SparkOut,

what is the use of "with messages" and where can i use it. this is new to me "with messages".

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sat Dec 19, 2020 5:56 pm
by SparkOut
In your code snippet you put "with message" but you must make sure the actual code is "with messages"

A "wait" statement is blocking in LiveCode. The engine literally suspends all processes for the duration, which includes all other ongoing messages placed in the message queue by other handlers, as well as "housekeeping" tasks like keyboard polling and screen redrawing. Adding "with messages" tells LiveCode to release some processor cycles back to the engine for these other tasks, a sort of "interrupt" if you like.

This is often useful in a repeat loop. If you have a repeat loop that runs for a while, it may appear to lock up, as the loop is greedy and takes all the processor cycles. This can make your app unresponsive and appear to have crashed.
If you add a statement

Code: Select all

wait 0 milliseconds with messages
inside the repeat loop, the engine can use that interruption to grab a few cycles to fire off screen updates and keyboard tests, etc.

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sun Dec 20, 2020 4:44 am
by lemodizon
Hi SparkOut,

Thanks for the explanation. Is there a way to change the picture of the widget spinner?

Re: Andriod App - Splash Card -Widget Spinner

Posted: Sun Dec 20, 2020 7:50 pm
by jacque
The widget can't be changed but you can use a gif. That's what I usually do. Show the gif on opencard, and use "wait 0 with messages" if your handler is long. If there is a repeat loop, put the wait inside the loop. The gif will not spin reliably unless the wait command has time to update it.

Re: Andriod App - Splash Card -Widget Spinner

Posted: Tue Dec 22, 2020 6:42 am
by lemodizon
jacque wrote:
Sun Dec 20, 2020 7:50 pm
The widget can't be changed but you can use a gif. That's what I usually do. Show the gif on opencard, and use "wait 0 with messages" if your handler is long. If there is a repeat loop, put the wait inside the loop. The gif will not spin reliably unless the wait command has time to update it.
Hi Jacque,

Thanks for the information I will try the gif. Stay safe everyone and thank you everyone for the sharing.