This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Android and the fly likes Help with Android Application Design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Help with Android Application Design" Watch "Help with Android Application Design" New topic
Author

Help with Android Application Design

zoheb hassan
Ranch Hand

Joined: Apr 01, 2009
Posts: 150

Hello Guys,

I am working on an android application, This app fetches data from an web service which is in XML which i parse and store in form of an Data Object now this data includes image Url which i retrieve while displaying it in a list.But due to network look ups the scrolling has become sluggish.Now my question is

1)Should i persist this retrieved data including the images to avoid multiple network look ups say like store data retrieved into sharedPreferences or database and then load it from here into ListView

or

2)Use lazy loading for list and persist data via softReferences
Worry in case 2 is that the data might get Garbage collected early

3)What is the best architecture for this app??

Also the application retrieves 3 distinct Data Sets where two of them need the first one's data to process their request, Any help in this regard will be mighty useful

Thanks & Regards
Zoheb
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Loading images like this is a problem on all types of devices. What needs to be done, is the retrieval of the images themselves needs to run on a separate thread asynchronously. Which means in a separate thread. When the image is loaded, that thread then populates the UI with the image. You can also do some caching after the image is loaded, so that you can start your new thread, look in the cache to see if the image is already there, if not then go get the image. When the image is loaded, put it in to the Cache, and then put the image on the UI.

I believe there is a library already out there for doing this, I think I had found one a while ago, but I can't remember, wait found it, it is called Square Wolf Android Image Cache.

I use one just like it on my iPhone apps that use images in a Table.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
zoheb hassan
Ranch Hand

Joined: Apr 01, 2009
Posts: 150

Hey Mark thanks a ton man, I was thinking of doing it the say you suggested because repeated Network look ups will most definitely be costly. Will definitely check out the library you suggested
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help with Android Application Design