예제 #1
0
 private void onShowCommentAction(Comment comment) {
   boolean canReplyTo = canSendComment();
   long userId = AccountUtils.getUserId(this);
   boolean canDelete =
       (mBroadcastAdapter.hasBroadcast() && mBroadcastAdapter.getBroadcast().author.id == userId)
           || comment.author.id == userId;
   CommentActionDialogFragment.show(comment, canReplyTo, canDelete, this);
 }
예제 #2
0
  @Override
  public boolean onLike(boolean like) {

    if (mBroadcastAdapter.hasBroadcast()
        && mBroadcastAdapter.getBroadcast().author.id == AccountUtils.getUserId(this)) {
      ToastUtils.show(R.string.broadcast_like_error_cannot_like_oneself, this);
      return false;
    }

    ApiRequest<Broadcast> request = ApiRequests.newLikeBroadcastRequest(mBroadcastId, like, this);
    LikeState state = new LikeState(like);
    RequestFragment.startRequest(REQUEST_CODE_LIKE, request, state, this);
    return true;
  }
예제 #3
0
  @Override
  public boolean onRebroadcast(boolean rebroadcast) {

    if (mBroadcastAdapter.hasBroadcast()
        && mBroadcastAdapter.getBroadcast().author.id == AccountUtils.getUserId(this)) {
      ToastUtils.show(R.string.broadcast_rebroadcast_error_cannot_rebroadcast_oneself, this);
      return false;
    }

    ApiRequest<Broadcast> request =
        ApiRequests.newRebroadcastBroadcastRequest(mBroadcastId, rebroadcast, this);
    RebroadcastState state = new RebroadcastState(rebroadcast);
    RequestFragment.startRequest(REQUEST_CODE_REBROADCAST, request, state, this);
    return true;
  }
예제 #4
0
 private void onDeleteCommentResponse(
     boolean successful, Boolean result, VolleyError error, DeleteCommentState state) {
   if (successful) {
     ToastUtils.show(R.string.broadcast_comment_delete_successful, this);
     EventBus.getDefault().post(new BroadcastCommentDeletedEvent(mBroadcastId, state.commentId));
     if (mBroadcastAdapter.hasBroadcast()) {
       Broadcast broadcast = mBroadcastAdapter.getBroadcast();
       --broadcast.commentCount;
       EventBus.getDefault().post(new BroadcastUpdatedEvent(broadcast));
     }
   } else {
     LogUtils.e(error.toString());
     ToastUtils.show(
         getString(
             R.string.broadcast_comment_delete_failed_format,
             ApiError.getErrorString(error, this)),
         this);
   }
 }
예제 #5
0
 private boolean canSendComment() {
   return mBroadcastAdapter.hasBroadcast() && mBroadcastAdapter.getBroadcast().canComment();
 }