mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
c6f0ae6dad
commit
45556c626b
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue