Example usage for twitter4j Status getText

List of usage examples for twitter4j Status getText

Introduction

In this page you can find the example usage for twitter4j Status getText.

Prototype

String getText();

Source Link

Document

Returns the text of the status

Usage

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

License:Apache License

StatusRealm(Status status) {
    this.id = status.getId();
    this.createdAt = status.getCreatedAt();
    this.retweetedStatus = status.getRetweetedStatus();
    this.retweet = status.isRetweet();
    if (status.isRetweet()) {
        this.retweetedStatusId = this.retweetedStatus.getId();
    }/* ww  w .j  av  a  2s  . co  m*/
    this.text = status.getText();
    this.source = status.getSource();
    this.retweetCount = status.getRetweetCount();
    this.favoriteCount = status.getFavoriteCount();
    this.reaction = new StatusReactionImpl(status);
    this.user = status.getUser();
    this.userId = user.getId();
    this.urlEntities = URLEntityRealm.createList(status.getURLEntities());

    this.mediaEntities = new RealmList<>();
    final ExtendedMediaEntity[] me = status.getExtendedMediaEntities();
    for (ExtendedMediaEntity m : me) {
        mediaEntities.add(new ExtendedMediaEntityRealm(m));
    }
    final UserMentionEntity[] userMentionEntities = status.getUserMentionEntities();
    this.userMentionEntities = new RealmList<>();
    for (UserMentionEntity u : userMentionEntities) {
        this.userMentionEntities.add(new UserMentionEntityRealm(u));
    }

    this.quotedStatus = status.getQuotedStatus();
    this.quotedStatusId = status.getQuotedStatusId();
}

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

License:Apache License

static CharSequence create(Status bindingStatus) {
    final List<SpanningInfo> spannableInfo = createSpanningInfo(bindingStatus);
    return createClickableSpan(bindingStatus.getText(), spannableInfo);
}

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

License:Apache License

private static List<SpanningInfo> createURLSpanningInfo(Status bindingStatus) {
    final String text = bindingStatus.getText();
    final String quotedStatusIdStr = bindingStatus.getQuotedStatus() != null
            ? Long.toString(bindingStatus.getQuotedStatusId())
            : "";
    final List<SpanningInfo> info = new ArrayList<>();
    final URLEntity[] urlEntities = bindingStatus.getURLEntities();
    info.addAll(createURLSpanningInfo(text, urlEntities, quotedStatusIdStr));
    final ExtendedMediaEntity[] eme = bindingStatus.getExtendedMediaEntities();
    for (ExtendedMediaEntity e : eme) {
        int start = text.indexOf(e.getURL());
        int end = start + e.getURL().length();
        if (isInvalidRange(text, start, end)) {
            continue;
        }/*from w  ww  .  j  a v a  2s .c o  m*/
        info.add(new SpanningInfo(null, start, end, ""));
    }
    return info;
}

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

License:Apache License

private static List<SpanningInfo> createUserSpanningInfo(Status bindingStatus) {
    final String text = bindingStatus.getText();
    final UserMentionEntity[] userMentionEntities = bindingStatus.getUserMentionEntities();
    final List<SpanningInfo> info = new ArrayList<>();
    for (UserMentionEntity u : userMentionEntities) {
        final int start = text.indexOf("@" + u.getScreenName());
        final int end = start + u.getScreenName().length() + 1;
        if (isInvalidRange(text, start, end)) {
            continue;
        }//from   w w  w  . ja  v a 2s  . co m
        final long id = u.getId();
        info.add(new SpanningInfo(new ClickableSpan() {
            @Override
            public void onClick(View view) {
                UserInfoActivity.start(view.getContext(), id);
            }
        }, start, end, null));
    }
    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 ww  w  . j a v  a 2 s . co m
            text = text.replace(u.getURL(), u.getDisplayURL());
        }
    }
    return removeMediaUrl(text, bindingStatus.getExtendedMediaEntities());
}

From source file:com.freshdigitable.udonroad.util.PerformUtil.java

License:Apache License

public static ViewInteraction selectItemView(Status target) {
    return onView(ofStatusView(withText(target.getText()))).perform(clickForStatusView());
}

From source file:com.freshdigitable.udonroad.util.PerformUtil.java

License:Apache License

public static ViewInteraction selectQuotedItemView(Status target) {
    return onView(ofQuotedStatusView(withText(target.getText()))).perform(clickForStatusView());
}

From source file:com.freshdigitable.udonroad.util.TwitterResponseMock.java

License:Apache License

public static Status createStatus(long id, User user) {
    final Status status = mock(Status.class);
    when(status.getId()).thenReturn(id);
    when(status.getCreatedAt()).thenReturn(new Date());
    when(status.getText()).thenReturn(createText(id));
    when(status.isRetweet()).thenReturn(false);
    when(status.getSource()).thenReturn("<a href=\"https://twitter.com/akihito104\">Udonroad</a>");
    when(status.getURLEntities()).thenReturn(new URLEntity[0]);
    when(status.getExtendedMediaEntities()).thenReturn(new ExtendedMediaEntity[0]);
    when(status.getUserMentionEntities()).thenReturn(new UserMentionEntity[0]);
    when(status.getUser()).thenReturn(user);
    return status;
}

From source file:com.freshdigitable.udonroad.util.TwitterResponseMock.java

License:Apache License

public static Status createRtStatus(Status rtedStatus, long newStatusId, int rtCount, int favCount,
        boolean isFromRest) {
    final Status rtStatus = createStatus(rtedStatus.getId(), rtedStatus.getUser());
    if (isFromRest) {
        when(rtStatus.isRetweeted()).thenReturn(true);
        when(rtStatus.getRetweetCount()).thenReturn(rtCount);
        when(rtStatus.getFavoriteCount()).thenReturn(favCount);
    } else {/*  w w  w  .j ava 2 s.c om*/
        when(rtStatus.isRetweeted()).thenReturn(false);
        when(rtStatus.getRetweetCount()).thenReturn(0);
        when(rtStatus.getFavoriteCount()).thenReturn(0);
    }

    final Status status = createStatus(newStatusId);
    final String rtText = rtStatus.getText();
    when(status.getText()).thenReturn(rtText);
    when(status.isRetweet()).thenReturn(true);
    when(status.isRetweeted()).thenReturn(isFromRest);
    when(status.getRetweetedStatus()).thenReturn(rtStatus);
    return status;
}

From source file:com.fuzuapp.model.resultados.TwitterAdapter.java

@Override
public List<Resultado> getResultados(GeoPoint ponto, double raio) {

    List<Resultado> resultados = new ArrayList();
    try {/*w  w w. ja v  a  2s  .c o m*/
        Query query = new Query("");
        GeoLocation geo = new GeoLocation(ponto.getLatitude(), ponto.getLongitude());
        query.setGeoCode(geo, raio, Query.KILOMETERS);
        query.resultType(Query.RECENT);
        query.setCount(20);
        QueryResult result = twitter.search(query);

        for (Status status : result.getTweets()) {
            Resultado r = new Resultado();

            r.setDescricao(status.getText());
            r.setUrl("http://twitter.com/statuses/" + String.valueOf(status.getId()));
            r.setNomeUsuario(status.getUser().getName());
            r.setHorario(new SimpleDateFormat("dd/MM HH:mm").format(status.getCreatedAt()));
            r.setFotoUrl(status.getUser().getProfileImageURL());
            //r.setLocal(new GeoPoint(status.getGeoLocation().getLatitude(), status.getGeoLocation().getLongitude()));
            r.setTipo(Resultado.TEXTO);

            resultados.add(r);

        }
    } catch (TwitterException ex) {
        Logger.getLogger(TwitterAdapter.class.getName()).log(Level.SEVERE, null, ex);
    }

    return resultados;
}