Exemplo n.º 1
0
  public static String getBigImageUrl(Status status) {
    String url = null;
    if (status == null) {
      return url;
    }
    if (status.getRetweetedStatus() != null) {
      status = status.getRetweetedStatus();
    }

    if (GlobalVars.IMAGE_DOWNLOAD_QUALITY == ImageQuality.Low
        || GlobalVars.IMAGE_DOWNLOAD_QUALITY == ImageQuality.Middle) {
      url = status.getMiddlePictureUrl();
    } else if (GlobalVars.IMAGE_DOWNLOAD_QUALITY == ImageQuality.High) {
      url = status.getOriginalPictureUrl();
    } else if (GlobalVars.IMAGE_DOWNLOAD_QUALITY == ImageQuality.Adaptive_Net) {
      switch (GlobalVars.NET_TYPE) {
        case WIFI:
          url = status.getOriginalPictureUrl();
          break;
        case NONE:
        case UNKNOW:
        case MOBILE_GPRS:
        case MOBILE_EDGE:
        case MOBILE_3G:
          url = status.getMiddlePictureUrl();
          break;
      }
    }

    return url;
  }
Exemplo n.º 2
0
  private static void quoteTweet(Context context, Status status) {
    String appendText =
        String.format(
            FeaturePatternUtils.getRetweetFormat(status.getServiceProvider()),
            FeaturePatternUtils.getRetweetSeparator(status.getServiceProvider()),
            status.getUser().getMentionName(),
            status.getText());

    Status retweet = status.getRetweetedStatus();
    if (retweet != null) {
      // 官方RT形成的微博结构,引用推文时不再插入RT,因为上面的status.getText()就是RT
      appendText +=
          String.format(
              FeaturePatternUtils.getRetweetFormat(status.getServiceProvider()),
              "",
              retweet.getUser().getMentionName(),
              retweet.getText());
    }

    Intent intent = new Intent();
    intent.putExtra("TYPE", Constants.EDIT_TYPE_RETWEET);
    intent.putExtra("APPEND_TEXT", appendText);

    intent.setClass(context, EditMicroBlogActivity.class);
    ((Activity) context).startActivity(intent);
  }
Exemplo n.º 3
0
  public static String extraSimpleStatus(Context context, Status status) {
    String statusText = status.getUser().getMentionName() + ": " + status.getText();
    Status retweet = status.getRetweetedStatus();
    if (retweet != null) {
      String retweetText = retweet.getUser().getMentionName() + ": " + retweet.getText();
      statusText = context.getString(R.string.msg_extra_simple_text, statusText, retweetText);
    }

    return statusText;
  }
Exemplo n.º 4
0
  public static String extraRichStatus(Context context, Status status) {
    String statusText = status.getUser().getMentionName() + ": " + status.getText();
    String middleUrl = status.getMiddlePictureUrl();
    Status retweet = status.getRetweetedStatus();
    if (retweet != null) {
      String retweetText = retweet.getUser().getMentionName() + ": " + retweet.getText();
      statusText = context.getString(R.string.msg_extra_rich_text, statusText, retweetText);
      middleUrl = retweet.getMiddlePictureUrl();
    }
    if (middleUrl != null) {
      statusText += context.getString(R.string.msg_extra_image, middleUrl);
    }

    return statusText;
  }
Exemplo n.º 5
0
  public static View fillConvertView(View convertView, Status status) {
    if (convertView == null || status == null) {
      return null;
    }

    Context context = convertView.getContext();
    StatusHolder holder = (StatusHolder) convertView.getTag();
    if (holder == null) {
      return null;
    }
    holder.reset();

    boolean isNetEase = status.getServiceProvider() == ServiceProvider.NetEase;
    User user = status.getUser();
    if (user == null) { // 微博已经删除
      if (StringUtil.isNotEmpty(status.getText())) {
        Spannable textSpan =
            EmotionLoader.getEmotionSpannable(status.getServiceProvider(), status.getText());
        holder.tvText.setText(textSpan);
      }

      return convertView;
    }
    if (GlobalVars.IS_SHOW_HEAD) {
      holder.ivProfilePicture.setVisibility(View.VISIBLE);
      holder.headClickListener.setUser(user);
      String profileUrl = user.getProfileImageUrl();
      if (StringUtil.isNotEmpty(profileUrl)) {
        ImageLoad4HeadTask headTask =
            new ImageLoad4HeadTask(holder.ivProfilePicture, profileUrl, true);
        holder.headTask = headTask;
        headTask.execute();
      }
    } else {
      holder.ivProfilePicture.setVisibility(View.GONE);
    }

    holder.tvScreenName.setText(user.getScreenName());
    if (status.getUser().isVerified()) {
      holder.ivVerify.setVisibility(View.VISIBLE);
    }
    if (status.getLocation() != null) {
      holder.ivLocation.setVisibility(View.VISIBLE);
    }
    if (status.isFavorited()) {
      holder.ivFavorite.setVisibility(View.VISIBLE);
    }

    holder.tvCreatedAt.setText(TimeSpanUtil.toTimeSpanString(status.getCreatedAt()));

    Spannable textSpan =
        EmotionLoader.getEmotionSpannable(status.getServiceProvider(), status.getText());
    holder.tvText.setText(textSpan);

    Status retweet = status.getRetweetedStatus();
    if (retweet != null) {
      holder.llRetweet.setVisibility(View.VISIBLE);
      holder.tvRetweetText.setVisibility(View.VISIBLE);
      String retweetText = "";
      if (retweet.getUser() != null) {
        retweetText = retweet.getUser().getMentionTitleName() + ": " + retweet.getText();
      }

      Spannable retweetTextSpan =
          EmotionLoader.getEmotionSpannable(status.getServiceProvider(), retweetText);
      holder.tvRetweetText.setText(retweetTextSpan);
    }

    String thumbnailUrl = status.getThumbnailPictureUrl();
    ImageView ivTempThumbnail = holder.ivThumbnail;
    if (retweet != null) {
      thumbnailUrl = retweet.getThumbnailPictureUrl();
      ivTempThumbnail = holder.ivRetweetThumbnail;
    }
    if (StringUtil.isNotEmpty(thumbnailUrl)) {
      holder.ivAttachment.setVisibility(View.VISIBLE);
      if (GlobalVars.IS_SHOW_THUMBNAIL && !isNetEase) {
        ivTempThumbnail.setVisibility(View.VISIBLE);
        ImageLoad4ThumbnailTask thumbnailTask =
            new ImageLoad4ThumbnailTask(ivTempThumbnail, thumbnailUrl);
        holder.thumbnailTask = thumbnailTask;
        // thumbnailTask.execute(status);
        ivTempThumbnail.setOnClickListener(new ImageClickListener(status));
      }
    }

    String source =
        String.format(GlobalResource.getStatusSourceFormat(context), status.getSource());
    holder.tvSource.setText(Html.fromHtml(source).toString());

    String responseFormat = GlobalResource.getStatusResponseFormat(context);
    int retweetCount = status.getRetweetCount() == null ? 0 : status.getRetweetCount();
    int commentCount = status.getCommentCount() == null ? 0 : status.getCommentCount();
    String responseText = String.format(responseFormat, retweetCount, commentCount);
    holder.tvResponse.setText(responseText);
    if (status.getRetweetCount() == null || status.getRetweetCount() != null) {
      holder.tvResponse.setText(responseText);
      QueryResponseCountTask responseCountTask =
          new QueryResponseCountTask(context, status, holder.tvResponse);
      holder.responseCountTask = responseCountTask;
      // countTask.execute();
    }

    return convertView;
  }