Small improvement

This commit is contained in:
M66B 2018-09-13 19:03:50 +00:00
parent 880c0d4326
commit c9c1a120cd
1 changed files with 8 additions and 6 deletions

View File

@ -611,7 +611,7 @@ public class FragmentCompose extends FragmentEx {
actionLoader.load(this, args); actionLoader.load(this, args);
} }
private EntityAttachment addAttachment(Context context, long id, Uri uri, boolean image) throws IOException { private static EntityAttachment addAttachment(Context context, long id, Uri uri, boolean image) throws IOException {
EntityAttachment attachment = new EntityAttachment(); EntityAttachment attachment = new EntityAttachment();
String name = null; String name = null;
@ -1195,11 +1195,13 @@ public class FragmentCompose extends FragmentEx {
@Override @Override
public Drawable getDrawable(String source) { public Drawable getDrawable(String source) {
if (source != null && source.startsWith("cid")) { if (source != null && source.startsWith("cid")) {
String cid = source.split(":")[1]; String[] cid = source.split(":");
File file = EntityAttachment.getFile(getContext(), Long.parseLong(cid)); if (cid.length > 1) {
Drawable d = Drawable.createFromPath(file.getAbsolutePath()); File file = EntityAttachment.getFile(getContext(), Long.parseLong(cid[1]));
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); Drawable d = Drawable.createFromPath(file.getAbsolutePath());
return d; d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
} }
float scale = getContext().getResources().getDisplayMetrics().density; float scale = getContext().getResources().getDisplayMetrics().density;