增加文章详情评论

This commit is contained in:
kehaoyuan
2018-09-27 18:32:21 +08:00
parent c33ff5fa20
commit c03b6521d5
12 changed files with 202 additions and 57 deletions

View File

@ -1,6 +1,7 @@
package com.gh.common.util;
import android.content.Context;
import android.text.TextUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.CommentEntity;
@ -57,27 +58,33 @@ public class PostCommentUtils {
});
}
public static void addAnswerComment(final Context context, final String answerId, final String content,
public static void addAnswerComment(final Context context, final String answerId, final String articleId,
final String articleCommunityId, final String content,
final CommentEntity commentEntity,
final PostCommentListener listener) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content);
Observable<ResponseBody> observable;
if (commentEntity != null) {
observable = RetrofitManager.getInstance(context).getApi().postReplyToAnswerComment(answerId, commentEntity.getId(), body);
if (!TextUtils.isEmpty(articleId)) {
if (commentEntity != null) {
observable = RetrofitManager.getInstance(context).getApi().postReplyToCommunityArticleComment(articleCommunityId,
articleId, commentEntity.getId(), body);
} else {
observable = RetrofitManager.getInstance(context).getApi().postCommentToCommunityArticle(articleCommunityId, articleId, body);
}
} else {
observable = RetrofitManager.getInstance(context).getApi().postNewCommentToAnswer(answerId, body);
if (commentEntity != null) {
observable = RetrofitManager.getInstance(context).getApi().postReplyToAnswerComment(answerId, commentEntity.getId(), body);
} else {
observable = RetrofitManager.getInstance(context).getApi().postNewCommentToAnswer(answerId, body);
}
}
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
.subscribe(new Response<ResponseBody>() {
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0) {
if (listener != null) {
listener.postSuccess(response);
}
} else {
Utils.toast(context, R.string.post_failure_hint);
public void onResponse(ResponseBody response) {
if (listener != null) {
listener.postSuccess(new JSONObject());// 不需要返回
}
}
@ -90,10 +97,18 @@ public class PostCommentUtils {
});
}
public static void voteAnswerComment(final Context context,final String answerId, final String commentId,
final PostCommentListener listener) {
RetrofitManager.getInstance(context).getApi()
.postVoteAnswerComment(answerId,commentId)
public static void voteAnswerComment(final Context context, final String answerId, String articleId, String articleCommunityId,
final String commentId, final PostCommentListener listener) {
Observable<ResponseBody> observable;
if (!TextUtils.isEmpty(answerId)) {
observable = RetrofitManager.getInstance(context).getApi().postVoteAnswerComment(answerId, commentId);
} else {
observable = RetrofitManager.getInstance(context).getApi().postVoteCommunityArticleComment(articleCommunityId, articleId, commentId);
}
observable
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {
@ -113,7 +128,7 @@ public class PostCommentUtils {
});
}
public static void addCommentVoto(final Context context, final String commentId,
public static void addCommentVote(final Context context, final String commentId,
final PostCommentListener listener) {
RetrofitManager.getInstance(context).getApi()
.postCommentVote(commentId)
@ -157,7 +172,7 @@ public class PostCommentUtils {
}
public static void postAnswerReportData(final Context context, final String commentId, final String answerId, final String reportData,
final PostCommentListener listener) {
final PostCommentListener listener) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
RetrofitManager.getInstance(context).getApi()
.postReportOfAnswerComment(answerId, commentId, body)