mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-04 03:43:55 +01:00
Prevent crash
This commit is contained in:
@@ -615,21 +615,24 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||||||
int px = (int) (24 * scale + 0.5f);
|
int px = (int) (24 * scale + 0.5f);
|
||||||
|
|
||||||
if (source != null && source.startsWith("cid")) {
|
if (source != null && source.startsWith("cid")) {
|
||||||
String cid = "<" + source.split(":")[1] + ">";
|
String[] cids = source.split(":");
|
||||||
EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid);
|
if (cids.length > 1) {
|
||||||
if (attachment == null || !attachment.available) {
|
String cid = "<" + cids[1] + ">";
|
||||||
Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid);
|
||||||
d.setBounds(0, 0, px, px);
|
if (attachment == null || !attachment.available) {
|
||||||
return d;
|
Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
||||||
} else {
|
|
||||||
File file = EntityAttachment.getFile(context, attachment.id);
|
|
||||||
Drawable d = Drawable.createFromPath(file.getAbsolutePath());
|
|
||||||
if (d == null) {
|
|
||||||
d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
|
||||||
d.setBounds(0, 0, px, px);
|
d.setBounds(0, 0, px, px);
|
||||||
} else
|
return d;
|
||||||
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
|
} else {
|
||||||
return d;
|
File file = EntityAttachment.getFile(context, attachment.id);
|
||||||
|
Drawable d = Drawable.createFromPath(file.getAbsolutePath());
|
||||||
|
if (d == null) {
|
||||||
|
d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme());
|
||||||
|
d.setBounds(0, 0, px, px);
|
||||||
|
} else
|
||||||
|
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
|
||||||
|
return d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user