Android Question Imagedownloader and lazyloading

Discussion in 'Android Questions' started by Sasuke Sama, Jun 22, 2019.

  1. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    Hi
    Can someone give me a small project or example of combining them as one? I've been trying but with no luck
    I have a larg json with over 900 images and using the imagedownloader alone makes the app lagging as hell XD
    Thanx
     
  2. Brandsum

    Brandsum Well-Known Member Licensed User

    Check this out.
     

    Attached Files:

    Sasuke Sama likes this.
  3. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    That made me more confused @_@ ..
     
  4. Brandsum

    Brandsum Well-Known Member Licensed User

    How?
     
  5. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    You are loading the clv inside an imageview ? as far as i understood.
    i mean i have the imageview inside a layout with other views like labels and i want to load that layout inside the clv
     
  6. Brandsum

    Brandsum Well-Known Member Licensed User

    For a quick illustration, I added imageviews inside a clv. If you want to load a layout having imageview then just search for that imageview inside visible panels like this,
    Code:
    For i = FirstIndex To LastIndex
        
    Dim p As Panel = CLV.GetPanel(i)
        
    For Each v As View In p.GetAllViewsRecursive
            
    If v Is ImageView Then
                
    Dim iv As ImageView = v
                
    If iv.Bitmap = Null Then
                    links.Put(iv, iv.Tag)
                
    End If
            
    End If
        
    Next
    Next
     
    Sasuke Sama likes this.
  7. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    Im tired :(
    This dosent work
    Code:
    Sub CLV_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
        
    Dim links As Map
        links.Initialize
        
    For i = FirstIndex To LastIndex
            
    Dim p As Panel = clv.GetPanel(i)
            
    For Each v As View In p.GetAllViewsRecursive
                
    If v Is ImageView Then
                    
    Dim iv As ImageView = v
                    
    If iv.Bitmap = Null Then
                        links.Put(iv, 
    "https://images.wallpaperscraft.com/image/tree_fog_grass_119819_800x600.jpg")
                    
    End If
                
    End If
            
    Next
        
    Next
        CallSubDelayed2(ImageDownloader, 
    "Download", links)
    End Sub

    i use this code to load the items in the clv

    Code:
    For i=0 To imglinks.Size-5
    Dim p As Panel
    p.Initialize(
    "p")
    p.LoadLayout(
    "card1")
    p.SetLayout(
    0,0,Activity.Width,180dip)
            clv.Add(p,
    "")
        
    Next
    items loads fine but no images

    sorry in advance and thank you
     
  8. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    Got it work thank you sooooooooooooo much
     
    Brandsum likes this.
  9. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    one last question sir
    how can i remove the unvisable panels with this code?
    Code:
    'not visible
                If p.NumberOfViews > 0 Then
                    p.RemoveAllViews 
    '<--- remove the layout
                End If
    im trying to add it to your code but it gives me a blank list
    thank you so much
     
  10. Brandsum

    Brandsum Well-Known Member Licensed User

    Didn't understand your query. Do you want to remove the panels which are above/below the visible screen? Then you have to reload that layout again when those become visible, and this will consume more CPU and internet data as those images will be downloaded again.
     
  11. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    Yes that is what i want to do
    As far as the lazyloading example says removing invisible panels will make the app faster to load larg lists
     
  12. Brandsum

    Brandsum Well-Known Member Licensed User

    Then while creating the list instead of loading the layout, set all the data as a map or custom type to the value of clv item. Load the layout after this line
    Code:
    Dim p As Panel = clv.GetPanel(i)
    and set your data.

    And remove all the views of a clv item if that is out of the visible bound (less than FirstIndex or greater LastIndex)
     
    Last edited: Jun 23, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice