Allow insert plain link

pull/171/head
M66B 5 years ago
parent 5a8bd2000d
commit 8a3c720a88

@ -108,6 +108,8 @@ public class StyleHelper {
} }
case R.id.menu_link: { case R.id.menu_link: {
String url = (String) args[0];
List<Object> spans = new ArrayList<>(); List<Object> spans = new ArrayList<>();
for (Object span : ss.getSpans(start, end, Object.class)) { for (Object span : ss.getSpans(start, end, Object.class)) {
if (!(span instanceof URLSpan)) if (!(span instanceof URLSpan))
@ -115,7 +117,13 @@ public class StyleHelper {
ss.removeSpan(span); ss.removeSpan(span);
} }
ss.setSpan(new URLSpan((String) args[0]), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (start == end) {
etBody.getText().insert(start, url);
end += url.length();
ss = new SpannableString(etBody.getText());
}
ss.setSpan(new URLSpan(url), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
for (Object span : spans) for (Object span : spans)
ss.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ss.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

Loading…
Cancel
Save