#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
#End Region
Sub Class_Globals
Type RssCardData (Title As String, Content As String, Link As String)
Private Root As B4XView
Private xui As XUI
Private ParsedData As Map
Private lblTitle As B4XView
Private lblContent As B4XView
Private ContentHolderPanel As B4XView
Private Labelaction1 As B4XView
Private CLV1 As CustomListView
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("2")
FillList
End Sub
Sub FillList
Dim j As HttpJob
j.Initialize("job",Me)
j.Download("https://www.ilsole24ore.com/rss/finanza--quotate-italia.xml")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
ParseRSSAndLoadToCLV1(j.GetString)
Log(j.GetString)
End If
j.Release
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.morningstar.it/it/news/rss.aspx?lang=it-IT")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
ParseRSSAndLoadToCLV1(j.GetString)
Log(j.GetString)
End If
j.Release
End Sub
Sub ParseRSSAndLoadToCLV1(rssString As String)
Dim xm As Xml2Map
xm.Initialize
Dim ParsedData = xm.Parse(rssString) As Map
Dim rss As Map = ParsedData.Get("rss")
Dim channel As Map = rss.Get("channel")
Dim items As List = channel.Get("item")
For Each item As Map In items
Dim title As String = item.Get("title")
Dim link As String = item.Get("link")
Dim description As String = item.Get("description")
AddCLV1Item(title,link,description)
Next
End Sub
Sub AddCLV1Item(Title As String, Link As String, Description As String)
Dim cd As RssCardData
cd.Initialize
cd.Title=Title
cd.Link=Link
cd.Content=Description
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, CLV1.AsView.Width, 280dip)
p.LoadLayout("Card1")
lblTitle.Text = cd.Title
Dim su As StringUtils
LogColor("lblContent.height before: "&lblContent.Height,Colors.red)
lblContent.Text = cd.Content
LogColor("lblContent.height after: "&lblContent.Height,Colors.red)
Labelaction1.Top=lblContent.Height+lblContent.Top
ContentHolderPanel.Height=Labelaction1.Top+Labelaction1.Height+2dip
p.Height=Labelaction1.Top+Labelaction1.Height+5dip
Log("P.height="&p.Height)
Log("100%y="&100%y)
CLV1.Add(p,cd)
Dim p2=CLV1.GetPanel(CLV1.Size-1) As Panel
Dim parent=p2.Parent As Panel
Log("size in view: "&parent.height)
End Sub
Sub CLV1_ItemClick (Index As Int, Value As Object)
Log("CLV1_ItemClick Index="&Index&" Value="&Value)
Dim cd=Value As RssCardData
CallSubDelayed3("page2","Show",cd.Link,"Article - Shared by This App")
End Sub