处理 SonarQube 问题:
双重检查锁方式实现的单例,改为使用静态内部类方式
This commit is contained in:
@ -46,9 +46,9 @@ public class PostCommentUtils {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content.toString());
|
||||
Observable<ResponseBody> observable;
|
||||
if (commentEntity != null) {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postReplyComment(commentEntity.getId(), body);
|
||||
observable = RetrofitManager.getInstance().getApi().postReplyComment(commentEntity.getId(), body);
|
||||
} else {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postNewsComment(newsId, body);
|
||||
observable = RetrofitManager.getInstance().getApi().postNewsComment(newsId, body);
|
||||
}
|
||||
observable.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -81,16 +81,16 @@ public class PostCommentUtils {
|
||||
Observable<ResponseBody> observable;
|
||||
if (!TextUtils.isEmpty(articleId)) {
|
||||
if (commentEntity != null) {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postReplyToCommunityArticleComment(articleCommunityId,
|
||||
observable = RetrofitManager.getInstance().getApi().postReplyToCommunityArticleComment(articleCommunityId,
|
||||
articleId, commentEntity.getId(), body);
|
||||
} else {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postCommentToCommunityArticle(articleCommunityId, articleId, body);
|
||||
observable = RetrofitManager.getInstance().getApi().postCommentToCommunityArticle(articleCommunityId, articleId, body);
|
||||
}
|
||||
} else {
|
||||
if (commentEntity != null) {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postReplyToAnswerComment(answerId, commentEntity.getId(), body);
|
||||
observable = RetrofitManager.getInstance().getApi().postReplyToAnswerComment(answerId, commentEntity.getId(), body);
|
||||
} else {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postNewCommentToAnswer(answerId, body);
|
||||
observable = RetrofitManager.getInstance().getApi().postNewCommentToAnswer(answerId, body);
|
||||
}
|
||||
}
|
||||
observable.subscribeOn(Schedulers.io())
|
||||
@ -124,13 +124,13 @@ public class PostCommentUtils {
|
||||
Observable<ResponseBody> observable;
|
||||
|
||||
if (!TextUtils.isEmpty(answerId)) {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postVoteAnswerComment(answerId, commentId);
|
||||
observable = RetrofitManager.getInstance().getApi().postVoteAnswerComment(answerId, commentId);
|
||||
} else if (!TextUtils.isEmpty(articleId)) {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postVoteCommunityArticleComment(articleCommunityId, articleId, commentId);
|
||||
observable = RetrofitManager.getInstance().getApi().postVoteCommunityArticleComment(articleCommunityId, articleId, commentId);
|
||||
} else if (!TextUtils.isEmpty(questionId)) {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postVoteQuestionComment(questionId, commentId);
|
||||
observable = RetrofitManager.getInstance().getApi().postVoteQuestionComment(questionId, commentId);
|
||||
} else {
|
||||
observable = RetrofitManager.getInstance(context).getApi().postVoteToVideo(videoId, commentId);
|
||||
observable = RetrofitManager.getInstance().getApi().postVoteToVideo(videoId, commentId);
|
||||
}
|
||||
observable
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -154,7 +154,7 @@ public class PostCommentUtils {
|
||||
|
||||
public static void addCommentVote(final Context context, final String commentId,
|
||||
final PostCommentListener listener) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postCommentVote(commentId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -178,7 +178,7 @@ public class PostCommentUtils {
|
||||
public static void addReportData(final Context context, final String commentId, final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postReportData(commentId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -198,7 +198,7 @@ public class PostCommentUtils {
|
||||
public static void postAnswerReportData(final Context context, final String commentId, final String answerId, final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postReportOfAnswerComment(answerId, commentId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -222,7 +222,7 @@ public class PostCommentUtils {
|
||||
final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postCommunityArticleCommentReport(communityId, articleId, commentId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -245,7 +245,7 @@ public class PostCommentUtils {
|
||||
final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postVideoCommentReport(videoId, commentId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -267,7 +267,7 @@ public class PostCommentUtils {
|
||||
final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postQuestionCommentReport(questionId, commentId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -290,7 +290,7 @@ public class PostCommentUtils {
|
||||
final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.reportGameCollectionComment(gameCollectionId, commentId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
Reference in New Issue
Block a user