Word break preview text

This commit is contained in:
M66B 2020-07-14 08:57:46 +02:00
parent ca84b8130f
commit 040c76a451
1 changed files with 11 additions and 4 deletions

View File

@ -1577,11 +1577,18 @@ public class HtmlHelper {
if (full)
return text;
String preview = text.substring(0, Math.min(text.length(), PREVIEW_SIZE));
if (preview.length() < text.length())
preview += "";
return truncate(text, PREVIEW_SIZE);
}
return preview;
static String truncate(String text, int at) {
if (text.length() < at)
return text;
String preview = text.substring(0, at);
int space = preview.lastIndexOf(' ');
if (space > 0)
preview = preview.substring(0, space + 1);
return preview + "";
}
static String getText(Context context, String html) {