#Region Project Attributes
#ApplicationLabel: CountDown
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: true
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim T1 As Timer
Dim Dur As Long 'Single phase duration
Dim TInit, TFinal,DT As Long
Dim PhaseList() As Long
Dim PhaseNum As Int : PhaseNum=0
Dim tick As Int : tick=1000
End Sub
Sub Activity_Create(FirstTime As Boolean)
T1.Initialize("T1",tick)
PhaseList=Array As Long(3,5,4) 'For testing, these values will be fetched from a DB [sec]
TInit=DateTime.now 'Save the start moment
Dur=1000*PhaseList(PhaseNum) 'Calc the interval in millsec
TFinal=TInit+Dur 'Calc the phase finish moment
Log("Begin of Phase:"&PhaseNum)
Log(Dur) 'Show the first value
T1.Enabled=True
End Sub
Sub T1_tick
If DateTime.Now<TFinal Then
DT=TFinal-DateTime.Now
Log(DT) 'Visualize the time remaining in millsec
Else
PhaseNum=PhaseNum+1 'Pass to the next phase
If PhaseNum>PhaseList.Length-1 Then
T1.Enabled=False 'Stop the countdown
Else
Dur=1000*PhaseList(PhaseNum)
TInit=DateTime.now 'Reset Initial time
TFinal=TInit+Dur 're-calc final time
Log("Begin of Phase:"&PhaseNum)
Log(Dur) 'Show the first value
End If
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub