Refactoring

This commit is contained in:
M66B 2020-02-11 20:07:00 +01:00
parent c6f0ae6dad
commit 45556c626b
4 changed files with 16 additions and 5 deletions

View File

@ -252,7 +252,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (file.exists()) {
String html = Helper.readText(file);
if (html.toLowerCase(Locale.ROOT).contains(find)) {
String text = HtmlHelper.getPreviewText(html);
String text = HtmlHelper.getFullText(html);
if (text.toLowerCase(Locale.ROOT).contains(find))
match.matched = true;
}

View File

@ -3215,7 +3215,7 @@ class Core {
if (notify_preview_all)
try {
String html = Helper.readText(message.getFile(context));
preview = HtmlHelper.getPreviewText(html);
preview = HtmlHelper.getFullText(html);
} catch (Throwable ex) {
Log.e(ex);
}

View File

@ -1050,18 +1050,29 @@ public class HtmlHelper {
static String getPreview(String body) {
try {
return _getPreview(body);
return _getText(body, false);
} catch (OutOfMemoryError ex) {
Log.e(ex);
return null;
}
}
private static String _getPreview(String body) {
static String getFullText(String body) {
try {
return _getText(body, true);
} catch (OutOfMemoryError ex) {
Log.e(ex);
return null;
}
}
private static String _getText(String body, boolean full) {
if (body == null)
return null;
String text = JsoupEx.parse(body).text();
if (full)
return text;
String preview = text.substring(0, Math.min(text.length(), PREVIEW_SIZE));
if (preview.length() < text.length())

View File

@ -71,7 +71,7 @@ public class WorkerFts extends Worker {
File file = message.getFile(getApplicationContext());
String html = Helper.readText(file);
String text = HtmlHelper.getPreviewText(html);
String text = HtmlHelper.getFullText(html);
try {
sdb.beginTransaction();
FtsDbHelper.insert(sdb, message, text);