'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim hc As HttpClient
Dim target As OutputStream
Dim a As Int
Dim largeur As Int
Dim hauteur As Int
Dim message As String
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim stop As Button
Dim save As Button
Dim Canvas1 As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
activity.LoadLayout("essai")
If FirstTime Then
hc.Initialize("hc")
largeur=activity.Width
hauteur=activity.Height
canvas1.Initialize(activity)
End If
message="play"
End Sub
Sub Activity_Resume
If stop.Text="Stop" Then
code.CallServer
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
a=a+1
If userclosed Then
activity.Finish
End If
End Sub
Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
If taskid=a Then
If message="play" Then
Log("Success"&TaskId)
Log("play")
Target = File.OpenOutput(File.DirInternalCache, "image.jpg", False)
Response.GetAsynchronously("Response", Target, True, TaskId)
End If
End If
End Sub
Sub HC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
urldone=1
Log("erreur")
Log(reason)
Log("ResponseError"&TaskId)
code.CallServer
End Sub
Sub Response_StreamFinish (Success As Boolean, TaskId As Int)
If taskid=a Then
If Success = False Then
ToastMessageShow("Error downloading file: " & LastException.Message, True)
Log("StreamFinish erreur"&TaskId)
Else If message="play" Then
Log("StreamFinish succes"&TaskId)
Dim image As Bitmap
image=LoadBitmap(File.DirInternalCache, "image.jpg")
If image.IsInitialized Then
'activity.SetBackgroundImage(image)
Dim destrect As Rect
destrect.Initialize(0,0,largeur,hauteur)
canvas1.DrawBitmap(image,Null,destrect)
activity.Invalidate
End If
End If
code.CallServer
End If
End Sub
Sub Stop_Up
If stop.Text="Stop" Then
message="stop"
stop.Text="Play"
save.Visible=True
Else
message="play"
stop.Text="Stop"
save.Visible=False
code.CallServer
End If
End Sub
Sub Save_Up
End Sub
Sub Activity_LongClick
End Sub
Sub Activity_Click
If stop.Visible=False Then
stop.Visible=True
If stop.Text="Play" Then
save.Visible=True
Else
save.Visible=False
End If
Else
stop.Visible=False
save.Visible=False
End If
End Sub