make image loading work again

This commit is contained in:
Morten Delenk 2022-08-15 10:35:02 +01:00
parent 9043b99914
commit df839b4c03
No known key found for this signature in database
GPG key ID: 5130416C797067B6

View file

@ -151,7 +151,7 @@ public class ItemDetailFragment extends FragmentBase<FragmentItemDetailBinding>
var fileName = image.getPath().substring(image.getPath().lastIndexOf('/'));
var path = this.requireActivity().getCacheDir().getAbsolutePath();
new File(path, "images").mkdirs();
path += new File(new File(path, "images"), fileName);
path += "/images/" + fileName;
// TODO: check if there is a better buffer size to use
// ideally I would use {@link java.nio.file.Files#copy(InputStream, Path, CopyOption...)} but it is not available on API level 21
@ -177,7 +177,8 @@ public class ItemDetailFragment extends FragmentBase<FragmentItemDetailBinding>
private Optional<Bitmap> getImageIfPresent(@NonNull URI uri) {
var fileName = uri.getPath().substring(uri.getPath().lastIndexOf('/'));
var path = this.requireActivity().getCacheDir().getAbsolutePath();
var file = new File(new File(path, "images"), fileName);
path += "/images/" + fileName;
var file = new File(path);
// Check if the image is present in the cache
if (file.exists()) {
try {