'Code module
#Region Project Attributes
#ApplicationLabel: B4i Example
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1, Listing As Page
Dim clvListing As CustomListView
Private Downloader As ImageDownloader
Dim JobVignette As HttpJob
Private hd As HUD
Private LISTING_LIST = "listing_list" As String
Dim mapData As Map
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Listing.Initialize("Listing")
Listing.RootPanel.LoadLayout("Listing")
Listing.RootPanel.Color = Colors.ARGB(255,109,237,199)'(255,255,0,0)
Listing.Title = "Listing"
clvListing.Initialize(Me, "clvListing", 100%x)
Listing.RootPanel.AddView(clvListing.AsView, 0, 5dip, 100%x, 100%y)
'-----------------------------------------------------------------------------
ExtraitListePardistance 'job
NavControl.ShowPage(Listing)
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.xxxxxxxxxxx.com/xxxxxxxxxxxx/connection.php", Query)'Chez OVH Kindabreak
End Sub
Sub ExtraitListePardistance
ExecuteRemoteQuery("SELECT ID, date_du_jour, mail1, civilite, nom, prenom, sexe, annee, adresse1, zip, ville, phone1, phone2, nationalite, profession, longitude, latitude, datedebut, datefin, facebook, motor, tarif, texte, img FROM kindasitters ",LISTING_LIST)
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
'XXXXXXXXX LISTING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Case LISTING_LIST
Dim RES, RES2 As String
RES = Job.GetString
Dim parser As JSONParser
parser.Initialize(RES)
Dim Affiche_list As List
Affiche_list = parser.NextArray 'returns a list with maps
For i = 0 To Affiche_list.Size - 1
Dim sb As StringBuilder
Dim M As Map
M = Affiche_list.Get(i)
Dim Civilite, Nom, Prenom, Ville, Zip, Telephone, sexe, URL_Vignette As String
Civilite = M.Get("civilite")
Prenom = M.Get("prenom")
Ville = M.Get("ville")
Zip = M.Get("zip")
sexe = M.Get("sexe")
URL_Vignette = M.Get("img")
Telephone = M.Get("phone1")
Dim Carte_V, TheAdress, MyVignette As String
Carte_V = Prenom & ", " & Nom
TheAdress = Ville & ", " & Zip
clvListing.Add(CreateListItem3(Prenom, Ville,TheAdress, URL_Vignette, clvListing.AsView.Width, 55dip), 70dip, M)
Next
End Select
Else
Log("Error: " & Job.ErrorMessage)
hd.ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub CreateListItem3(Text1 As String, Text2 As String, Text3 As String, ImgPath As String, Width As Int, Height As Int) As Panel
'Routine pour placer 2 labels dans l'item de la customListView
Dim P As Panel
P.Initialize("")
P.Color = Colors.White
'Dim ImgVignette As ImageView
Dim lbl1, lbl2, lbl3 As Label
lbl1.Initialize("lbl1")
lbl1.TextAlignment = lbl1.ALIGNMENT_LEFT
'lbl1.Color =Colors.Gray
lbl1.Text = Text1
lbl1.Font = Font.CreateNew(22)
lbl2.Initialize("lbl2")
lbl2.TextAlignment = lbl2.ALIGNMENT_LEFT
lbl2.Multiline= True
lbl2.Text = Text2
lbl2.Font = Font.CreateNew(16)
lbl3.Initialize("lbl3")
lbl3.TextAlignment = lbl2.ALIGNMENT_LEFT
lbl3.Multiline= True
lbl3.Text = Text3
lbl3.Font = Font.CreateNew(16)
Dim ImgVignette As ImageView
ImgVignette.Initialize
Downloader.Initialize
Downloader.Download(CreateMap(ImgVignette: ImgPath))
P.AddView(ImgVignette, 10dip, 5dip, 15%x, 15%x )
P.AddView(lbl1, 5dip + 20%x, 0dip, 75%x, Height/2-5dip )
P.AddView(lbl2, 5dip + 20%x, lbl1.Height, 75%x, Height/2)
P.AddView(lbl3, 5dip + 20%x, (lbl1.Height +lbl2.Height)-5dip, 75%x, Height/2)
Return P
End Sub