Public Sub RestoreWidgetData
Dim R As RandomAccessFile, It As List, SS As NotePoperties, i2 As Int
Try
R.Initialize(File.DirInternal, "SwipeList.swl", False)
It = R.ReadB4XObject(0)
R.Close
'ToastMessageShow("Refreshing widget data", False)
i2 = It.Size
'ToastMessageShow("Size " & i2, False)
Dim CV As Canvas, BMP As Bitmap, Rect As Rect
Rect.Initialize(0, 0, 155, 50)
BMP.InitializeMutable(155dip, 50dip)
CV.Initialize2(BMP)
If i2 > 0 Then
' Log(1)
SS = It.Get(0)
RV.SetText("Label1", SS.Txt)
RV.SetVisible("Label1", True)
RV.SetTextColor("Label1", SS.TxtClr)
CV.DrawColor(SS.BClr)
RV.SetImage("IV1", BMP)
Else
RV.SetText("Label1", "List is empty. Top 6 in your list will display here.")
RV.SetVisible("Label1", True)
RV.SetTextColor("Label1", Colors.White)
CV.DrawColor(Colors.Blue)
RV.SetImage("IV1", BMP)
End If
If i2 > 1 Then
' Log(2)
SS = It.Get(1)
RV.SetText("Label2", SS.Txt)
RV.SetVisible("Label2", True)
RV.SetTextColor("Label2", SS.TxtClr)
Dim CV As Canvas, BMP As Bitmap, Rect As Rect
Rect.Initialize(0, 0, 155, 50)
BMP.InitializeMutable(155dip, 50dip)
CV.Initialize2(BMP)
CV.DrawColor(SS.BClr)
RV.SetImage("IV2", BMP)
Else
RV.SetVisible("Label2", False)
RV.SetVisible("IV2", False)
End If
If i2 > 2 Then
' Log("3 " & SS.Txt & " " & SS.BClr)
SS = It.Get(2)
RV.SetText("Label3", SS.Txt)
RV.SetVisible("Label3", True)
RV.SetTextColor("Label3", SS.TxtClr)
Dim CV As Canvas, BMP As Bitmap, Rect As Rect
Rect.Initialize(0, 0, 155, 50)
BMP.InitializeMutable(155dip, 50dip)
CV.Initialize2(BMP)
CV.DrawColor(SS.BClr)
RV.SetImage("IV3", BMP)
Else
RV.SetVisible("Label3", False)
RV.SetVisible("IV3", False)
End If
If i2 > 3 Then
' Log(4)
SS = It.Get(3)
RV.SetText("Label4", SS.Txt)
RV.SetVisible("Label4", True)
RV.SetTextColor("Label5", SS.TxtClr)
Dim CV As Canvas, BMP As Bitmap, Rect As Rect
Rect.Initialize(0, 0, 155, 50)
BMP.InitializeMutable(155dip, 50dip)
CV.Initialize2(BMP)
CV.DrawColor(SS.BClr)
RV.SetImage("IV4", BMP)
Else
RV.SetVisible("Label4", False)
RV.SetVisible("IV4", False)
End If
If i2 > 4 Then
' Log(5)
SS = It.Get(4)
RV.SetText("Label5", SS.Txt)
RV.SetVisible("Label5", True)
RV.SetTextColor("Label5", SS.TxtClr)
Dim CV As Canvas, BMP As Bitmap, Rect As Rect
Rect.Initialize(0, 0, 155, 50)
BMP.InitializeMutable(155dip, 50dip)
CV.Initialize2(BMP)
CV.DrawColor(SS.BClr)
RV.SetImage("IV5", BMP)
Else
RV.SetVisible("Label5", False)
RV.SetVisible("IV5", False)
End If
If i2 > 5 Then
' Log(6)
SS = It.Get(5)
RV.SetText("Label6", SS.Txt)
RV.SetVisible("Label6", True)
RV.SetTextColor("Label6", SS.TxtClr)
Dim CV As Canvas, BMP As Bitmap, Rect As Rect
Rect.Initialize(0, 0, 155, 50)
BMP.InitializeMutable(155dip, 50dip)
CV.Initialize2(BMP)
CV.DrawColor(SS.BClr)
RV.SetImage("IV6", BMP)
Else
RV.SetVisible("Label6", False)
RV.SetVisible("IV6", False)
End If
' Log("Update")
RV.UpdateWidget
Catch
ToastMessageShow(LastException.Message, True)
End Try