Hello,
I use this code, for create a customlistview from httpjob
This is for create the Item
I would like to convert it into CustomListView with lazy loading and then, on click event, log the value of lbluserID.Text instead the INDEX.
In some exaples that I found here, the date doesn't come from a httpjob and I don't know how to do it
Thank you
I use this code, for create a customlistview from httpjob
B4X:
Sub downloadEmailsLista
UsersCV.Clear
Dim bytemail() As Byte
Dim byteSalsy() As Byte
Dim index As Int = 1
e.Initialize
Dim j As HttpJob
j.Initialize("", Me) 'name is empty as it is no longer needed
j.Download(ServerURl & "/xxxxxxxxxxxxxx/restapi.php?api=tbl-users&orderby=my_iduser&sort=asc") '&orderby=my_iduser&sort=asc") '2")
ProgressDialogShow2("Loading User list...",False)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
Dim parser As JSONParser
parser.Initialize(j.getstring)
Dim jRoot As List = parser.NextArray
For Each coljRoot As Map In jRoot
my_enabled = coljRoot.Get("my_enabled")
my_appversion = coljRoot.Get("my_appversion")
my_email = coljRoot.Get("my_email")
my_last_see = coljRoot.Get("my_last_see")
my_btcaddress = coljRoot.Get("my_btcaddress")
my_ispremium = coljRoot.Get("my_ispremium")
Dim my_salt As String = coljRoot.Get("my_salt")
Dim my_registration_date As String = coljRoot.Get("my_registration_date")
Dim my_iduser As Int = coljRoot.Get("my_iduser")
byteSalsy = encode.DecodeBase64(my_salt)
Dim stringSalt As String = DecryptText(byteSalsy,Main.app_id)
my_salt = stringSalt
bytemail = encode.DecodeBase64(my_email)
stringmail = DecryptText(bytemail,my_salt)
e.Add(stringmail)
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
Dim dt As Long = DateTime.DateParse(my_last_see)
DateTime.DateFormat = "dd/MM/yyyy"
' Log(DateUtils.PeriodBetweenInDays(DateTime.DateParse($"$Date{dt}"$),DateTime.Now).Days)
Dim daydif As Int = DateUtils.PeriodBetweenInDays(DateTime.DateParse($"$Date{dt}"$),DateTime.Now).Days
UsersCV.Add(CreateItem(UsersCV.AsView.Width, my_iduser, stringmail, daydif,my_appversion), "")
Next
Else
ToastMessageShow("Error: " & j.ErrorMessage, True)
End If
j.Release
ProgressDialogHide
End Sub
This is for create the Item
B4X:
Private Sub CreateItem(Width As Int, userid As String, email As String, last As String, version As String) As Panel
Dim p As B4XView = xui.CreatePanel("")
Dim height As Int = 160dip 'UsersCV.AsView.Height '350dip '50dip
p.SetLayoutAnimated(0, 0, 0, Width, height)
p.LoadLayout("CLV_UTENTI")
p.Color = Colors.Cyan
If my_enabled = 0 Then
Panel1.Color = 0xAEFF0000
End If
lbluserID.Text = userid 'user id da searchbox
lblemail.Text = email 'email decriptata
lbllastactivity.Text = "Ultima attività: "
txtastactivity.Text = last 'differenza in giorni della ultima attività
lblversion.Text = "Versione: "
txtversion.Text = version
index = userid
Return p
End Sub
I would like to convert it into CustomListView with lazy loading and then, on click event, log the value of lbluserID.Text instead the INDEX.
In some exaples that I found here, the date doesn't come from a httpjob and I don't know how to do it
Thank you