iOS Question Scrollview flicker when jobdone syncs with main thread

jb0502

Member
Licensed User
Longtime User
I have a scrollview and dynamicly created panels inside, panels filled with data comes from RDC.
Scrollview scrolls perfect in all conditions.
Except when jobdone finishes its job and syncs with MAIN.
The scrollview becomes nonresponsive for a while. After it syncs, it becomes normal again.
Anybody has any solution for this issue.
Thanks in advance.
 
Last edited:

jb0502

Member
Licensed User
Longtime User
B4X:
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
    Else
    
        If Job.JobName = "DBRequest" Then
            'ScrollView1.Panel.RemoveAllViews
            ActivityIndicator1.Visible = True
            Dim result As DBResult = reqManager.HandleJob(Job)
            'reqManager.PrintTable(result)
            If Job.Tag = "select_animal" Then
            
                For i = 0 To result.Rows.Size-1
        
                Dim items() As Object = result.Rows.Get(i)
            
                
    Dim panel1 As Panel
    Dim label1 As Label
    Dim baslik As Label
    Dim pic1 As ImageView

    
    panel1.Initialize("panel1")

panel1.Color = Colors.White
panel1.SetBorder(0,0,5)






    pic1.Initialize("pic1")
    label1.Initialize("label1")

    label1.AdjustFontSizeToFit = False
    baslik.Initialize("baslik")

    baslik.Font = Lbl.Font
    label1.Font = lbl2.Font
    pic1.Bitmap = reqManager.BytesToImage(items(0))


        
    baslik.Text = yk & "-" &items(1)
    label1.Text = items(2)  & "-" &yk

    If sol < sag Then
  

    ScrollView1.Panel.AddView(panel1,(5),(sol),(ScrollView1.Width/2-10),((pic1.bitmap.Height/pic1.bitmap.Width*ScrollView1.Width/2)+200))

    panel1.AddView(pic1,0,0,panel1.Width,(pic1.bitmap.Height/pic1.bitmap.Width*panel1.Width))
    sol = panel1.Top+panel1.Height + 10
    Else



    ScrollView1.Panel.AddView(panel1,(ScrollView1.Width/2 +5),(sag),(ScrollView1.Width/2-10),((pic1.bitmap.Height/pic1.bitmap.Width*ScrollView1.Width/2)+200))

    panel1.AddView(pic1,0,0,panel1.Width,(pic1.bitmap.Height/pic1.bitmap.Width*panel1.Width))
    sag = panel1.Top+panel1.Height +10
    End If
    baslik.Text = yk & "-" &items(1) & "-" & ScrollView1.Panel.NumberOfViews

    label1.Multiline = True


    pic1.ContentMode = pic1.MODE_FILL
    panel1.AddView(baslik,2,pic1.Height,panel1.Width,20)

    panel1.AddView(label1,2,pic1.Height+20,panel1.Width,(panel1.Height-pic1.Height-40))

    label1.TextAlignment = label1.ALIGNMENT_LEFT

   
    Dim cnv As Canvas
    cnv.Initialize(panel1)
    cnv.DrawLine(0,baslik.Top+20,panel1.Width,baslik.Top+20,Colors.red,1)
    cnv.DrawLine(0,panel1.Height - 25,panel1.Width,panel1.Height - 25,Colors.LightGray,1)
    cnv.Refresh

    yk = yk + 1

    Next
            
                
            
            End If
        End If
    End If


    ActivityIndicator1.Visible = False
    ykb = False
        If sol > sag Then
    ScrollView1.ContentHeight = sol + 10
    Else            
    ScrollView1.ContentHeight = sag + 10            
    End If
    Job.Release
End Sub
 
Last edited:
Upvote 0

jb0502

Member
Licensed User
Longtime User
Because the canvas is drawing lines for each panel1(which are created at runtime too).
Also I removed all canvases now to see if it is the reason and syncing with main thread still hangs the scroll.
 
Upvote 0

jb0502

Member
Licensed User
Longtime User
I decreased my network speed to very low to see in which step it slows down. Now each request takes 20 seconds.
I can scroll very fast when the job is handling. I check out RDC server also.
The problem occurs in the exact second of job.release.
I also tried to request 1 item only, same issue.
 
Upvote 0

jb0502

Member
Licensed User
Longtime User
Afaik customlistview is also scrollview.
And I dont know if I can make dynamic design(depending on item size)with it as in attached screenshot.
 

Attachments

  • scr01.png
    314.5 KB · Views: 214
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…