Android Question Imagedownloader

db0070

Active Member
Licensed User
Longtime 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
 
Upvote 0

db0070

Active Member
Licensed User
Longtime 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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can NOT use it inside JobDone!
You need to use it inside your label click event
 
Upvote 0

db0070

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