大于两个的if分支,使用switch
This commit is contained in:
@ -475,17 +475,23 @@ public class MessageDetailActivity extends BaseActivity implements OnCommentCall
|
||||
try {
|
||||
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
|
||||
String detail = errorJson.getString("detail");
|
||||
if ("too frequent".equals(detail)) {
|
||||
toast("别话痨哦~休息一会再来评论吧~");
|
||||
} else if ("user blocked".equals(detail)) {
|
||||
toast("账号状态异常,暂时无法发表评论");
|
||||
} else if ("article blocked".equals(detail)) {
|
||||
toast("文章异常,无法发表评论");
|
||||
setSoftInput(false);
|
||||
} else if ("illegal".equals(detail)) {
|
||||
toast("评论内容可能包括敏感信息,请修改后再发表");
|
||||
} else {
|
||||
toast("评论失败,未知原因");
|
||||
switch (detail) {
|
||||
case "too frequent":
|
||||
toast("别话痨哦~休息一会再来评论吧~");
|
||||
break;
|
||||
case "user blocked":
|
||||
toast("账号状态异常,暂时无法发表评论");
|
||||
break;
|
||||
case "article blocked":
|
||||
toast("文章异常,无法发表评论");
|
||||
setSoftInput(false);
|
||||
break;
|
||||
case "illegal":
|
||||
toast("评论内容可能包括敏感信息,请修改后再发表");
|
||||
break;
|
||||
default:
|
||||
toast("评论失败,未知原因");
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user