Android Question Imagedownloader

db0070

Active Member
Licensed User
I am using ImageDownloader.
I have a customelistview that shows the file names that can be downloaded. The user is given the option to download any file by clicking on the appropriate label on the customlistview.
I want to color the label to after the file is downloaded. The problem is if the user presses 4 or 5 labels continuously, and the links get queued in HTTP Job, how can I determine in JobDone which label's file was downloaded so that I can color it? Hope this makes sense.

It's easy to color as the user presses, but I want color it after the download has completed.
 

Brandsum

Well-Known Member
Licensed User
If you are using wait for then on job success change the color of the sender(label).

B4X:
Dim lbl as label=Sender
 

db0070

Active Member
Licensed User
Does not work, gives error java.lang.ClassCastException: cannot be cast to android.view.View
when executing line lbl.SetBitmap(LoadBitmap(File.DirAssets,"buttons_PNG163.png"))

B4X:
Sub JobDone(Job As HttpJob)
    Dim ss As String
    ongoingTasks.Remove(Job.JobName)
    If Job.Success Then
        Dim bmp As Bitmap = Job.GetBitmap
        cache.Put(Job.JobName, bmp)
        If tasks.IsInitialized Then
            For i = 0 To tasks.Size - 1
                Dim link As String = tasks.GetValueAt(i)
                If link = Job.JobName Then
                    Dim iv As ImageView = tasks.GetKeyAt(i)
                    ss= link.SubString(link.Length-15)
                    Dim out As OutputStream = File.OpenOutput(File.DirInternal, ss, False)
                    File.Copy2(Job.GetInputStream, out)
                    out.Close '<------ very important
                    Log("close " & ss)
                    iv.SetBackgroundImage(bmp)
                    Dim lbl As B4XView = Sender
                    lbl.SetBitmap(LoadBitmap(File.DirAssets,"buttons_PNG163.png"))
                End If
            Next
        End If
    Else
        Log("Error downloading image: " & Job.JobName & CRLF & Job.ErrorMessage)
    End If
    Job.Release
End Sub
 

db0070

Active Member
Licensed User
Is there any way that a label's Sender value can sent to the label's click event after the download is complete?
 
Top