private void findLinks(String text,Map<Integer,Integer> ranges,Map<Integer,MutableAttributeSet> rangesStyle){
  urlMatcher.reset(text);
  while (urlMatcher.find()) {
    int start=urlMatcher.start();
    int end=urlMatcher.end() - 1;
    if (!inRanges(start,ranges) && !inRanges(end,ranges)) {
      String foundUrl=urlMatcher.group();
      if (foundUrl.contains("..")) {
        continue;
      }
      if (foundUrl.endsWith(")") && !foundUrl.contains("(")) {
        foundUrl=foundUrl.substring(0,foundUrl.length() - 1);
        end--;
      }
      if (checkUrl(foundUrl)) {
        ranges.put(start,end);
        if (!foundUrl.startsWith("http")) {
          foundUrl="http://" + foundUrl;
        }
        rangesStyle.put(start,url(foundUrl));
      }
    }
  }
}

private void findLinks ( String text , Map < Integer , Integer > ranges , Map < Integer , MutableAttributeSet > rangesStyle ) { urlMatcher . reset ( text ) ; while ( urlMatcher . find ( ) ) { int start = urlMatcher . start ( ) ; int end = urlMatcher . end ( ) - 1 ; if ( ! inRanges ( start , ranges ) && ! inRanges ( end , ranges ) ) { String foundUrl = urlMatcher . group ( ) ; if ( foundUrl . contains ( ".." ) ) { continue ; } if ( foundUrl . endsWith ( ")" ) && ! foundUrl . contains ( "(" ) ) { foundUrl = foundUrl . substring ( 0 , foundUrl . length ( ) - 1 ) ; end -- ; } if ( checkUrl ( foundUrl ) ) { ranges . put ( start , end ) ; if ( ! foundUrl . startsWith ( "http" ) ) { foundUrl = "http://" + foundUrl ; } rangesStyle . put ( start , url ( foundUrl ) ) ; } } } }
finds all urls and saves them to be printed as clickable links .
