Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lazy loading list

 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
    • Quote
    • Report post to moderator
    You can see this thread to see Efficient Adapter in use: Styling Items in ListViews
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic