Simplification

This commit is contained in:
M66B 2023-11-28 12:38:41 +01:00
parent 66b5971847
commit d287a45d48
2 changed files with 14 additions and 9 deletions

View File

@ -3167,11 +3167,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Check for structured email
if (json_ld)
for (Element struct : document.select("script[type=application/ld+json]"))
try {
document.body().append(new JsonLd(struct.html()).getHtml(context));
} catch (Throwable ex) {
Log.w(ex);
}
document.body().append(new JsonLd(struct.html()).getHtml(context));
// Format message
if (show_full) {

View File

@ -35,14 +35,23 @@ import java.util.Iterator;
// https://structured.email/content/introduction/getting_started.html
public class JsonLd {
private final JSONObject jroot;
private JSONObject jroot;
private Throwable error = null;
public JsonLd(String json) throws JSONException {
jroot = new JSONObject(json);
public JsonLd(String json) {
try {
jroot = new JSONObject(json);
} catch (Throwable ex) {
Log.e(ex);
error = ex;
}
}
public String getHtml(Context context) throws JSONException {
public String getHtml(Context context) {
try {
if (error != null)
throw error;
Document d = Document.createShell("");
d.body().appendElement("hr");
d.body().appendElement("div")