コード例 #1
0
 public static String formatUserDescription(final User user) {
   if (user == null) return null;
   final String text = user.getDescription();
   if (text == null) return null;
   final HtmlBuilder builder = new HtmlBuilder(text, false, true, true);
   final UrlEntity[] urls = user.getDescriptionEntities();
   if (urls != null) {
     for (final UrlEntity url : urls) {
       final String expanded_url = url.getExpandedUrl();
       if (expanded_url != null) {
         builder.addLink(expanded_url, url.getDisplayUrl(), url.getStart(), url.getEnd());
       }
     }
   }
   return builder.build();
 }
コード例 #2
0
 private static void parseEntities(final HtmlBuilder builder, final EntitySupport entities) {
   // Format media.
   final MediaEntity[] mediaEntities = entities.getMediaEntities();
   if (mediaEntities != null) {
     for (final MediaEntity mediaEntity : mediaEntities) {
       final int start = mediaEntity.getStart(), end = mediaEntity.getEnd();
       final String mediaUrl = TwitterContentUtils.getMediaUrl(mediaEntity);
       if (mediaUrl != null && start >= 0 && end >= 0) {
         builder.addLink(mediaUrl, mediaEntity.getDisplayUrl(), start, end);
       }
     }
   }
   final UrlEntity[] urlEntities = entities.getUrlEntities();
   if (urlEntities != null) {
     for (final UrlEntity urlEntity : urlEntities) {
       final int start = urlEntity.getStart(), end = urlEntity.getEnd();
       final String expandedUrl = urlEntity.getExpandedUrl();
       if (expandedUrl != null && start >= 0 && end >= 0) {
         builder.addLink(expandedUrl, urlEntity.getDisplayUrl(), start, end);
       }
     }
   }
 }
コード例 #3
0
 public static String formatStatusText(final Status status) {
   if (status == null) return null;
   final HtmlBuilder builder = new HtmlBuilder(status.getText(), false, true, true);
   TwitterContentUtils.parseEntities(builder, status);
   return builder.build();
 }
コード例 #4
0
 public static String formatDirectMessageText(final DirectMessage message) {
   if (message == null) return null;
   final HtmlBuilder builder = new HtmlBuilder(message.getText(), false, true, true);
   TwitterContentUtils.parseEntities(builder, message);
   return builder.build();
 }