Example #1
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);
  }
Example #2
0
 public static Set<String> extraStatusMentions(final Status status, boolean excludeSelf) {
   Pattern mentionPattern = FeaturePatternUtils.getMentionPattern(status.getServiceProvider());
   Matcher matcher = mentionPattern.matcher(status.getText());
   Set<String> mentions = new LinkedHashSet<String>();
   while (matcher.find()) {
     mentions.add(matcher.group());
   }
   if (excludeSelf) {
     mentions.remove(status.getUser().getMentionName());
   }
   return mentions;
 }