Sub Activity_Create(FirstTime As Boolean)
Try
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("lista_carros")
SQL1.Initialize(File.DirDefaultExternal, "ijavendi.db", True)
'StartService(Starter)
timer_online.Initialize("timer_online", 60000)
timer_online.Enabled = True
clv.Initialize(Me, "clv")
Activity.AddView(clv.AsView, 0, 12%y, 100%x, 88%y)
PopupMenu.Initialize("PopupMenu",imgMenu)
PopupMenu.AddMenuItem(0, 0, "Preferencia")
PopupMenu.AddMenuItem(2, 1, "Vender Carro")
PopupMenu.AddMenuItem(3, 2, "Estoque de Carros")
PopupMenu.AddMenuItem(1, 3, "Sair")
StartService(Starter)
Catch
gravaLog(LastException.Message,"Activity_Create")
End Try
End Sub
Sub recebeDados(dados As String)
Try
links.Initialize
lista_carros.Initialize("lista_carros", Me)
Log(servridor &"listaCarros.php?acao=1&id_user="& id_comprador)
lista_carros.PostString(servridor &"listaCarros.php?acao=1", "id_user="& id_comprador)
inicio = 1
Catch
gravaLog(LastException.Message,"recebeDados")
End Try
End Sub
Sub JobDone (Job As HttpJob)
'Log("Nome = " & Job.JobName & ", Success = " & Job.Success)
'Dim Map1 As Map
If Job.Success = True Then
Select Job.JobName
Case "lista_carros"
Dim p As JSONParser
Dim response As String
response = Job.GetString
p.Initialize(response)
Dim rows As List
rows = p.NextArray
links.Clear
If rows.Size <> 0 Then
For i = 0 To rows.Size - 1
links.Add(rows.Get(i))
Next
BuildItems
Else
semCarros
End If
End Select
Else
Log(Job.ErrorMessage)
gravaLog(LastException.Message,"Case lista_carros")
End If
ProgressDialogHide
End Sub
Sub BuildItems
Try
lblInfoCarros.Visible = False
buscaIdComprador
usuario_online.Initialize("usuario_online", Me)
usuario_online.PostString(servridor &"usuario_online.php?acao=1", "id_comprador="& id_comprador)
If links.Size = 0 Then Return
clv.Clear
Dim m As Map
m.Initialize
For Each link As String In links
Dim p As Panel
p.Initialize("painel_carro")
clv.Add(p, 50%y, link)
p.LoadLayout("exibi_lista_carros")
Dim components() As String
components = Regex.Split("-", link)
Log(servridor_imagem & components(6))
m.Put(imgCarroLista, servridor_imagem & components(6))
lblValor.Text = components(4)
lblModelo.Text = components(1)
'lblTempoRest.Text = ""
Next
CallSubDelayed2(ImageDownloader, "Download", m)
ProgressDialogHide
Catch
gravaLog(LastException.Message,"BuildItems")
End Try
End Sub
Sub StartTimer (Hours As Int, Minutes As Int, Segundos As Int)
targetTime = DateTime.Now + Hours * DateTime.TicksPerHour + Minutes * DateTime.TicksPerMinute + Segundos * DateTime.TicksPerSecond
timer1.Enabled = True
End Sub
Sub Timer1_Tick
Dim t As Long = Max(0, targetTime - DateTime.Now)
Dim hours, minutes, seconds As Int
hours = t / DateTime.TicksPerHour
minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute
seconds = (t Mod DateTime.TicksPerMinute) / DateTime.TicksPerSecond
Log($"$2.0{minutes}:$2.0{seconds}"$)
lblTempoRest.Text = $"$2.0{hours}:$2.0{minutes}:$2.0{seconds}"$
If t = 0 Then
timer1.Enabled = False
End If
End Sub