添加接口统一拦截码3800 跳登录页面
This commit is contained in:
@@ -28,7 +28,10 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.utils.IoUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
|
||||
public class HttpHelper {
|
||||
// public static final String URL = "http://10.0.2.2:8080/";
|
||||
@@ -117,7 +120,37 @@ public class HttpHelper {
|
||||
// else {
|
||||
// http.send(method, url, params, callback);
|
||||
// }
|
||||
HttpHandler<String> cancleHttp = http.send(method, url, params,callback);
|
||||
final RequestCallBack<String> finalCallback = callback;
|
||||
RequestCallBack<String> wrappedCallback = finalCallback == null ? null : new RequestCallBack<String>() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
finalCallback.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoading(long total, long current, boolean isUploading) {
|
||||
finalCallback.onLoading(total, current, isUploading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled() {
|
||||
finalCallback.onCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> responseInfo) {
|
||||
if (responseInfo != null && UIUtils.interceptCode38000(UIUtils.getContext(), responseInfo.result)) {
|
||||
return;
|
||||
}
|
||||
finalCallback.onSuccess(responseInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException error, String msg) {
|
||||
finalCallback.onFailure(error, msg);
|
||||
}
|
||||
};
|
||||
HttpHandler<String> cancleHttp = http.send(method, url, params, wrappedCallback);
|
||||
// if(cancleHttp!=null){
|
||||
// cancleHttp.cancel();//取消网络请求
|
||||
// }
|
||||
@@ -277,7 +310,8 @@ public class HttpHelper {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
byte[] data = out.toByteArray();
|
||||
mStr = new String(data, "utf-8");
|
||||
mStr = new String(data, "utf-8");
|
||||
UIUtils.interceptCode38000(UIUtils.getContext(), mStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user