'Class clsGlobals
Sub Class_Globals
Public FIELD_ART_CDATE As String = "created"
'......
end sub
Sub GetArtContent (nid As Int, aUser As String, aPsw As String) As ResumableSub
Try
'I got the putted values from a json parsing and all the values are putted and populated correctly
Dim field_image As List = JRoot.Get("field_image") '>>> img attachment is madatory so is always available
For Each colfield_image As Map In field_image
Private mapContent As Map
mapContent.Initialize
Dim target_id As Int = colfield_image.Get("target_id")
Dim alt As String = colfield_image.Get("alt")
Dim ArtImgtitle As String = colfield_image.Get("title")
Dim imgURL As String = colfield_image.Get("url")
Dim artNID As Int = nid
mapContent.Put (FIELD_ART_NID, artNID)
mapContent.Put (FIELD_ART_TITLE, ArtTitle)
mapContent.Put (FIELD_ART_BODY, ArtBody)
mapContent.Put (FIELD_ART_IMG_ID, target_id)
mapContent.Put (FIELD_ART_IMG_ALT, alt)
mapContent.Put(FIELD_ART_IMG_TITLE, ArtImgtitle)
mapContent.Put(FIELD_ART_IMAGE_URL, imgURL)
'download image
Wait For (DownloadImage(imgURL)) Complete (Image As Bitmap)
mapContent.Put (FIELD_ART_IMAGE, Image)
mapContent.Put (FIELD_ART_CDATE, CDate) 'creation date
mapArtIMGs.Put(target_id, mapContent)
Next
Log("")
Catch
'Log ...
End Try
Return mapArtIMGs
end sub
Sub imgNews_Click
Wait For (AppGlobals.GetArtsNIDs (AppGlobals.user, AppGlobals.psw)) Complete (ArtsNIDs As B4XOrderedMap)
For Each nid As Int In ArtsNIDs.Keys
Wait For (AppGlobals.GetArtContent (nid, AppGlobals.user, AppGlobals.psw)) Complete (ArtContent As B4XOrderedMap)
Next
ArtContent.Values.SortType (AppGlobals.FIELD_ART_CDATE, True)
end sub