Hi There:) I am trying to create Image Gallery in Android, I am trying to load Thumbnails from HD images(more than 1000) from local device.
Glide.with(context)
.load(Uri.fromFile(new File(MyPhotoList.get(position).getPath()))).override(110,110)/*.thumbnail(0.1f)*/
.placeholder(R.color.colorAccent).into(holder.image);
But on scroll, RecycleView stucks and load image after few sec.(CPU: 70-80%, 180 MB, It consumes.)
(Test Device config. Deca-core 2.3 GHz, 4 Gb RAM).
Could you please suggest me, how to make smooth scrolling for image gallery.
I think this is normal behavior. On every another app launch (after the first one) glide will load those photos from its cache so it will be much smoothier.
To explain this just calculate, the phone needs to load e.g 20 photos those size together is about ~200/300 MB. Now take device's flash memory read speed. Most of devices may have about speed rate up to ~120 mb/s, so it means it may load those photos in few seconds.
Take a quick try with stock Gallery app on your phone. Open this and swipe down and see images and videos loading and compare with your app speed. Then you will know how big is difference againist those apps if any.
Related
I am building a flutter ebook app. When the user is reading, the images take quite a while to load since they are over 1 mb in size. This is not a problem for most users with a decent internet connection, but for many others it is. Is it possible to control the quality of the image when being loaded from the internet by controlling how much to download, similar to when you search google images and the images progressively become more vibrant and their resolution increases,but in my case I stop it at a certain quality decided by the user. Thank you.
It sounds like you need to solve this on the server side and have an option in the Flutter app to choose the quality. An example would be to have 5 versions of each image at 5 quality levels and let the user choose the quality level. You can then have a quality parameter in the url you fetch images from. Let's say that the user wants page 12 of a book with a quality level of 2, the url can be something like
"https://mybackend.com/book-title/12/2".
Implementing this solely in Flutter won't solve the internet issue. The app will still download a 1MB image and then you could compress it before showing it but that won't matter.
I am developing an android app which needs to load a big image quickly. Using Instagram on Android I have noticed a feature they have that I cannot figure out how it works. Instagram users have a feed which displays usually a scroll list with a bunch of small thumbnails:
When you click an thumbnail image you get sent to another page(assuming fragment) that shows a bigger version of the image which appears instantly (to the human eye it looks instant)
You can scroll through all these thumbnails which means a lot of thumbnails display very quickly which I can understand because the images are small and sending over the network would be relatively quick. The problem I am understanding is how the larger images appear so quickly!? When the app downloaded the thumbnails are the larger images downloaded at the same time (I do not think this is the case because it would be such a waste of network traffic since most users on't click on every thumbnail? What technique is being used to have such fast response times for large images? I thought it maybe because of cache, but it happens when I click a picture I have never seen before.I is so fast it looks like it even is not hitting the network.
How clicking on a thumbnail image produces a a larger image so quickly?
Uses faster CDN networks to fetch images
Uses Fresco for image loading which implements progressive image loading
Uses RecyclerView, image loading is triggered when ever you stop scrolling.
Probably uses webp and jpg image formats
Images are cached for later use
I'm developing an app and I got several HD Images (PNG Files) throughout the app. To navigate through the app as quickly as possible, I want to load all pictures in RAM and display them when the certain activity starts.
Means each activity has a HD picture.
Since it is quite impossible to load a 32bit HD Image to the RAM of the app, I had to resize them using that bitmap shit of Android. But I don't want to resize them.
Is it possible to load all HD images at the beginning of the app to the RAM? I don't understand why there are HD 3D games like Modern Combat 5 have no problems with that and just take the amount of RAM they need and I can't even load 7 or 8 HD Images at once to my app. Is there a trick? How can I get a Heap large enough for all my stuff to load at once and keep it in RAM while the app is active?
Thank you in advance
You need to recycle() your bitmaps after you complete the work with bitmap, so that will clear your memory :). Read this Displaying Bitmaps Efficiently
I am into developing an android app which fetches images from server. A single activity downloads more than 10 images from the server. So, what should be the size of images(in bytes) so that the app runs smoothly and swiftly?
It is not the size of images that really matters..its the resolution of the image that really matters. When you try to take that image to a bitmap variable, the memory is consumed to represent each pixel of your image. Since you are working in a client server scenario, the size will become a problem when it comes to download and store the image.
If you don't need to zoom the image in your application, it is better to use image with standard resolution that matches screen size.
Its better for you to use some image manager libraries for these kind of image loading purpose, so that they will manage the memory issues to an extend. Check this post.
I have a gridview of images in my android app. It is an image gallery for an artist, so there are about 180 relatively high quality images in the resource folder. It works fine in the emulator and on my HTC Evo in debug mode. However when I publish it to the market and install it from there it crashes when the gridview is attempted to be loaded.
Is there a limit on locally defined images or is there a better way to manage so many images?
I went ahead and processed all the images into a worthwhile size for the respective
/res/drawable-hdpi (around 1000px wide or high)
/res/drawable-mdpi (max 300px)
/res/drawable-ldpi (max 75px)
and even though the compiled app is even bigger, it runs much better and does not crash on opening the gallery gridview.