I have an application that allows users to display photos. It is using Glide to download them.
When a user creates a photo locally, they can see it, instantly, in the application, because the app knows where the local file is.
Eventually, though, I have to upload the photo so that it is available to other users on other devices. All devices, including the one that created the photo now use the URI for the uploaded file. That means that the first time the device that created the photo views it, after it is uploaded, there is an annoying delay while the photo is downloaded again, redundantly. (After that is is in Glide's cache)
The application uploads the photo from the local file to its location behind the globally available URI. At that time it knows both the path to to local file and the URI from which it will, eventually, be downloaded.
I would love to be able, at that point, to pre-populate Glide's cache for the download URI, with the contents of the file. No redundant download; no annoying delay.
I've poked at Glide a little bit and I just don't see how to get it to do that.
Related
I have the following problem and do not quite know how to solve it:
I am loading pictures from one device to Firebase Storage Cloud. With another device, I want to download them from Firebase Storage.
So far my implementation looks like this. Every time I open the app it re-downloads and displays all the images. I can't effectively get it to save the images in the app (NOT GALLERY) and just check if there is a new image that hasn't been downloaded yet.
What you're looking for, is to cache images on an Android device. This means that once you download it, you will not need to download it again, it will always be read from the cache.
For Android, there are a few libraries that do that. One would be Glide, and another one would be Picasso. If you're using however Kotlin and Jetpack Compose, then you can use Coil.
i am using the cordova camera plugin and saving images to the gallery/photos so they don't delete as prior to this my photos would be saved to the cache and delete quickly enough.
I attach the images i take and save with camera plugin to an email.
What i do is save the ImageURI from the camera function to localstorage to be called again if i resend the email at a later date.
This method works in the short-term and images attach successfully but not after a few hours.
The imageURI of captured images is usually on the format of cdv_photo_001.jpg for example.
However, the images are saved in photos/gallery and the filenames tend to be normal "IMG_0001.JPG" format and don't attach to the email.
is there a way i can get the actual gallery name while taking a picture.
Ive tried to save the image persistently using some guides but i could never get the moveTo to work.
Anyone any ideas?
Thanks
I want to download the images thumbnail not the entire image from my firebase storage. I am using glide to load the images but i am not getting how can i load image thumbnails as it will be quicker and memory efficient.
You first need to create thumbnails for the images, likely using something like Google Cloud Functions or Google App Engine. You can write a function that takes the original image, and runs it through ImageMagick, then saves it back to Firebase Storage at a known location, say images/myImage_resized_<height>_<width>.png, which your client can then fetch.
Alternatively, you can use Imgix or Cloudinary to serve smaller images stored in Firebase Storage by providing our Download URLs to those services and fetching the images from there. If you're willing to do some more work, Google App Engine offers the App Engine Images API for free, which does many of the same things.
I am currently allowing my user to pick an image from the gallery and I load it in an ImageView. Then I store in my sharedPreferences the URI of the image in order to be able to load it again later.
It won't work, and I've noticed that somehow the URI of the picture changed.
I was wondering how to simply store the Image I got from the gallery to be able to reload it later.
Then I store in my sharedPreferences the URI of the image in order to be able to load it again later.
That is not going to work. Not only might the Uri differ, but if the Uri has a content scheme, you lose the rights to work with the content identified by the Uri after your process ends. Plus, the user might get rid of the image.
I was wondering how to simply store the Image I got from the gallery to be able to reload it later.
Use Java I/O to make a copy of the image to a file that you control (e.g., on internal storage), then use that copy. Adjust your UI to reflect this (e.g., use verbs like "import" instead of "link").
Depending on how you got that Uri, you might be able to call takePersistableUriPermission() to try to get long-term rights to the content, in which case the Uri also should be stable (assuming that the user does not move or delete the content in question).
Better to store image path in shared preferences, then reload it again
I have problem with my app, it's very slow because of using Video and images. When I play video or show images it takes time to download, the app would close during this time or it will take for ever. How can I avoid this problem? Once we have seen the image or video it should not download from server again, please give me the solution for this(Like Facebook).
First you should download the video or image in an asynctask inner class, this is why the app freezes while downloading.
You are downloading on the UI thread and this freezes your app, AsyncTask is the way to go.
Second when download is complete you could save the video, image to sdcard so you won't have to download them again next time. When you want to view the video the second time you will only have to know the file name so you could grab it from sd card. You could make a method that determines if a video on sd card is considered outdated and delete that file if true.
Also as other comments say, AQuery ( Android Query) is a library (facilitates chaining like jQuery does for javascript) that offers a lot of convenience methods for file downloading and other cool stuff. A short Google query for AQuery term should reveal tutorials and download sources.
You can use AndroidVideoCache for caching video while streaming. It allow to use cached video after single viewing.