禁言功能优化

This commit is contained in:
kehaoyuan
2018-08-17 15:33:04 +08:00
parent 33dba4e9bf
commit b5e025984c
5 changed files with 30 additions and 55 deletions

View File

@ -25,50 +25,6 @@ import retrofit2.HttpException;
// TODO: 1/12/17 逐步整理 删除
public class LoginUtils {
// public static void checkPhoneNum(final Context context, final String phoneName, final onCaptchaCallBackListener listener) { // 老用户登录检查手机是否登录过
// RetrofitManager.getInstance(context).getApi()
// .checkPhoneNum(phoneName)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Response<ResponseBody>() {
// @Override
// public void onResponse(ResponseBody response) {
// super.onResponse(response);
// try {
// JSONObject content = new JSONObject(response.string());
// String status = content.getString("status");
// if ("ok".equals(status)) {
// getPhoneCaptcha(context, phoneName, listener);
// } else {
// DialogUtils.showWarningDialog(context, null, "手机号已存在,请使用未登录过的手机号,以保证数据正常同步到新账号上"
// , null, "我知道了", null, null);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void onFailure(HttpException e) {
// super.onFailure(e);
// if (e == null) {
// Utils.toast(context, "请检查网络是否可用");
// return;
// }
// try {
// ResponseBody responseBody = e.response().errorBody();
// String string = responseBody.string();
// JSONObject content = new JSONObject(string);
// int code = content.getInt("code");
// outputErrorHint(context, code);
// } catch (Exception e1) {
// e1.printStackTrace();
// }
// }
// });
//
// }
// 获取验证码
public static void getPhoneCaptcha(final Context context, String phoneNum, final onCaptchaCallBackListener listener) {
JSONObject content = new JSONObject();
@ -147,7 +103,7 @@ public class LoginUtils {
});
}
public static boolean userPostErrorToast(Throwable throwable, Context context, boolean isComment) {
public static boolean userPostErrorToast(Throwable throwable, Context context, boolean isQuestion) {
if (throwable instanceof HttpException) {
HttpException exception = (HttpException) throwable;
if (exception.code() == 403) {
@ -155,19 +111,35 @@ public class LoginUtils {
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
int errorCode = errorJson.getInt("code");
switch (errorCode) {
case 403019:
if (isComment) {
Utils.toast(context, R.string.comment_failed_userblocked);
} else {
Utils.toast(context, R.string.comment_failed_userbanned);
}
case 403050:
case 403048:
case 403049:
Utils.toast(context, R.string.comment_failed_userbanned);
break;
case 403051:
Utils.toast(context, R.string.comment_failed_userblocked);
break;
case 403020:
Utils.toast(context, R.string.comment_failed_toofrequent);
if (isQuestion) {
DialogUtils.showAlertDialog(context, "限制提醒"
, "提问过于频繁,请先休息一下哦", "知道了"
, null, null, null);
} else {
Utils.toast(context, R.string.comment_failed_toofrequent);
}
break;
case 403021:
Utils.toast(context, R.string.comment_failed_illegal);
break;
case 403045:
Utils.toast(context, R.string.deny_edit_question);
break;
case 403046:
Utils.toast(context, R.string.deny_edit_answer);
break;
case 403047:
Utils.toast(context, R.string.deny_vote_answer);
break;
default:
Utils.toast(context, R.string.comment_failed_unknown);
break;