Example usage for twitter4j Status getQuotedStatusId

List of usage examples for twitter4j Status getQuotedStatusId

Introduction

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

Prototype

long getQuotedStatusId();

Source Link

Document

Returns the Tweet ID of the quoted Tweet

Usage

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

License:Apache License

StatusIDs(Status status) {
    this.id = status.getId();
    final Status retweetedStatus = status.getRetweetedStatus();
    this.retweetedStatusId = retweetedStatus != null ? retweetedStatus.getId() : -1;
    this.quotedStatusId = status.getQuotedStatusId();
}

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();
    }//  w  w w  .  j a v  a  2 s. 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.module.realm.TimelineStoreRealm.java

License:Apache License

private List<StatusIDs> createUpdateList(List<Status> statuses) {
    if (!updateEvent.hasObservers()) {
        return Collections.emptyList();
    }// w ww  .java  2  s. co  m

    final List<StatusIDs> updates = new ArrayList<>();
    for (Status s : statuses) {
        final StatusIDs update = findTimeline(s);
        if (update != null) {
            updates.add(update);
        }

        final RealmResults<StatusIDs> u = findReferringStatus(s.getId());
        if (!u.isEmpty()) {
            updates.addAll(u);
        }

        final long quotedStatusId = s.getQuotedStatusId();
        if (quotedStatusId > 0) {
            final Status quotedStatus = s.getQuotedStatus();

            final StatusIDs q = findTimeline(quotedStatus);
            if (q != null) {
                updates.add(q);
            }

            final RealmResults<StatusIDs> updatedQuotedStatus = findReferringStatus(quotedStatusId);
            if (!updatedQuotedStatus.isEmpty()) {
                updates.addAll(updatedQuotedStatus);
            }
        }

        if (!s.isRetweet()) {
            continue;
        }
        final Status retweetedStatus = s.getRetweetedStatus();

        final StatusIDs rs = findTimeline(retweetedStatus);
        if (rs != null) {
            updates.add(rs);
        }
        final RealmResults<StatusIDs> rtedUpdate = findReferringStatus(retweetedStatus.getId());
        if (!rtedUpdate.isEmpty()) {
            updates.addAll(rtedUpdate);
        }

        final long rtQuotedStatusId = retweetedStatus.getQuotedStatusId();
        if (rtQuotedStatusId > 0) {
            final RealmResults<StatusIDs> rtUpdatedQuotedStatus = findReferringStatus(rtQuotedStatusId);
            if (!rtUpdatedQuotedStatus.isEmpty()) {
                updates.addAll(rtUpdatedQuotedStatus);
            }
        }
    }
    return updates;
}

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;
        }//  www. ja va  2  s .c om
        info.add(new SpanningInfo(null, start, end, ""));
    }
    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.TimelineAdapter.java

License:Apache License

@Override
public void onBindViewHolder(final ViewHolder<T> holder, int position) {
    final T entity = timelineStore.get(position);
    final StatusView itemView = (StatusView) holder.itemView;
    final long entityId = getEntityId(entity);
    holder.setEntityId(entityId);//from  www . j a v  a 2 s  . co m
    holder.bind(timelineStore.observeById(entityId));
    if (position == getItemCount() - 1) {
        final long nextCursor = timelineStore.getLastPageCursor();
        if (nextCursor > 0) {
            lastItemBoundListener.onLastItemBound(nextCursor);
        }
    }
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            itemViewClickListener.onItemViewClicked(itemView, entityId, v);
        }
    });

    if (entity instanceof Status) {
        final Status status = (Status) entity;
        itemView.bindStatus(status);
        final long quotedStatusId = status.getQuotedStatusId();
        if (entityId == getSelectedEntityId()) {
            selectedEntityHolder = new SelectedEntity(holder);
        } else if (quotedStatusId != -1 && quotedStatusId == getSelectedEntityId()) {
            final QuotedStatusView quotedStatusView = ((StatusView) holder.itemView).getQuotedStatusView();
            selectedEntityHolder = new SelectedEntity(quotedStatusId, quotedStatusView);
        }
        StatusViewImageHelper.load(status, (StatusView) holder.itemView);
        setupUserIcon(status, itemView);
        setupMediaView(status, itemView);
        setupQuotedStatusView(status, itemView.getQuotedStatusView());
    } else if (entity instanceof User) {
        final User user = (User) entity;
        itemView.bindUser(user);
        if (entityId == getSelectedEntityId()) {
            selectedEntityHolder = new SelectedEntity(holder);
        }
        StatusViewImageHelper.load(user, (StatusView) holder.itemView);
        setupUserIcon(user, itemView);
    }
}

From source file:org.smarttechie.servlet.SimpleStream.java

public void getStream(TwitterStream twitterStream, String[] parametros, final Session session)//,PrintStream out)
{

    listener = new StatusListener() {

        @Override//from  w  ww.  j  av a2 s  .c om
        public void onException(Exception arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onScrubGeo(long arg0, long arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStatus(Status status) {
            Twitter twitter = new TwitterFactory().getInstance();
            User user = status.getUser();

            // gets Username
            String username = status.getUser().getScreenName();
            System.out.println("");
            String profileLocation = user.getLocation();
            System.out.println(profileLocation);
            long tweetId = status.getId();
            System.out.println(tweetId);
            String content = status.getText();
            System.out.println(content + "\n");

            JSONObject obj = new JSONObject();
            obj.put("User", status.getUser().getScreenName());
            obj.put("ProfileLocation", user.getLocation().replaceAll("'", "''"));
            obj.put("Id", status.getId());
            obj.put("UserId", status.getUser().getId());
            //obj.put("User", status.getUser());
            obj.put("Message", status.getText().replaceAll("'", "''"));
            obj.put("CreatedAt", status.getCreatedAt().toString());
            obj.put("CurrentUserRetweetId", status.getCurrentUserRetweetId());
            //Get user retweeteed
            String otheruser;
            try {
                if (status.getCurrentUserRetweetId() != -1) {
                    User user2 = twitter.showUser(status.getCurrentUserRetweetId());
                    otheruser = user2.getScreenName();
                    System.out.println("Other user: " + otheruser);
                }
            } catch (Exception ex) {
                System.out.println("ERROR: " + ex.getMessage().toString());
            }
            obj.put("IsRetweet", status.isRetweet());
            obj.put("IsRetweeted", status.isRetweeted());
            obj.put("IsFavorited", status.isFavorited());

            obj.put("InReplyToUserId", status.getInReplyToUserId());
            //In reply to
            obj.put("InReplyToScreenName", status.getInReplyToScreenName());

            obj.put("RetweetCount", status.getRetweetCount());
            if (status.getGeoLocation() != null) {
                obj.put("GeoLocationLatitude", status.getGeoLocation().getLatitude());
                obj.put("GeoLocationLongitude", status.getGeoLocation().getLongitude());
            }

            JSONArray listHashtags = new JSONArray();
            String hashtags = "";
            for (HashtagEntity entity : status.getHashtagEntities()) {
                listHashtags.add(entity.getText());
                hashtags += entity.getText() + ",";
            }

            if (!hashtags.isEmpty())
                obj.put("HashtagEntities", hashtags.substring(0, hashtags.length() - 1));

            if (status.getPlace() != null) {
                obj.put("PlaceCountry", status.getPlace().getCountry());
                obj.put("PlaceFullName", status.getPlace().getFullName());
            }

            obj.put("Source", status.getSource());
            obj.put("IsPossiblySensitive", status.isPossiblySensitive());
            obj.put("IsTruncated", status.isTruncated());

            if (status.getScopes() != null) {
                JSONArray listScopes = new JSONArray();
                String scopes = "";
                for (String scope : status.getScopes().getPlaceIds()) {
                    listScopes.add(scope);
                    scopes += scope + ",";
                }

                if (!scopes.isEmpty())
                    obj.put("Scopes", scopes.substring(0, scopes.length() - 1));
            }

            obj.put("QuotedStatusId", status.getQuotedStatusId());

            JSONArray list = new JSONArray();
            String contributors = "";
            for (long id : status.getContributors()) {
                list.add(id);
                contributors += id + ",";
            }

            if (!contributors.isEmpty())
                obj.put("Contributors", contributors.substring(0, contributors.length() - 1));

            System.out.println("" + obj.toJSONString());

            insertNodeNeo4j(obj);

            //out.println(obj.toJSONString());
            String statement = "INSERT INTO TweetsClassification JSON '" + obj.toJSONString() + "';";
            executeQuery(session, statement);
        }

        @Override
        public void onTrackLimitationNotice(int arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStallWarning(StallWarning sw) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    };
    FilterQuery fq = new FilterQuery();

    fq.track(parametros);

    twitterStream.addListener(listener);
    twitterStream.filter(fq);
}