mirror of https://github.com/M66B/FairEmail.git
Improved image caching
This commit is contained in:
parent
304ed90fe0
commit
aada937c74
|
@ -1882,7 +1882,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
new SimpleTask<Spanned>() {
|
||||
@Override
|
||||
protected Spanned onExecute(Context context, Bundle args) throws IOException {
|
||||
long id = args.getLong("id");
|
||||
final long id = args.getLong("id");
|
||||
List<Uri> uris = args.getParcelableArrayList("uris");
|
||||
boolean image = args.getBoolean("image");
|
||||
int resize = args.getInt("resize");
|
||||
|
@ -2637,7 +2637,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
Spanned spanned = HtmlHelper.fromHtml(text, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(getContext(), -1, source, true, 0, etBody);
|
||||
return ImageHelper.decodeImage(getContext(), working, source, true, 0, etBody);
|
||||
}
|
||||
}, null);
|
||||
etBody.getText().insert(etBody.getSelectionStart(), spanned);
|
||||
|
@ -4572,7 +4572,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
signature = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(getContext(), -1, source, true, 0, tvSignature);
|
||||
return ImageHelper.decodeImage(getContext(), working, source, true, 0, tvSignature);
|
||||
}
|
||||
}, null);
|
||||
tvSignature.setText(signature);
|
||||
|
|
|
@ -333,7 +333,7 @@ class ImageHelper {
|
|||
return d;
|
||||
}
|
||||
|
||||
if (!show || id < 0) {
|
||||
if (!show) {
|
||||
// Show placeholder icon
|
||||
int resid = (embedded || data ? R.drawable.baseline_photo_library_24 : R.drawable.baseline_image_24);
|
||||
Drawable d = res.getDrawable(resid, theme);
|
||||
|
@ -513,6 +513,9 @@ class ImageHelper {
|
|||
}
|
||||
|
||||
private static Drawable getCachedImage(Context context, long id, String source) {
|
||||
if (id < 0)
|
||||
return null;
|
||||
|
||||
File file = getCacheFile(context, id, source);
|
||||
if (file.exists()) {
|
||||
Log.i("Using cached " + file);
|
||||
|
@ -618,9 +621,11 @@ class ImageHelper {
|
|||
|
||||
Log.i("Downloaded image source=" + source);
|
||||
|
||||
File file = getCacheFile(context, id, source);
|
||||
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
bm.compress(Bitmap.CompressFormat.PNG, 90, os);
|
||||
if (id >= 0) {
|
||||
File file = getCacheFile(context, id, source);
|
||||
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
bm.compress(Bitmap.CompressFormat.PNG, 90, os);
|
||||
}
|
||||
}
|
||||
|
||||
Drawable d = new BitmapDrawable(res, bm);
|
||||
|
|
Loading…
Reference in New Issue