Android Question How to show progressbar in Job.Complete

ronovar

Active Member
Licensed User
Longtime User
Hi,

I have Sub JobDone(Job As HttpJob) procedure that is parsing JSON from my server, all is fine but i need to show progressbar1.progress and update it on each increse I variable in Map1 JSON Parser...but it does not update on apk start, it updates it when JobDone is finished...how to do it to update progressbar in JobDone procesure? Here is example that is not working as expected:

B4X:
Sub JobDone(Job As HttpJob)
    'DECLARE - Variables
    Dim JSON As JSONParser
    Dim Map1 As Map
    Dim I As Int

    If Job.Success = True Then
        Select Job.JobName
            Case "Job0"
                'DISPLAY - Status Text
                Label1.Text = "Loading JSON..."
             
                'INITIALIZE - JSON
                JSON.Initialize(Job.GetString)

                'INITIALIZE - Map1
                Map1.Initialize
                Map1 = JSON.NextObject

                'LOOP - Throught List
                For I=0 To Map1.Size-2
 
                    If (I = Map1.Size-1) Then
                        'XYZ - Informations
                        JSON.Initialize(Job.GetString)
                        Map1 = JSON.NextObject
                        Map1 = Map1.Get("authorization")
                     
                        Authorisation(0) = Map1.Get("AAA")
                        Authorisation(1) = Map1.Get("BBB")
                        Authorisation(2) = Map1.Get("CCC")
                    Else
                        'OHOH - Informations
                        JSON.Initialize(Job.GetString)
                        Map1 = JSON.NextObject
                        Map1 = Map1.Get(CStr(I))
                        Map1 = Map1.Get("ooooo")
                                     
                        'ADD - Channels To Array
                        Channels(I,0) = I
                        Channels(I,1) = Map1.Get("www")
                        Channels(I,2) = Map1.Get("ccc")
                       ProgressBar1.Progress = I
                    End If
                Next
                'DISPLAY - Status Text
                Label1.Text = "Loading List...OK"
                ChMax = Map1.Size-2
        End Select
    End If
End Sub

Erel can you give me example code how to update progressbar position in job done?
 
Last edited:

eurojam

Well-Known Member
Licensed User
Longtime User
you should put your code in code-tags or use the code tool, then we can read your code - in that form it is very difficult....
Image2.jpg
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
you can add a DoEvents
B4X:
ProgressBar1.Progress = I
DoEvents
and normalize the max progress to 100%
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
Thanks....that works Flaweslly. I love progress bar how fast is updating and working...i was added delay routine after
ProgressBar1.Progress = I and set delay to 1ms but was slow..using DoEvents it is working fast.

Thanks for replay.
 
Upvote 0

Similar Threads

Top