Reminisce
Active Member
Here is my DownloadImage Sub. I needed to Download images using the same download sub.
The Above sub works, but when i try to use this in a loop that populates my customlistview,
no image is downloaded. What is wrong? I followed @Erel's advice not to use the Imagedownloader service again. I want to use this easier sub.
EDIT: even when i bring the highlighted code out of the loop, only the image on the first panel is downloaded...
@Erel this is the code that adds the PANEL.
Download Image Sub:
Sub DownloadImage(Link As String, iv As ImageView,imageround As Boolean)
Try
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) jobdone(j As HttpJob)
If j.Success Then
If imageround Then
iv.Initialize("")
Dim bm,bmp As Bitmap
bmp = j.GetBitmap
Dim nativeme As JavaObject
nativeme.InitializeContext
bm.Initialize3(bmp)
Dim bordercolor,borderwidth As Int
bordercolor = Starter.colourpurple
borderwidth = 0
Dim finalbmp As Bitmap = nativeme.RunMethod("getRoundBitmap",Array(bm,bordercolor, borderwidth))
iv.SetBackgroundImage(finalbmp)
Else If Not(imageround) Then
iv.Initialize("")
FillImageToView(j.GetBitmap,iv)
End If
End If
j.Release
Catch
Log(LastException)
End Try
End Sub
The Above sub works, but when i try to use this in a loop that populates my customlistview,
Code that populates CLV:
Sub loadlvfeed
Dim parser As JSONParser
parser.Initialize(feedresponse)
feedresponselist= parser.NextArray
feedresponsemap.Initialize
Dim imgmap,m As Map
Dim pnl As Panel
Dim imgpostimage As ImageView
Dim videoplayer As VideoView
Dim videoplayerlayout As VideoViewRelativeLayout
Dim pnlvholder As Panel
imgmap.Initialize
m.Initialize
For i = 0 To feedresponselist.Size - 1
feedresponsemap = feedresponselist.Get(i)
Dim user_profilepicture_thumb As String = feedresponsemap.Get("user_profilepicture_thumb")
Dim post_content As String = feedresponsemap.Get("post_content")
Dim post_id As String = feedresponsemap.Get("post_id")
Dim post_date As String = feedresponsemap.Get("post_date")
Dim user_verifiedaccount As String = feedresponsemap.Get("user_verifiedaccount")
Dim user_title As String = feedresponsemap.Get("user_title")
Dim post_like As Int= feedresponsemap.Get("post_like")
Dim post_type As String = feedresponsemap.Get("post_type")
Dim post_media_content As String = feedresponsemap.Get("post_media_content")
Dim user_username As String = feedresponsemap.Get("user_username")
Dim post_user_id As String = feedresponsemap.Get("post_user_id")
post_date = du.FormatDateTime(DateTime.Now, Bit.Or(du.FORMAT_SHOW_WEEKDAY, du.FORMAT_SHOW_DATE))
If user_verifiedaccount = 1 And user_title <> "" Then
user_title = user_title
End If
If user_verifiedaccount = 0 Then
user_title = "Unverified"
End If
If user_verifiedaccount = 1 And user_title = "" Then
user_title = "Verified"
End If
If lvmenufeed.thesizer = 0 And post_type = postype(1) And loadoldpost = False Then
lvmenufeed.Add(feedpostpanel(user_profilepicture_thumb,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,20%y),feedpostpanelheight,Null)
Else If lvmenufeed.thesizer <> 0 And post_type = postype(1) And loadoldpost =False Then
lvmenufeed.InsertAt(0,feedpostpanel(user_profilepicture_thumb,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,20%y),feedpostpanelheight,Null)
Else If lvmenufeed.thesizer <> 0 And post_type = postype(1) And loadoldpost =True Then
lvmenufeed.InsertAt(lvmenufeed.thesizer,feedpostpanel(user_profilepicture_thumb,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,20%y),feedpostpanelheight,Null)
Else If lvmenufeed.thesizer = 0 And post_type = postype(2) Then
lvmenufeed.Add(feedimagepostpanel(user_profilepicture_thumb,post_media_content,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,imagepostpanelheight),imagepostpanelheight,Null)
Else If lvmenufeed.thesizer <> 0 And post_type = postype(2) Then
lvmenufeed.InsertAt(0,feedimagepostpanel(user_profilepicture_thumb,post_media_content,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,imagepostpanelheight),imagepostpanelheight,Null)
Else If lvmenufeed.thesizer <> 0 And post_type = postype(2) And loadoldpost =True Then
lvmenufeed.InsertAt(lvmenufeed.thesizer,feedimagepostpanel(user_profilepicture_thumb,post_media_content,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,imagepostpanelheight),imagepostpanelheight,Null)
Else If lvmenufeed.thesizer = 0 And post_type = postype(3) Then
lvmenufeed.Add(feedvideopostpanel(user_profilepicture_thumb,post_media_content,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,videopostpanelheight),videopostpanelheight,Null)
Else If lvmenufeed.thesizer <> 0 And post_type = postype(3) Then
lvmenufeed.InsertAt(0,feedvideopostpanel(user_profilepicture_thumb,post_media_content,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,videopostpanelheight),videopostpanelheight,Null)
Else If lvmenufeed.thesizer <> 0 And post_type = postype(3) And loadoldpost =True Then
lvmenufeed.InsertAt(lvmenufeed.thesizer,feedvideopostpanel(user_profilepicture_thumb,post_media_content,user_title,user_username,post_content,post_user_id,post_date,post_id,post_like,lvmenufeed.AsView.Width,videopostpanelheight),videopostpanelheight,Null)
End If
If post_type = postype(3) Then
pnl = lvmenufeed.GetPanel(0)
pnl.Tag = "videolayout"
currentlayout = pnl.Tag
pnlvholder = pnl.GetView(11)
videoplayer.Initialize("")
videoplayer= pnlvholder.GetView(0)
videoplayer.LoadVideo("http",Starter.serverlink&"uservideos/"&videoplayer.Tag)
'videoplayer.MediaControllerEnabled = False
'videoplayer.Play
End If
'If the post Is an image, get the image link from tag And download
If post_type = postype(2) Then
pnl = lvmenufeed.GetPanel(0)
imgpostimage.Initialize("")
imgpostimage= pnl.GetView(11)
DownloadImage(Starter.serverlink&"userimages/"&imgpostimage.Tag,imgpostimage,False)
End If
''/insert the imgprofilepic tag and add to map then download the profile pictures after getting the index and download it..
'//get the profile picture link and load it
Dim pnl2 As Panel
pnl2 = lvmenufeed.GetPanel(0)
Dim imgprofpic2 As ImageView = pnl2.GetView(1)
Next
''reset the load more boolean into false
loadoldpost = False
End Sub
EDIT: even when i bring the highlighted code out of the loop, only the image on the first panel is downloaded...
@Erel this is the code that adds the PANEL.
Last edited: