private CharSequence formatFrom(Recipients from, long count, boolean read) {
    String fromString = from.toShortString();
    SpannableStringBuilder builder = new SpannableStringBuilder(fromString);

    if (count > 0) {
      builder.append(" " + count);
      builder.setSpan(
          new ForegroundColorSpan(Color.parseColor("#66333333")),
          fromString.length(),
          builder.length(),
          Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }

    if (!read) {
      builder.setSpan(
          new StyleSpan(Typeface.BOLD), 0, builder.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }

    return builder;
  }
示例#2
0
    public String toString() {
      if (groupContext == null) {
        return context.getString(R.string.GroupUtil_group_updated);
      }

      StringBuilder description = new StringBuilder();
      String title = groupContext.getName();

      if (members != null) {
        description.append(
            context.getString(R.string.GroupUtil_joined_the_group, members.toShortString()));
      }

      if (title != null && !title.trim().isEmpty()) {
        if (description.length() > 0) description.append(" ");
        description.append(context.getString(R.string.GroupUtil_title_is_now, title));
      }

      if (description.length() > 0) {
        return description.toString();
      } else {
        return context.getString(R.string.GroupUtil_group_updated);
      }
    }
 private String formatFrom(Recipients from, long count) {
   return from.toShortString() + (count > 0 ? " (" + count + ")" : "");
 }