Search in sources :

Example 1 with LinkExtractor

use of org.nibor.autolink.LinkExtractor in project Rocket.Chat.Android by RocketChat.

the class Linkify method markupInner.

private static SpannableString markupInner(final CharSequence text) {
    LinkExtractor linkExtractor = LinkExtractor.builder().linkTypes(sTargetType).build();
    SpannableString spannableString = new SpannableString(text);
    for (LinkSpan link : linkExtractor.extractLinks(text)) {
        final int idx1 = link.getBeginIndex();
        final int idx2 = link.getEndIndex();
        final String url = text.subSequence(idx1, idx2).toString();
        spannableString.setSpan(MarkDown.createLinkSpan(url), idx1, idx2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    return spannableString;
}
Also used : SpannableString(android.text.SpannableString) LinkExtractor(org.nibor.autolink.LinkExtractor) LinkSpan(org.nibor.autolink.LinkSpan) SpannableString(android.text.SpannableString)

Aggregations

SpannableString (android.text.SpannableString)1 LinkExtractor (org.nibor.autolink.LinkExtractor)1 LinkSpan (org.nibor.autolink.LinkSpan)1