Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev

# Conflicts:
#	app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java
This commit is contained in:
kehaoyuan
2018-03-28 17:28:12 +08:00
43 changed files with 2050 additions and 405 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()