mttkay / ignition

Kick-starts Android application development.
1.28k stars 290 forks source link

RemoteImageView's initialize leads to poor performance of RemoteImageGalleryAdapter #27

Open Steven-Meyer opened 12 years ago

Steven-Meyer commented 12 years ago

Currently in the initialize of RemoteImageView if "sharedImageLoader" is null then a new instance of RemoteImageLoader is created. This will call "enableDiskCache" which in turn calls "sanatizeDiskCache", which is a costly method.

In the getView of the RemoteImageGalleryAdapter, if convertView is null then a new instance of RemoteImageView is created, which following the flow of the above paragraph will call "sanatizeDiskCache".

This means that"sanatizeDiskCache" will be called frequently when scrolling through a gallery, and will really takes a lot of cpu time and can causes the frame rate to really slow down.

A simple work around is to set a "sharedImageLoader", stopping new instances of "RemoteImageLoader" and preventing the "sanatizeDiskCache" calls. This is an easy step, but one that was not obvious to me when setting up my gallery, and so i would presume that it would not be obvious to others doing the same.

mttkay commented 12 years ago

Good point, thanks for reporting.