Share My Creation Cercatel

Ok this is a beta but it works well.
Cercatel is an engine, written for my Italian project Cercatel: ricerca elenchi telefonici., whose aim is looking for/finding people, companies and relevant phone numbers and addresses. I'm posting some screenshots without code since this contains confidencial info. Upon request I may post some part of code.

Herebelow you will see activities for different types of research
AttRicerca.png
Persona.png
Telefono.png


Each activity calls the same webservice (http://www.founditservice.net) . When respons arrive it parse Xml and fill the information into a Listview. After this, the user can dial in or get location through Google Map.
Results.png
Action.png
Telef.png


Mappa.png


Thanks.
 
Last edited:

Ladware

Member
Licensed User
Longtime User
Globals
B4X:
Sub Process_Globals

   'INDIRIZZO SERVIZIO WEB
   Dim URL As String
   URL = "http://www.founditservice.net/FoundItWs.asmx/"
            'HTTP CLIENT X WEBSERVICE
   Dim HttpClient1 As HttpClient
   Dim in As InputStream   
   
   'SAX PARSER INIT
   Dim parser As SaxParser

End Sub


Web service FoundIt Servizio Web
B4X:
HTTP GET
Di seguito è riportato un esempio di richiesta e risposta HTTP GET. I segnaposto devono essere sostituiti con i valori appropriati.

GET /FoundItWs.asmx/RicercaSemplice?Tipo=string&txtCittaSemp=string&txtCognomeSemp=string&txtNomeSemp=string&txtIndSemplice=string&txtCittaVicini=string&txtIndVicini=string&txtCivico=string&txtAziendaRagsoc=string&txtCittaAzienda=string&RadioB1=string&Secret=string HTTP/1.1
Host: www.founditservice.net

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<DataTable xmlns="http://FoundItService/">xmlxml</DataTable>

Start request...
B4X:
Sub DoFind(Tipo As String)
   Awake.KeepAlive(True)
   'AVVIO RICERCA
   Dim request As HttpRequest
   Dim Values As String 
   
   'COMPONGO LA STINGA PER LA RICHIESTA GET AL WEBSERVICE
   If tipo="1" Then
      'CERCA DA PERSONA
      Values="RicercaSemplice?Tipo=1&txtCittaSemp=" & Citta & "&txtCognomeSemp=" & Cognome & "&txtNomeSemp=&txtIndSemplice=&txtCittaVicini=&txtIndVicini=&txtCivico=&txtAziendaRagsoc=&txtCittaAzienda=&RadioB1=False&Secret=***"
   Else If tipo="5" Then
      'CERCA DA NUMERO
      Values="RicercaSemplice?Tipo=5&txtCittaSemp=" & Citta & "&txtCognomeSemp=" & Cognome & "&txtNomeSemp=&txtIndSemplice=&txtCittaVicini=&txtIndVicini=&txtCivico=&txtAziendaRagsoc=&txtCittaAzienda=&RadioB1=False&Secret=***"
   Else If tipo="6" Then
      'CERCA VICINO A
      Values="RicercaDiProssimita?Tipo=6&txtAziendaRagsoc=" & CosaCerchi & "&txtCittaAzienda=" & Citta & "&txtVicinoA=" & ViaVicinoA & "&RadioB1=True&Secret=***"
   End If
   
   'INIT LA RICHIESTA PASSANDOGLI L'URL E I PARAMETRI GET
   request.InitializeGet(URL &  Values)
   
   'TIMEOUT RICHIESTA ( 1 MIN )
   request.Timeout = 60000 
   
   'ESEGUO LA RICHIESTA
   If HttpClient1.Execute(request, 1) = False Then Return   ProgressDialogShow("Ricerca in corso...")
   
End Sub

Http response...
B4X:
Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
   'RISPOSTA DAL WEBSERVICE
   'INIT STREAM
   in = Response.GetInputStream
   ProgressDialogHide
   DoParse
End Sub

Sub HttpClient1_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
   'ERRORE RISPOSTA DAL WEBSERVICE
   ProgressDialogHide
   msg = "Timeout servizio."
   If reason <> Null Then msg = msg 
   ToastMessageShow (msg, True)
End Sub

Parsing...
B4X:
Sub DoParse      
   
   ProgressDialogShow("Recupero informazioni...")
   DoEvents
   lstStreamResult.Initialize
   'CHIAMO IL PARSER
   'PASSO LO STREAM XML E PUNTO AL NOME DELL'EVENTO
   Try   
      parser.Initialize
      parser.Parse(in,"Parser")
   Catch
   End Try
   ProgressDialogHide
   StartActivity(mdlActResult) <<<<
   
End Sub

B4X:
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
   
   'EVENTO BRUCIATO DAL PARSER
   
   'CERCO IL NOME DELL'ELEMENTO
   If parser.Parents.IndexOf("DocumentElement")>-1 Then
      If Name = "Cognome" Then
         tCognome = Text.ToString
      Else If Name = "Nome" Then
         tNome = Text.ToString
      Else If Name = "Indirizzo" Then
         tIndirizzo = Text.ToString
      Else If Name = "Provincia" Then
         tProc = Text.ToString
      Else If Name = "Cap" Then
         tCap = Text.ToString
      Else If Name  ="Tel" Then
         tTel = Text.ToString
      Else If Name = "Mail" Then
         tMail = Text.ToString
         Dim NomeCogn As String
         If tCognome.Trim <> "" Then NomeCogn = tCognome.Trim
         If tNome.Trim <> "" Then NomeCogn = NomeCogn & " " & tNome.Trim
         lstStreamResult.Add( NomeCogn & CRLF & tIndirizzo & " " & tProc & " " & tCap & CRLF & tTel & CRLF & tMail  )
      End If    
   End If 

End Sub
 
Last edited:

Ladware

Member
Licensed User
Longtime User
Result activity (mdlActResult)

B4X:
'***********************************
'MODULO RISULTATI
'***********************************
Sub Process_Globals
   Dim l As List
End Sub

Sub Globals
   Dim ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Dim i As Int
   
   Activity.LoadLayout("ActResult")
   
   ProgressDialogShow("Caricamento...")
   DoEvents
   ListView1.FastScrollEnabled=True
   ListView1.SingleLineLayout.ItemHeight = 110dip
   ListView1.SingleLineLayout.Label.TextSize=15
   ListView1.SingleLineLayout.Label.TextColor=Colors.DarkGray
   ListView1.ScrollingBackgroundColor = Colors.Transparent
   
   Try
      If  main.lstStreamResult.Size >0 Then
         For i=0 To main.lstStreamResult.Size-1
            ListView1.AddSingleLine(main.lstStreamResult.Get(i))
         Next 
         Activity.Title="Trovati " & main.lstStreamResult.Size & " contatti."
      Else
      ListView1.AddSingleLine("Informazione non trovata.")
      Msgbox("Nessun risultato.","Ricerca")
      End If 
   Catch
   End Try

   main.Awake.ReleaseKeepAlive
   ProgressDialogHide
   
End Sub

Sub ListView1_ItemLongClick (Position As Int, Value As Object)
   If ListView1.GetItem(0)<> "Informazione non trovata." Then
      StartActivity(mdlDoAction)  <<<<
   End If 
End Sub
 
Last edited:

Ladware

Member
Licensed User
Longtime User
Action Activity (mdlActResult)

B4X:
Sub Activity_Create(FirstTime As Boolean)
      ProgressDialogShow("")
      Activity.LoadLayout("DoAction")
   
      Dim i As Int
      For i=0 To mdlactresult.l.Size -1
         Dim matcher1 As Matcher
         matcher1 = Regex.Matcher("\d+\s\d+", mdlactresult.l.Get(i))
         Do While matcher1.Find = True
            lblTel.Text = matcher1.Match.Trim
         Loop
         Dim matcher2 As Matcher
         matcher2 = Regex.Matcher("\w+@\w+\.\w+", mdlactresult.l.Get(i))
         Do While matcher2.Find = True
            lblMail.Text = matcher2.Match.Trim
         Loop
      Next
      ....
      ProgressDialogHide


   
End Sub

Sub ImageMap_Click
   'MAPPA
   Dim Intent1 As Intent
   Intent1.Initialize2("http://www.cercatel.net/map.html?var1=" & lblMap.Text, 0)
   StartActivity(Intent1) 
End Sub

Sub ImageChiama_Click
   'CHIAMA
   Dim p As PhoneCalls
   StartActivity(p.Call(lblTel.Text))
End Sub

Sub ImageMail_Click
   Dim Message As Email
   Message.To.Add(lblMail.Text)
   StartActivity(Message.GetIntent) 
End Sub
 
Top