Android Question [Resolved] ImageDownloader and Image in Cache

ALBRECHT

Active Member
Licensed User
Hello,

Inside the B4A file : (see below : Matmed.zip - made with 3.90 => 9.30)

i have inserted :
One Activity : "Main"
And the ImageDownloader library


- I have made a loop with my api to display product categories lines
- when we click on a line, then that display the sub categories, and so on ...
- And if you click on the Return button you go to the Parent category.

But each time, the images are downloaded from the server (see the display delay)
whereas i use the ImageDownloader library where i have read that it admin the cache ?

Some one, could help me to display the image already in the cache for faster process ?

Regards
Michel
 

Attachments

Last edited:

ALBRECHT

Active Member
Licensed User
sorry it's a mistake : i m using the last : 9.30
perhaps i will becam dyslexic:(

sorry i m newbie with b4x and I'm stuck on that pb since more 3 days !
 
Last edited:

ALBRECHT

Active Member
Licensed User
cool as an answer!

I subscribed in 2017, but I'm only now starting to use this dev tool!

Now, if you are so tired, do not answer and leave room for other volunteer members to help novices like me!
 

DonManfred

Expert
Licensed User
Find stttached a change app. Replaced customlistview with xcustomlistview and did some other changes. You can just ignore it and use your crappy code.
Also added that images are only downloaded if not already on the device.

Good luck.
 

Attachments

Last edited:

ALBRECHT

Active Member
Licensed User
For your information, I have not had a post since the summer of 2019.

But, as you say, if I have to learn to code, thank you for learning to stay friendly and change your language on a professional forum!

I did not attack you ... there are drugs to help you fix that
 

ALBRECHT

Active Member
Licensed User
Ok, for some that have that had the same pb.

The ImageDownloader service i have donwload was not the good on,

So i had to replace :

B4X:
Sub Download (ImageViewsMap As Map)
    For i = 0 To ImageViewsMap.Size - 1
        tasks.Put(ImageViewsMap.GetKeyAt(i), ImageViewsMap.GetValueAt(i))
        Dim link As String = ImageViewsMap.GetValueAt(i)
            ongoingTasks.Put(link, "")
            Dim j As HttpJob
            j.Initialize(link, Me)
        j.Download(link)
    Next
End Sub
by :

B4X:
Sub Download (ImageViewsMap As Map)
    For i = 0 To ImageViewsMap.Size - 1
        tasks.Put(ImageViewsMap.GetKeyAt(i), ImageViewsMap.GetValueAt(i))
        Dim link As String = ImageViewsMap.GetValueAt(i)
        If cache.ContainsKey(link) Then
            Dim iv As ImageView = ImageViewsMap.GetKeyAt(i)
            iv.SetBackgroundImage(cache.Get(link))
        Else If ongoingTasks.ContainsKey(link) = False Then
            ongoingTasks.Put(link, "")
            Dim j As HttpJob
            j.Initialize(link, Me)
            j.Download(link)
        End If
    Next
End Sub
probably a copy mistake

and like that, it works great.

if it can be helpful to someone ...
 
Top