コード例 #1
0
  private void bindSocialView(
      DiscussionSocialLayoutViewHolder holder,
      final int position,
      final DiscussionComment response) {
    holder.setDiscussionResponse(response);

    holder.voteViewContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            SetCommentVotedTask task =
                new SetCommentVotedTask(context, response, !response.isVoted()) {
                  @Override
                  public void onSuccess(DiscussionComment comment) {
                    super.onSuccess(comment);
                    discussionResponses.set(position - 1, comment);
                    notifyItemChanged(position);
                  }
                };
            task.setProgressCallback(null);
            task.execute();
          }
        });
  }
コード例 #2
0
  private void bindSocialView(DiscussionSocialLayoutViewHolder holder, DiscussionThread thread) {
    holder.setDiscussionThread(thread);

    holder.voteViewContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            SetThreadVotedTask task =
                new SetThreadVotedTask(context, discussionThread, !discussionThread.isVoted()) {
                  @Override
                  public void onSuccess(DiscussionThread updatedDiscussionThread) {
                    super.onSuccess(updatedDiscussionThread);
                    discussionThread = updatedDiscussionThread;
                    notifyItemChanged(0);
                  }
                };
            task.setProgressCallback(null);
            task.execute();
          }
        });

    holder.threadFollowContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            SetThreadFollowedTask task =
                new SetThreadFollowedTask(
                    context, discussionThread, !discussionThread.isFollowing()) {
                  @Override
                  public void onSuccess(DiscussionThread updatedDiscussionThread) {
                    super.onSuccess(updatedDiscussionThread);
                    discussionThread = updatedDiscussionThread;
                    notifyItemChanged(0);
                  }
                };
            task.setProgressCallback(null);
            task.execute();
          }
        });
  }