> I'm currently using the ImageAdapter from the Hello GridView sample. > But loading the images from the web rather than using resources.
I think you need a better understanding of how adapters work to solve your problem. The getView() method of your Adapter is inkoved every time an image in your grid becomes visible (yes, including when you scroll back and forth to previously visible images). So if you have just replaced that one line image.setImageResource(int) with image.setImageDrawable(Drawable.createFromStream()) it means you are re-downloading images every time they get scrolled into view. So you need to cache those downloaded images and while you are at it make sure you cache scaled thumbnail of the image, just as big as you need them to avoid the possible problem Romain suggested. Use Bitmap.createScaledBitmap() - it's worked great for me. Also be aware that the emulator is running on your PC using that same network speed. If you want to test for real network problems you might get on a real device try starting the emulator with limited network (or on your G1 disable wireless and 3G). I alwasy run my emulator with network speed and latency set to EDGE, or for some debugging purposes even GPRS or GSM. hope that helps you, gesh. On Mar 15, 7:22 am, ifuller1 <[email protected]> wrote: > Hi Gesh, > > Thanks for the response. I'll certainly give the bitmap factory a go. > I'm currently using the ImageAdapter from the Hello GridView sample. > But loading the images from the web rather than using resources. The > problem is immediate, in that the performance doesn't degrade after re- > visits to the activity, but is instead directly proportional to the > number of images I'm displaying. > > As well as trying the bitmap factory can I ask what you think is the > best way to encourage garbage collection? Will nulling my objects be a > big help. > > Once I have it optimized I'm going to release it for free... I think > there's a big hole in androids picasa support. > > Ian > > On Mar 14, 11:38 pm, Gesh <[email protected]> wrote: > > > hi, > > > I have written 2 connected apps with some image content pulled from > > the web and must say if you handle your resources right it shouldn't > > be a problem at all. > > > Do you use your own Adapter for theGridViewor do you use some of the > > already available ones in the SDK? If you use your own you should keep > > in mind that when you deal with AdapterViews in general they keep > > references to Views you create in your adapter and recycle them, so > > try to reuse the convertView reference you get in the Adapter.getView > > (int position, View convertView, ViewGroup parent) method. > > > And although memory leaks are difficult to achieve in what sounds like > > a single activity app the other thing that comes to mind is that you > > might have memory leaks due to the way you use Drawables. Try using > > Bitmaps from the BitmapFactory.decodeStream(InputStream) method and > > maybe read this blog for more info why Drawables could cause memory > > leaks > > -http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks..... > > > cheers, > > gesh. > > > On Mar 14, 12:47 pm, ifuller1 <[email protected]> wrote: > > > > I've managed to successfully connect to the picasa web services using > > > JSON and download a list of thumbnails from my picasa album. The > > > thumbnails are all very small but I'm getting pretty terrible > > > performance (especially when compared to the native picture viewer). > > > As my main goal was getting the application working their is obviously > > > lots of optimisation work I can do but I just wanted to know where the > > > most likely cause of poor performance is coming from. Is it the memory > > > usage (so I should try cleaning up existing objects) or is it display > > > performance (can't cope with 30 thumbnails at once)? > > > > Example thumbnail > > > imagehttp://lh6.ggpht.com/_QIFTbqmwS8U/Samo30_xoBI/AAAAAAAAAEk/VeBxiukdKzU... > > > > being loaded via Drawable.createFromStream > > > > Thanks in advanced. > > > > Ian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

