Sub Process_Globals
Type RssCardData (Title As String, Content As String, Link As String, url As String , pubDate As String)
Private xui As XUI
End Sub
Sub Globals
Private CLV1 As CustomListView
Private lblTitle As B4XView
Private lblContent As B4XView
Private playbutton As Label
Private sharebutton As Label
Private web As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
youtubelist
End Sub
Sub youtubelist
ProgressDialogShow("loading...")
Dim j As HttpJob
j.Initialize("job",Me)
j.Download("https://www.youtube.com/feeds/videos.xml?playlist_id=PLSXGv13TotQZUPJCw1lnxeaPsfYjns5W-") 'use only the portion beginning with PL...
Wait For (j) JobDone(j As HttpJob)
ProgressDialogHide
If j.Success Then
ParseYoutube(j.GetString)
Log(j.GetString)
End If
j.Release
End Sub
Sub ParseYoutube(rssString As String)
Dim xm As Xml2Map
xm.Initialize
Dim ParsedData = xm.Parse(rssString) As Map
Dim feed As Map = ParsedData.Get("feed")
Dim entrys As List = feed.Get("entry")
For Each entry As Map In entrys
Dim title As String = entry.Get("title")
Dim pubDate As String = entry.Get("published")
Dim link As String = entry.Get("videoId")
Dim group As Map = entry.Get("group")
Dim thumbnails As Map = group.Get("thumbnail")
Dim Attributes As Map = thumbnails.Get("Attributes")
Log($"Attributes: ${Attributes}"$)
Dim url As String = Attributes.Get("url")
Log($"url: ${url}"$)
Log($"link: ${link}"$)
Log($"entrys: ${entrys}"$)
Log($"title: ${title}"$)
AddCLVItem(title,link ,url, pubDate)
Next
End Sub
Sub AddCLVItem(Title As String, Link As String, url As String , pubDate As String)
Dim cd As RssCardData
cd.Initialize
cd.Title=Title
cd.Link=Link
cd.url=url
cd.pubDate=pubDate
cd.Content=""
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, CLV1.AsView.Width, 400dip)
p.LoadLayout("Card1")
lblTitle.Text = cd.Title
web.LoadHtml($"<img src="${url}" style= "width:100%"/>"$)
Dim htm As Html
Dim su As StringUtils
lblContent.Text = htm.FromHtml(cd.Content)
lblContent.Height=su.MeasureMultilineTextHeight(lblContent,lblContent.Text)
playbutton.Top=lblContent.Height+lblContent.Top
sharebutton.Top=lblContent.Height+lblContent.Top
p.Height=playbutton.Top+playbutton.Height+5dip
CLV1.Add(p,cd)
End Sub
Sub playbutton_Click
Dim index As Int = CLV1.GetItemFromView(Sender)
Dim cd=CLV1.GetValue(index) As RssCardData
CallSubDelayed2(play,"Show",cd.Link)
Log($"Action 1 clicked. Index: ${index}"$)
End Sub
Sub sharebutton_Click
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub