File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Lazy loading list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Lazy loading list" Watch "Lazy loading list" New topic
Author

Lazy loading list

Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
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

Joined: Oct 12, 2008
Posts: 1369
    
    1

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!


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
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

Joined: Oct 12, 2008
Posts: 1369
    
    1

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

    Joined: Oct 12, 2008
    Posts: 1369
        
        1

    You can see this thread to see Efficient Adapter in use: Styling Items in ListViews
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Lazy loading list
     
    Similar Threads
    Synchronization for Singleton
    How to manage a very very large list in memory?
    hibernate mapping and performance
    Singleton class + Lazy loading
    lazy loading