mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-25 23:20:53 +01:00
Fixed showing cached images
This commit is contained in:
@@ -188,11 +188,20 @@ public class HtmlHelper {
|
||||
File dir = new File(context.getCacheDir(), "images");
|
||||
if (!dir.exists())
|
||||
dir.mkdir();
|
||||
File file = new File(dir, id + "_" + source.hashCode());
|
||||
File file = new File(dir, id + "_" + Math.abs(source.hashCode()) + ".png");
|
||||
|
||||
if (file.exists()) {
|
||||
Log.i("Using cached " + file);
|
||||
return Drawable.createFromPath(file.getAbsolutePath());
|
||||
Bitmap bm = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
if (bm == null) {
|
||||
Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
|
||||
d.setBounds(0, 0, px, px);
|
||||
return d;
|
||||
} else {
|
||||
Drawable d = new BitmapDrawable(bm);
|
||||
d.setBounds(0, 0, bm.getWidth(), bm.getHeight());
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user