mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 00:53:26 +02:00
Jsoup parse from file to reduce memory usage
This commit is contained in:
@@ -64,6 +64,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -1249,6 +1250,36 @@ public class HtmlHelper {
|
||||
return (length >= max);
|
||||
}
|
||||
|
||||
static boolean contains(Document d, String[] texts) {
|
||||
Map<String, Boolean> condition = new HashMap<>();
|
||||
for (String t : texts)
|
||||
condition.put(t, false);
|
||||
|
||||
for (Element elm : d.select("*"))
|
||||
for (Node child : elm.childNodes()) {
|
||||
if (child instanceof TextNode) {
|
||||
TextNode tnode = ((TextNode) child);
|
||||
String text = tnode.getWholeText();
|
||||
for (String t : texts)
|
||||
if (!condition.get(t) && text.contains(t)) {
|
||||
condition.put(t, true);
|
||||
|
||||
boolean found = true;
|
||||
for (String c : texts)
|
||||
if (!condition.get(c)) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (found)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static Spanned fromHtml(@NonNull String html) {
|
||||
return fromHtml(html, null, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user