コード例 #1
0
  public void onMarkedMessagesRead() {
    for (int i = 0, size = adapter.getItemCount(); i < size; ++i) {
      IEndlessAdaptable element = adapter.getItem(i);
      if (!(element instanceof Comment)) continue;

      Comment comment = (Comment) element;

      if (comment.isHighlighted()) {
        comment.setHighlighted(false);
        adapter.notifyItemChanged(i);
      }
    }

    adapter.setXsrfToken(null);
    getActivity().supportInvalidateOptionsMenu();

    // We no longer have any notifications
    SteamGiftsUserData.getCurrent().setMessageNotification(0);
  }
コード例 #2
0
  public void setFrom(final Comment comment) {
    Utils.setBackgroundDrawable(context, itemView, comment.isHighlighted());

    commentAuthor.setText(comment.getAuthor());
    commentAuthor.setTextAppearance(
        context,
        comment.isHighlighted()
            ? R.style.SmallText
            : comment.isOp() ? R.style.SmallText_HighlightOp : R.style.SmallText_NormalUser);
    Utils.setBackgroundDrawable(
        context,
        commentAuthor,
        comment.isOp() && !comment.isHighlighted(),
        R.attr.colorAccountHeader);

    commentTime.setText(comment.getTimeAgo());
    commentTime.setTextAppearance(
        context, comment.isHighlighted() ? R.style.SmallText : R.style.SmallText_Light);

    commentContent.setText(Utils.fromHtml(context, comment.getContent(), !comment.isDeleted()));

    // Space before the marker
    ViewGroup.LayoutParams params = commentIndent.getLayoutParams();
    params.width =
        commentMarker.getLayoutParams().width * Math.min(MAX_VISIBLE_DEPTH, comment.getDepth());
    commentIndent.setLayoutParams(params);

    Picasso.with(context)
        .load(comment.getAvatar())
        .placeholder(R.drawable.default_avatar_mask)
        .transform(new RoundedCornersTransformation(20, 0))
        .into(commentImage);
    View.OnClickListener viewProfileListener =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            fragment.showProfile(comment.getAuthor());
          }
        };
    commentImage.setOnClickListener(viewProfileListener);
    commentAuthor.setOnClickListener(viewProfileListener);

    writeCommentListener =
        comment.getId() == 0
            ? null
            : new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                fragment.requestComment(comment);
              }
            };
  }