Jsoup parse from file to reduce memory usage

This commit is contained in:
M66B
2020-02-20 10:07:01 +01:00
parent 48a5278ba0
commit 873a696a52
6 changed files with 50 additions and 13 deletions

View File

@@ -1690,18 +1690,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (!file.exists())
return null;
String body = Helper.readText(file);
if (!TextUtils.isEmpty(body))
if (file.length() > 0)
signed_data = false;
args.putBoolean("signed_data", signed_data);
Document document = JsoupEx.parse(body);
Document document = JsoupEx.parse(file);
HtmlHelper.cleanup(document);
// Check for inline encryption
int begin = body.indexOf(Helper.PGP_BEGIN_MESSAGE);
int end = body.indexOf(Helper.PGP_END_MESSAGE);
args.putBoolean("inline_encrypted", begin >= 0 && begin < end);
boolean iencrypted = HtmlHelper.contains(document, new String[]{
Helper.PGP_BEGIN_MESSAGE,
Helper.PGP_END_MESSAGE
});
args.putBoolean("inline_encrypted", iencrypted);
// Check for images
boolean has_images = false;
@@ -1752,7 +1753,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
HtmlHelper.removeTrackingPixels(context, document);
if (debug) {
Document format = JsoupEx.parse(document.html());
Document format = JsoupEx.parse(file);
format.outputSettings().prettyPrint(true).outline(true).indentAmount(1);
Element pre = document.createElement("pre");
pre.text(format.html());