In one section of my app , I m showing images to 1024+ websites inside a gridview. When the images are not present on the devices they are downloaded with an async task and the image is saved in the data folder. The grid view has a section indexer, adapter and fast scroll associated with it.
However I have noticed that the app becomes really slow when I try to fast scroll to different positions in the app. A solution \[here\]\[1\] hints implementing a hashmap to store images. The total size of the images I have are around .3mb . Will storing the bitmap in the map help speed up the app ?
Related
I have implemented a custom version of bitmap loader. I have an auto scroll list of images
of movies. When the user presses and holds the d-pad i start scrolling the list at Speed 1. We have speed 2 and 3 which scroll the list very fast so I have to load the images very fast.
So I created a circular list to load 50 images first then based on the current position I load the 25 images and discard the older 25 images.
I also tried the Glide preload https://muyangmin.github.io/glide/int/recyclerview.html but this does not work well in speed 3 and shows empty tiles instead of images
When I am doing the profiling i am seeing that 395MB memory is used by FinalizerRefrenace
FinalizerReference is held by the bitmaps I am using.
How can I fix the memory leak? I tried calling the recycle when the user closed the seek, still no luck.
Images i have are very small in size, mostly 10kb. Why do they take 100 Mb in memory?
Is there any other library I can use to show these images on a fast scrolling list for android TV?
I need to display a list of items each with text and various number of images.
I'm currently using a ListView with custom adapter to show these items. And for each item, I used a HorizontalScrollView with a LinearLayout in it to display the images. In the getView method of the ListView, I read the image URIs of each item and dynamically create ImageViews, then load the images asynchronously. I used a ViewHolder to hold the LinearLayout which contains all the ImageViews of each item.
The problem is, if I scroll down the ListView and scroll back, I'll lost the content of the item, which means I have to load the images again. And most of the images are too large and loads very slow. Actually on my app the screen can show only about 2 or 3 items once, so the scroll happens very frequently.
I have some ideas to improve this, but I'm not sure whether one of them will results better.
Since I'm just showing a thumbnail of each image, maybe I can save the thumbnails into a temp dir and load them dynamically, loading small images will be much faster. And I might have to clear that temp dir when it gets large.
I have at most 9 images for each item, so it might still be slow even if I cache the thumbnails and scroll frequently. And maybe I have to show the list manually instead of using ListView, so each item will not be reused, and the load will happen only once. But, the list will grow large in the future, if I preserve like 100 items in the LinearLayout my app may still crash.
Other better options...
Any advice will be helpful! Thanks!
You can use LazyLoading to display your image. You can use Universal Image Loader for this purpose. What lazyloading does is download an image once, cache it and display the image from cache during subsequent requests.
So I have a listview with an image and some text hooked by a custom array adapter. The problem I am facing is that the image is still loading a little bit too slow for my liking. I've watched the google tech talk and attempted to optimize my list by resusing the view by the convertView (if it's null then inflate, if not, resuse). I've also spawned AsyncTasks to load the bitmap with BitmapFactory.Options inSampleSize set to a power of 2, since the image is relatively small. I've also used the ViewHolder pattern to reduce findViewById calls.
However, even with this, when I scroll through my list, it is very noticeable how the convertViews are being reused because the image constantly gets updated as I scroll up and down.
What I noticed in the stock Android photo gallery is, with the hundreds of photos that I have, when I scroll through quickly, the photos initially load slowly, but then get cached. The amount cached is MUCH more than what the screen is capable of showing, so as I scroll, initially the photos load seamlessly until I scroll pass the amount of photos cached, and then the reload of photos is noticeable again.
Is there a way to do this with the ArrayAdapter? Basically, store more than the 9 views within my listview (What my screen is capable of showing) for the purposes of when a user scrolls down quickly, the user would have to scroll down a lot before the convertView is reused and thus the noticeable image reloads?
Thanks in advanced!
Load the images in the background, using multiple parallel threads.
For example: Sending Operations to Multiple Threads; the sample app downloads thumbnails from the Picasa Featured Photos RSS feed. Hope this helps.
I am using GridView in my app. The images for gridview are
I download them from network.
Downscale them to required size.
Write them to file,
All 3 steps are done using AsyncTask. Then I update UI. Next time when I open GridView, I simply decode it from sdcard. The image count is around 15. When I do memeinfo dumpsys on my app, my heap size keeps growing from 12 to 50. My question is , will gridview automatically recycle the bitmaps passed in adapter or we have to do for it. I get OutOfMemoryException.I see many links how to handle bitmaps efficiently including android link and I have implemented them in my app but no link explains bitmap recycle in gridview.Please help me.
I want to display a large number of images(say 500).i am currently displaying them in a scrollable grid layout by lazyloading images(very similar to fedor's lazylist). but i am having issues while scrolling the grid. when i scroll the grid, the views get refreshed and the actual images are reloaded. so, even the images that were displayed earlier are refetched from SD card. this causes a very slow UI. is there any solutions for this.(i.e is there a way to tell the grid view not to refesh views on scrolling).
or
is there any other better way to display large number of images.
Thumbnails would speed things up a bit.
Check out: Android how to create runtime thumbnail