How to load updated image from server using Picasso/Glide? - java

I have more than 300 images in the app. I need to show three at a time in the screen. But loading the image every time from the server takes 1-2 secs sometimes. I want to cache the images but when image gets updated from the server the url remains same. How to use cache and automatically update image and cache it for further use?

Related

API minimize data usage

I'm making games app on android using RAWG Video Games Database.
This is how the app look like.
the problem is the API provide large image size average 1.5 MB,
it's too big for small size space in the app, and lots of data wasted.
all the solutions i found was for better performance "after downloading" the image
by scale down the resolution.
is there anyway i can make the image smaller "before download"?
or is there other APIs provide me small image for thumbnail and another one as original size?
Why not download it, make it smaller, and then delete the old version?

what does Glide do when disk storage is full?

I am using Glide in my Android application for loading images from internet. I've disabled memoryCache when loading images but diskCache is still active and it uses default strategy to cache resources on the disk. My question is What Glide do during caching resources on the disk storage if disk's storage is full and there isn't any free space on it? Will it throw and exception or what?
No it wont throw any errors. but it might give a callback in
#Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
}
Currently Glide downloads the whole image and decodes it. Then fails to write the cache and error is displayed. Next time it tries it'll download it again, and do the same thing. If this proposal is implemented it would fail at writing cache, but since it displays the image next time it MAY hit the cache and prevent downloading again. So this fix would save bandwidth and enhance UX. because of this Glide may not load images when device space run out.
Hope this answers to your question

Reload and cache again an updated image in Picasso

I have a link of an image in my code, which will be updated in server some times.
I load this image with Picasso library and I have two problems.
I want to show the updated image when it is changed in server and cache it again in Picasso.
First, the invalidate() method of Picasso does not invalidate disk cache memory (network cache) and the cached image in disk still show.
Second, for the first problem there are some answers in Stackoverflow such as this one: Abort memory cache and disk cache, The problem with this :it will not cache again the new image because of the policies, but I want to cache again the new image.
My app is connected to a server which I can tell the app whenever an image is changed, but the URL of images does not change.
What should I do?

How to resize high resolution tif images efficiently and quickly?

I am working on a project where I have users uploading print quality high resolution tif images and I need to create a lower resolution web quality preview for the user if/when they come back to view what they uploaded.
Currently I have a working solution to resize these images using ImageIO.read and ImageIO.write but it is taking up to 15 minutes to modify and save these preview images. I am wondering if there is a better solution that would take less time to complete. Or is this a RAM issue that I am experiencing?
I'm not sure what libraries you're using, but you can do this in two passes. If you're cutting the resolution by half in width and height, then simply take every other pixel and create a quick image from that. It will be low quality, but you should be able to do this very quickly even on large images. Later, perhaps with a workflow automation system, you can "slow cook" a better-quality derez and take some time to do it well.

Picture makes the App slow?

When I use a background for my Android App it begins to lagg. I'm just using :
android:background = "#drawable/picture_here"
When I click on a button it takes 2min till it reacts.
Is it because of the Emulator or am I doing something wrong ?
Of course the emulator is slow. See if you can run intel processor powered emulator to increase its performance. Also see if the image s of the appropriate format. Because heavy formats like bitmaps can be of large size. So make sure that the image is not too big.
Emulator is slow. Also you are displaying image that is too big. Take a look at image's size which must be loaded into RAM at runtime. If you are loading it into frame that is smaller than image itself it must recalculate size of it. (take DPI of device into account) Try smaller your image and run it on real device or e.g. Genymotion.
-Go to http://www.genymotion.com/ download the genymotion emulator
-make an account for free
-install what device you needed and test again the app

Categories