protected void openMedia(
     long accountId, long extraId, boolean sensitive, String link, int start, int end) {
   final ParcelableMedia[] media = {ParcelableMedia.image(link)};
   // TODO open media animation
   Bundle options = null;
   Utils.openMedia(context, accountId, sensitive, null, media, options);
 }
  @Nullable
  @Override
  public ParcelableMedia from(@NonNull String link) {
    final Uri uri = Uri.parse(link);
    final ParcelableMedia media = new ParcelableMedia();
    media.type = ParcelableMedia.Type.TYPE_IMAGE;
    media.url = link;
    if (link.contains("profile")) {
      media.preview_url = link;
      media.media_url = link;
    } else {
      media.preview_url = String.format(Locale.ROOT, "%s:medium", link);
      media.media_url = String.format(Locale.ROOT, "%s:orig", link);
    }

    return media;
  }
Exemplo n.º 3
0
  public ParcelableStatus(final Status orig, final long account_id, final boolean is_gap) {
    this.is_gap = is_gap;
    this.account_id = account_id;
    id = orig.getId();
    timestamp = getTime(orig.getCreatedAt());

    final Status retweeted = orig.getRetweetedStatus();
    final User retweet_user = retweeted != null ? orig.getUser() : null;
    is_retweet = orig.isRetweet();
    retweet_id = retweeted != null ? retweeted.getId() : -1;
    retweet_timestamp = retweeted != null ? getTime(retweeted.getCreatedAt()) : -1;
    retweeted_by_user_id = retweet_user != null ? retweet_user.getId() : -1;
    retweeted_by_user_name = retweet_user != null ? retweet_user.getName() : null;
    retweeted_by_user_screen_name = retweet_user != null ? retweet_user.getScreenName() : null;
    retweeted_by_user_profile_image = TwitterContentUtils.getProfileImageUrl(retweet_user);

    final Status quoted = orig.getQuotedStatus();
    final User quote_user = quoted != null ? orig.getUser() : null;
    is_quote = orig.isQuote();
    quote_id = quoted != null ? quoted.getId() : -1;
    quote_text_html = TwitterContentUtils.formatStatusText(orig);
    quote_text_plain = TwitterContentUtils.unescapeTwitterStatusText(orig.getText());
    quote_text_unescaped = HtmlEscapeHelper.toPlainText(quote_text_html);
    quote_timestamp = orig.getCreatedAt().getTime();
    quote_source = orig.getSource();
    quote_retweet_count = orig.getRetweetCount();
    quote_favorite_count = orig.getFavoriteCount();
    quote_reply_count = orig.getReplyCount();

    quoted_by_user_id = quote_user != null ? quote_user.getId() : -1;
    quoted_by_user_name = quote_user != null ? quote_user.getName() : null;
    quoted_by_user_screen_name = quote_user != null ? quote_user.getScreenName() : null;
    quoted_by_user_profile_image = TwitterContentUtils.getProfileImageUrl(quote_user);
    quoted_by_user_is_protected = quote_user != null && quote_user.isProtected();
    quoted_by_user_is_verified = quote_user != null && quote_user.isVerified();

    final Status status;
    if (quoted != null) {
      status = quoted;
    } else if (retweeted != null) {
      status = retweeted;
    } else {
      status = orig;
    }
    final User user = status.getUser();
    user_id = user.getId();
    user_name = user.getName();
    user_screen_name = user.getScreenName();
    user_profile_image_url = TwitterContentUtils.getProfileImageUrl(user);
    user_is_protected = user.isProtected();
    user_is_verified = user.isVerified();
    user_is_following = user.isFollowing();
    text_html = TwitterContentUtils.formatStatusText(status);
    media = ParcelableMedia.fromStatus(status);
    quote_media = quoted != null ? ParcelableMedia.fromStatus(orig) : null;
    text_plain = TwitterContentUtils.unescapeTwitterStatusText(status.getText());
    retweet_count = status.getRetweetCount();
    favorite_count = status.getFavoriteCount();
    reply_count = status.getReplyCount();
    in_reply_to_name = TwitterContentUtils.getInReplyToName(retweeted != null ? retweeted : orig);
    in_reply_to_screen_name = (retweeted != null ? retweeted : orig).getInReplyToScreenName();
    in_reply_to_status_id = (retweeted != null ? retweeted : orig).getInReplyToStatusId();
    in_reply_to_user_id = (retweeted != null ? retweeted : orig).getInReplyToUserId();
    source = status.getSource();
    location = ParcelableLocation.fromGeoLocation(status.getGeoLocation());
    is_favorite = status.isFavorited();
    text_unescaped = HtmlEscapeHelper.toPlainText(text_html);
    my_retweet_id = retweeted_by_user_id == account_id ? id : status.getCurrentUserRetweet();
    is_possibly_sensitive = status.isPossiblySensitive();
    mentions = ParcelableUserMention.fromUserMentionEntities(status.getUserMentionEntities());
    card = ParcelableCardEntity.fromCardEntity(status.getCard(), account_id);
    place_full_name = getPlaceFullName(status.getPlace());
    card_name = card != null ? card.name : null;
  }
Exemplo n.º 4
0
 public ParcelableStatus(final Cursor c, final CursorIndices idx) {
   id = idx.status_id != -1 ? c.getLong(idx.status_id) : -1;
   account_id = idx.account_id != -1 ? c.getLong(idx.account_id) : -1;
   timestamp = idx.status_timestamp != -1 ? c.getLong(idx.status_timestamp) : 0;
   user_id = idx.user_id != -1 ? c.getLong(idx.user_id) : -1;
   retweet_id = idx.retweet_id != -1 ? c.getLong(idx.retweet_id) : -1;
   retweet_timestamp = idx.retweet_timestamp != -1 ? c.getLong(idx.retweet_timestamp) : -1;
   retweeted_by_user_id =
       idx.retweeted_by_user_id != -1 ? c.getLong(idx.retweeted_by_user_id) : -1;
   retweet_count = idx.retweet_count != -1 ? c.getLong(idx.retweet_count) : -1;
   favorite_count = idx.favorite_count != -1 ? c.getLong(idx.favorite_count) : -1;
   reply_count = idx.reply_count != -1 ? c.getLong(idx.reply_count) : -1;
   in_reply_to_status_id =
       idx.in_reply_to_status_id != -1 ? c.getLong(idx.in_reply_to_status_id) : -1;
   in_reply_to_user_id = idx.in_reply_to_user_id != -1 ? c.getLong(idx.in_reply_to_user_id) : -1;
   is_gap = idx.is_gap != -1 && c.getInt(idx.is_gap) == 1;
   is_retweet = idx.is_retweet != -1 && c.getInt(idx.is_retweet) == 1;
   is_favorite = idx.is_favorite != -1 && c.getInt(idx.is_favorite) == 1;
   user_is_protected = idx.is_protected != -1 && c.getInt(idx.is_protected) == 1;
   user_is_verified = idx.is_verified != -1 && c.getInt(idx.is_verified) == 1;
   retweeted_by_user_name =
       idx.retweeted_by_user_name != -1 ? c.getString(idx.retweeted_by_user_name) : null;
   retweeted_by_user_screen_name =
       idx.retweeted_by_user_screen_name != -1
           ? c.getString(idx.retweeted_by_user_screen_name)
           : null;
   retweeted_by_user_profile_image =
       idx.retweeted_by_user_profile_image != -1
           ? c.getString(idx.retweeted_by_user_profile_image)
           : null;
   text_html = idx.text_html != -1 ? c.getString(idx.text_html) : null;
   media = idx.media != -1 ? ParcelableMedia.fromSerializedJson(c.getString(idx.media)) : null;
   quote_media =
       idx.quote_media != -1
           ? ParcelableMedia.fromSerializedJson(c.getString(idx.quote_media))
           : null;
   text_plain = idx.text_plain != -1 ? c.getString(idx.text_plain) : null;
   user_name = idx.user_name != -1 ? c.getString(idx.user_name) : null;
   user_screen_name = idx.user_screen_name != -1 ? c.getString(idx.user_screen_name) : null;
   in_reply_to_name =
       idx.in_reply_to_user_name != -1 ? c.getString(idx.in_reply_to_user_name) : null;
   in_reply_to_screen_name =
       idx.in_reply_to_user_screen_name != -1
           ? c.getString(idx.in_reply_to_user_screen_name)
           : null;
   source = idx.source != -1 ? c.getString(idx.source) : null;
   location = idx.location != -1 ? new ParcelableLocation(c.getString(idx.location)) : null;
   user_profile_image_url =
       idx.user_profile_image_url != -1 ? c.getString(idx.user_profile_image_url) : null;
   text_unescaped = idx.text_unescaped != -1 ? c.getString(idx.text_unescaped) : null;
   my_retweet_id = idx.my_retweet_id != -1 ? c.getLong(idx.my_retweet_id) : -1;
   is_possibly_sensitive =
       idx.is_possibly_sensitive != -1 && c.getInt(idx.is_possibly_sensitive) == 1;
   user_is_following = idx.is_following != -1 && c.getInt(idx.is_following) == 1;
   mentions =
       idx.mentions != -1
           ? ParcelableUserMention.fromSerializedJson(c.getString(idx.mentions))
           : null;
   card = idx.card != -1 ? ParcelableCardEntity.fromJSONString(c.getString(idx.card)) : null;
   place_full_name = idx.place_full_name != -1 ? c.getString(idx.place_full_name) : null;
   is_quote = idx.is_quote != -1 && c.getShort(idx.is_quote) == 1;
   quote_id = idx.quote_id != -1 ? c.getLong(idx.quote_id) : -1;
   quote_timestamp = idx.quote_timestamp != -1 ? c.getLong(idx.quote_timestamp) : -1;
   quoted_by_user_id = idx.quoted_by_user_id != -1 ? c.getLong(idx.quoted_by_user_id) : -1;
   quote_text_html = idx.quote_text_html != -1 ? c.getString(idx.quote_text_html) : null;
   quote_text_plain = idx.quote_text_plain != -1 ? c.getString(idx.quote_text_plain) : null;
   quote_text_unescaped =
       idx.quote_text_unescaped != -1 ? c.getString(idx.quote_text_unescaped) : null;
   quoted_by_user_name =
       idx.quoted_by_user_name != -1 ? c.getString(idx.quoted_by_user_name) : null;
   quoted_by_user_screen_name =
       idx.quoted_by_user_screen_name != -1 ? c.getString(idx.quoted_by_user_screen_name) : null;
   quoted_by_user_profile_image =
       idx.quoted_by_user_profile_image != -1
           ? c.getString(idx.quoted_by_user_profile_image)
           : null;
   quoted_by_user_is_protected =
       idx.quoted_by_user_is_protected != -1 && c.getShort(idx.quoted_by_user_is_protected) == 1;
   quoted_by_user_is_verified =
       idx.quoted_by_user_is_verified != -1 && c.getShort(idx.quoted_by_user_is_verified) == 1;
   quote_source = idx.quote_source != -1 ? c.getString(idx.quote_source) : null;
   quote_retweet_count = idx.quote_retweet_count != -1 ? c.getLong(idx.quote_retweet_count) : -1;
   quote_favorite_count =
       idx.quote_favorite_count != -1 ? c.getLong(idx.quote_favorite_count) : -1;
   quote_reply_count = idx.quote_reply_count != -1 ? c.getLong(idx.quote_reply_count) : -1;
   card_name = card != null ? card.name : null;
 }