增加部分回答详情评论的接口

This commit is contained in:
chenjuntao
2018-03-23 18:09:52 +08:00
parent de08d4d32d
commit 76d788ee66
21 changed files with 656 additions and 91 deletions

View File

@ -57,6 +57,62 @@ public class PostCommentUtils {
});
}
public static void addAnswerComment(final Context context, final String answerId, 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);
} else {
observable = RetrofitManager.getInstance(context).getApi().postNewCommentToAnswer(answerId, body);
}
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
@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);
}
}
@Override
public void onFailure(HttpException e) {
if (listener != null) {
listener.postFailed(e);
}
}
});
}
public static void voteAnswerComment(final Context context,final String answerId, final String commentId,
final PostCommentListener listener) {
RetrofitManager.getInstance(context).getApi()
.postVoteAnswerComment(answerId,commentId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {
@Override
public void onResponse(ResponseBody response) {
if (listener != null) {
listener.postSuccess(null);
}
}
@Override
public void onFailure(HttpException e) {
if (listener != null) {
listener.postFailed(e);
}
}
});
}
public static void addCommentVoto(final Context context, final String commentId,
final PostCommentListener listener) {
RetrofitManager.getInstance(context).getApi()