Example usage for twitter4j URLEntity getDisplayURL

List of usage examples for twitter4j URLEntity getDisplayURL

Introduction

In this page you can find the example usage for twitter4j URLEntity getDisplayURL.

Prototype

String getDisplayURL();

Source Link

Document

Returns the display URL if mentioned URL is shorten.

Usage

From source file:com.dwdesign.tweetings.util.Utils.java

License:Open Source License

private static void parseEntities(final HtmlBuilder builder, final EntitySupport entities) {
    final URLEntity[] urls = entities.getURLEntities();
    // Format media.
    final MediaEntity[] medias = entities.getMediaEntities();
    if (medias != null) {
        for (final MediaEntity media : medias) {
            final URL media_url = media.getMediaURL();
            if (media_url != null) {
                builder.addLink(parseString(media_url), media.getDisplayURL(), media.getStart(),
                        media.getEnd());
            }//w ww  .  j  a v  a 2 s  .c o  m
        }
    }
    if (urls != null) {
        for (final URLEntity url : urls) {
            final URL tco_url = url.getURL();
            final URL expanded_url = url.getExpandedURL();
            if (tco_url != null && !url.getDisplayURL().contains("tl.gd")) {
                builder.addLink(parseString(tco_url), url.getDisplayURL(), url.getStart(), url.getEnd());
            } else if (expanded_url != null && url.getDisplayURL().contains("tl.gd")) {
                builder.addLink(parseString(expanded_url), url.getDisplayURL(), url.getStart(), url.getEnd());
            }
        }
    }
}

From source file:com.freshdigitable.udonroad.module.realm.URLEntityRealm.java

License:Apache License

URLEntityRealm(URLEntity urlEntity) {
    this.url = urlEntity.getURL();
    this.expandedUrl = urlEntity.getExpandedURL();
    this.displayUrl = urlEntity.getDisplayURL();
    this.start = urlEntity.getStart();
    this.end = urlEntity.getEnd();
}

From source file:com.freshdigitable.udonroad.module.realm.URLEntityRealm.java

License:Apache License

@NonNull
private static URLEntityRealm createFromRealm(URLEntity urlEntity, Realm realm) {
    final URLEntityRealm created = realm.createObject(URLEntityRealm.class, urlEntity.getURL());
    created.displayUrl = urlEntity.getDisplayURL();
    created.expandedUrl = urlEntity.getExpandedURL();
    return created;
}

From source file:com.freshdigitable.udonroad.module.realm.URLEntityRealm.java

License:Apache License

private static boolean hasDisplayUrl(URLEntity found) {
    return !TextUtils.isEmpty(found.getDisplayURL()) && !TextUtils.isEmpty(found.getExpandedURL());
}

From source file:com.freshdigitable.udonroad.QuotedStatusView.java

License:Apache License

@Override
protected CharSequence parseText(Status status) {
    String text = getBindingStatus(status).getText();
    final URLEntity[] urlEntities = status.getURLEntities();
    for (URLEntity u : urlEntities) {
        text = text.replace(u.getURL(), u.getDisplayURL());
    }//w ww .j  a  va  2 s. c o m
    return removeMediaUrl(text, status.getExtendedMediaEntities());
}

From source file:com.freshdigitable.udonroad.SpannableStringUtil.java

License:Apache License

private static List<SpanningInfo> createURLSpanningInfo(final String text, URLEntity[] urlEntities,
        @Nullable String quotedStatusIdStr) {
    List<SpanningInfo> info = new ArrayList<>(urlEntities.length);
    for (URLEntity u : urlEntities) {
        int start = text.indexOf(u.getURL());
        int end = start + u.getURL().length();
        if (isInvalidRange(text, start, end)) {
            if (TextUtils.isEmpty(u.getExpandedURL())) {
                continue;
            }/*from   w  w  w .ja v  a2s .c o m*/
            start = text.indexOf(u.getExpandedURL());
            end = start + u.getExpandedURL().length();
            if (isInvalidRange(text, start, end)) {
                continue;
            }
        }
        if (!TextUtils.isEmpty(quotedStatusIdStr) && u.getExpandedURL().contains(quotedStatusIdStr)) {
            info.add(new SpanningInfo(null, start, end, ""));
        }
        info.add(new SpanningInfo(new URLSpan(u.getExpandedURL()), start, end, u.getDisplayURL()));
    }
    return info;
}

From source file:com.freshdigitable.udonroad.StatusView.java

License:Apache License

@Override
protected String parseText(Status status) {
    final Status bindingStatus = getBindingStatus(status);
    String text = bindingStatus.getText();
    final String quotedStatusIdStr = Long.toString(bindingStatus.getQuotedStatusId());
    final URLEntity[] urlEntities = bindingStatus.getURLEntities();
    for (URLEntity u : urlEntities) {
        if (bindingStatus.getQuotedStatus() != null && u.getExpandedURL().contains(quotedStatusIdStr)) {
            text = text.replace(u.getURL(), "");
        } else {// ww w . j  av  a2s  . com
            text = text.replace(u.getURL(), u.getDisplayURL());
        }
    }
    return removeMediaUrl(text, bindingStatus.getExtendedMediaEntities());
}

From source file:com.freshdigitable.udonroad.UserInfoView.java

License:Apache License

private void bindURL(User user) {
    final URLEntity urlEntity = user.getURLEntity();
    if (urlEntity != null) {
        final String displayURL = urlEntity.getDisplayURL();
        final String expandedURL = urlEntity.getExpandedURL();
        final String plainUrl = urlEntity.getURL();
        bindURL(displayURL != null ? displayURL : plainUrl, expandedURL != null ? expandedURL : plainUrl);
        return;//from www.java  2  s . c  o  m
    }
    final String url = user.getURL();
    if (!TextUtils.isEmpty(url)) {
        bindURL(url, url);
        return;
    }
    urlIcon.setVisibility(GONE);
    this.url.setVisibility(GONE);
}

From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java

License:Apache License

static Struct convertURLEntity(URLEntity uRLEntity) {
    return new Struct(SCHEMA_URL_ENTITY).put("URL", uRLEntity.getURL()).put("Text", uRLEntity.getText())
            .put("ExpandedURL", uRLEntity.getExpandedURL()).put("Start", uRLEntity.getStart())
            .put("End", uRLEntity.getEnd()).put("DisplayURL", uRLEntity.getDisplayURL());
}

From source file:com.javielinux.utils.Utils.java

License:Apache License

static public String getTextURLs(twitter4j.Status st) {
    String out = "";
    URLEntity[] urls = st.getURLEntities();

    if (urls != null && urls.length > 0) {
        for (URLEntity url : urls) {
            if (url.getDisplayURL() != null && !url.getDisplayURL().equals("")) {
                out += url.getURL().toString() + SEP_VALUES + url.getDisplayURL() + SEP_VALUES
                        + url.getExpandedURL().toString() + SEP_BLOCK;
            }/*www  .j a v a  2 s  .  c  o m*/
        }
    }

    MediaEntity[] medias = st.getMediaEntities();

    if (medias != null && medias.length > 0) {
        for (MediaEntity media : medias) {
            if (media.getDisplayURL() != null && !media.getDisplayURL().equals("")) {
                out += media.getURL().toString() + SEP_VALUES + media.getDisplayURL() + SEP_VALUES
                        + media.getExpandedURL().toString() + SEP_VALUES + media.getMediaURL().toString()
                        + ":thumb" + SEP_VALUES + media.getMediaURL().toString() + ":medium" + SEP_BLOCK;
            }
        }
    }

    return out;
}