Example usage for twitter4j URLEntity getExpandedURL

List of usage examples for twitter4j URLEntity getExpandedURL

Introduction

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

Prototype

String getExpandedURL();

Source Link

Document

Returns the expanded URL if mentioned URL is shorten.

Usage

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.module.realm.URLEntityRealm.java

License:Apache License

@Nullable
private static URLEntityRealm findExpandedUrl(URLEntity urlEntity, Realm realm) {
    if (urlEntity.getExpandedURL() != null) {
        return null;
    }//  ww  w.  j  av  a  2  s  . co m
    return realm.where(URLEntityRealm.class).equalTo("expandedUrl", urlEntity.getURL()).findFirst();
}

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 ww w.j  ava 2  s.  c om*/
            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 {/*from w  ww .j  ava  2s  .  c o m*/
            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   w w w .j  a v  a2s.com
    }
    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.daytron.twaattin.ui.tabledecorator.TweetColumnDecorator.java

License:Open Source License

void createFragmentsWithUrl(URLEntity[] urls) {

    if (urls != null) {

        for (URLEntity url : urls) {

            String expandedUrl = url.getExpandedURL();

            int start = url.getStart();
            int end = url.getEnd();

            String href = "<a href='" + expandedUrl + "' target='_blank' + title='" + expandedUrl + "'>";

            TweetFragment fragment = new TweetFragment(start, end, href + url.getURL() + "</a>");

            fragments.add(fragment);//from w w w.  jav  a  2s.co  m
        }
    }
}

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;
            }//from  w  ww .j av  a 2 s. co  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;
}