Swiss Railway Station Clock

klaus

Expert
Licensed User
Longtime User
Having played with some graphics I have programed the
Swiss Railway Station Clock just for fun.

There already does exist the German DB Railway Station Clock here: http://www.b4x.com/forum/share-your-creations/2847-railway-station-clock.html

Best regards.

EDIT: Added a new version with a Panel instead of an Activity for the time setting to garantie the Timer_Tick events running.
 

Attachments

  • SwissStationClock.jpg
    SwissStationClock.jpg
    28.7 KB · Views: 229
  • SwissStationClock.zip
    26.5 KB · Views: 224
  • SwissStationClockNew.zip
    25.6 KB · Views: 233
Last edited:

klaus

Expert
Licensed User
Longtime User
Added a new version in the first post.
In the first version I used a second Activity to display a 'form' for the time settings. When this Activity was active the Timer_Tick event routines, in the Main Activity, didn't trigger anymore. The Timers were declared in the Process_Globals.
Is there a possibility to have a kind of Process Timer_Tick event routines, independant of the Activities ?

So I replaced the second Activity by a Panel in the Main Activity.

Best regards.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there a possibility to have a kind of Process Timer_Tick event routines, independant of the Activities ?
It is problematic to run code when the activity is paused as the activity may be destroyed at that time (therefore the code is likely to eventually fail).
Usually you can use Activity_Resume to update the activity when it is active again.
 

agraham

Expert
Licensed User
Longtime User
I just checked and you are of course correct. I thought I had tested that previously but I guess I just might have been trying it with ProgressDialog and not a true modal dialog.

Any idea why it stops? Your modal code is pumping messages - maybe Android is being selective with the messages and only allows those for the dialog through?
 

klaus

Expert
Licensed User
Longtime User
Usually you can use Activity_Resume to update the activity when it is active again.
That's what I did. But I am increasing the angle of the second needle every Timer_Tick. And the time used in the second Activity is lost, or must be measured seperately. But using a panel solved the problem for my program.

When using Timers with different Activities we must be aware that the Timer_Tick routines are no more triggerd in the other activities.

As an aside have you found EditText.INPUT_TYPE_NUMBERS?
Hadn't noticed it. Will for shure use it.

Thanks and Best regards.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Timers are paused by design. It caused all kinds of problems when combined with the activity life cycle events.

As I wrote in a different post (and I know that you already know it), Android doesn't support true modal dialogs natively. Adding support for these dialogs was much more complicated than I initially thought. The combination of the activity dynamic life cycle with the additional messages handler requires a very delicate handling.
 
Top