• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lazy loading list

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anybody tell me some good links to go over the lazy loading list concept. And any code samples that i can use.

thanks
 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For starters, the following should suffice:

1. There is a DroidFu library that you can use: it has a custom ImageView widget which automatically loads the image in bakground.
2. Apart from that you can take a look at Mark Murphy's ThumbnailAdapter class: cwac-thumbnail
3. See this tutorial. It uses a queue based implementation for executing tasks.
4. I started with something like this but then my code evolved to handle a lot of potential issues like the ones discussed here and here. You may also want to read this answer I wrote here

All the best!
 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Monu,
Thanks a lot for the list. I also found example for lazy loading lists in the API demos. I guess its the last 2 exampls the the list section.

Could you maybe have a look on those and provide your point of view?

Thanks again

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case you are talking about List13.java(SlowAdapter) and List14.java(EfficientAdapter), then let me tell you they do not have any 'Lazy-Loading-logic' in them. Instead, these two files demonstrate two different patterns that one must use to make an efficient List in Android(you should consider including them whenever applicable).

  • SlowAdapter pattern demonstrates how you can avoid doing heavy, time consuming operations whilst the list is scrolling(Touch Scroll or Fling mode). When you scroll a List, getView() method of the adapter is called. If you do heavy operations in getView() like image fetches over network, file reads etc., this would slow down the scroll and even affect the scroll animation.


  • EfficientAdapter pattern, IMO, should be used in every implementation of a ListView. It makes use of view recycling and also avoid the expensive findViewById() call by employing a static holder class.
  •  
    Monu Tripathi
    Rancher
    Posts: 1369
    1
    Android Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You can see this thread to see Efficient Adapter in use: Styling Items in ListViews
     
    They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic