Sub Globals
Dim id As Int
Dim Contacts1 As Contacts
Dim lvPersons As ListView
Dim myContact As Contact
Dim listOfContacts As List
End Sub
Sub Activity_Create(FirstTime As Boolean)
lvPersons.Initialize("")
Activity.AddView(lvPersons,0%x,0%y,100%x,100%y) 'don't confuse %x and %y
lvPersons.Clear
listOfContacts = Contacts1.GetAll
Dim map1 As Map
map1.Initialize
Dim list1 As List
list1.Initialize
For i = 0 To listOfContacts.Size - 1
myContact = listOfContacts.Get(i)
list1.Add(myContact.DisplayName)
map1.Put(myContact.DisplayName, myContact)
Next
list1.Sort(True)
For i = 0 To list1.Size - 1
myContact = map1.Get(list1.Get(i))
lvPersons.AddTwoLines2(myContact.DisplayName,myContact.PhoneNumber,myContact.id)
Next
End Sub
Dim m As Map
m = myContact.GetPhones
Dim p as String
for i = 0 To m.Size - 1
If m.GetValueAt(i) = myContact.MOBILE_PHONE Then
p = m.GetKeyAt(i)
Exit
End If
Next
If p.Length > 0 Then Msgbox("Mobile phone = " & p)
Sub Activity_Create(FirstTime As Boolean)
lvPersons.Initialize("")
Activity.AddView(lvPersons,0%x,0%x,100%x,100%x)
lvPersons.Clear
listOfContacts = Contacts1.GetAll
For i = 0 To listOfContacts.Size - 1
myContact = listOfContacts.Get(i)
Dim mob As Map
Dim mobile As String
mob = myContact.GetPhones
For x = 0 To mob.Size -1
If mob.GetValueAt(x) = myContact.PHONE_MOBILE Then
mobile = mob.GetKeyAt(x)
lvPersons.AddTwoLines2(myContact.DisplayName,mobile,myContact.id)
Exit
End If
Next
Next
End Sub
Sub btnContactos_Click
Dim contactos As Contacts
Dim contacto As Contact
Dim listaContactos As List
Dim telefones As Map
Dim telemovel As String
Dim listaNomes As List
Dim listaTelefones As List
Dim listaGeral As Map
Dim selecionado As Int
Dim inicio As String
ProgressDialogShow("A carregar a lista de contactos...")
listaNomes.Initialize
listaTelefones.Initialize
listaGeral.Initialize
DoEvents
If txtNumero.Text.Length = 0 Then
listaContactos = contactos.GetAll
Else
listaContactos = contactos.FindByName(txtNumero.Text.Trim , False)
End If
For i = 0 To listaContactos.Size - 1
DoEvents
Contacto = listaContactos.Get(i)
If contacto.DisplayName.IndexOf("@") < 0 Then
telefones = Contacto.GetPhones
For j = 0 To telefones.Size -1
If telefones.GetValueAt(j) = Contacto.PHONE_MOBILE Then
listaNomes.Add(contacto.DisplayName)
listaGeral.Put(contacto.DisplayName,contacto)
Exit
End If
Next
End If
Next
listaNomes.SortCaseInsensitive(True)
For i = 0 To listaNomes.Size - 1
DoEvents
Contacto = listaGeral.Get(listaNomes.Get(i))
telefones = Contacto.GetPhones
For j = 0 To telefones.Size -1
If telefones.GetValueAt(j) = Contacto.PHONE_MOBILE Then
telemovel = telefones.GetKeyAt(j)
listaTelefones.Add(telemovel)
Exit
End If
Next
Next
ProgressDialogHide
selecionado = InputList(listaNomes, "Contactos", -1 )
If selecionado <> DialogResponse.CANCEL Then
telemovel = listaTelefones.Get(selecionado)
txtNumero.Text = telemovel.Replace("+351","").Trim
Else
txtNumero.Text = ""
End If
End Sub