Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("LayoutLog")
SetStatusBarColor(0xFFFFFFFF)
DateTime.DateFormat="EEEE, dd MMMM yyyy"
Private i As Int =1
xclvLog.AsView.Visible=False
Dim rs As ResultSet
Dim val,mode,date As String
rs = Starter.sql.ExecQuery("select * from app where userid =" &StateManager.GetSetting("userid") &" ORDER BY time_entry Desc, id Desc")
If rs.RowCount > 0 Then
loadingcircles.show
End If
Do While rs.NextRow
Dim p As B4XView = xui.CreatePanel("")
Dim p1 As B4XView = xui.CreatePanel("")
p1.SetLayoutAnimated(100,0,0,100%x,30dip)
p.SetLayoutAnimated(100,0,0,100%x,75dip)
p1.LoadLayout("itemDate")
p.LoadLayout("itemLog")
Private Buffer() As Byte
Buffer = rs.GetBlob("imageblob")
Private InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Private Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1)
InputStream1.Close
selfieimage.Bitmap = Bitmap1
'Category
val = rs.GetString("category")
Dim rs2 As ResultSet
rs2 = Starter.sql.ExecQuery("select * from categories")
Do While rs2.NextRow
If val = rs2.GetInt("id") Then
lblcategory.Color = rs2.GetInt("hex_color")
lblcategory.Text = rs2.GetString("category")
lblcategory.Width = rs2.GetInt("width_log") *1dip
End If
Loop
rs2.close
'Date
Dim Yesterday As Long
Yesterday = DateTime.add(DateTime.Now, 0, 0, -1)
DateTime.DateFormat="yyyy-M-dd"
Dim t As Long
t = DateTime.DateParse(rs.GetString("date_entry"))
DateTime.DateFormat = "EEEE, dd MMMM yyyy"
Dim s As String
s = DateTime.Date(t)
If s = DateTime.Date(DateTime.Now) Then
lblDate.Text = "Today - " &s
Else if s = DateTime.Date(Yesterday) Then
lblDate.Text = "Yesterday - " &s
Else
lblDate.Text = s
End If
' Time
DateTime.DateFormat="yyyy-MM-dd kk:mm:ss"
Dim time As Long
time = DateTime.DateParse(rs.GetString("time_entry"))
DateTime.TimeFormat="hh:mm a"
Dim timeformatted As String
timeformatted = DateTime.Time(time)
lbltime.Text= timeformatted
p1.SetColorAndBorder(Colors.White,2,0xFFE0E0E0,0)
p.SetColorAndBorder(Colors.White,2,0xFFE0E0E0,0)
'Adding row in List View
If date = rs.GetString("date_entry") Then
xclvLog.Add(p,"")
Else
xclvLog.Add(p1,"")
xclvLog.Add(p,"")
End If
date = rs.GetString("date_entry")
Sleep(0)
xclvLog.AsView.Visible=True
i=i+1
Loop
rs.close
End Sub