本文整理汇总了Java中com.lidroid.xutils.HttpUtils.configDefaultHttpCacheExpiry方法的典型用法代码示例。如果您正苦于以下问题:Java HttpUtils.configDefaultHttpCacheExpiry方法的具体用法?Java HttpUtils.configDefaultHttpCacheExpiry怎么用?Java HttpUtils.configDefaultHttpCacheExpiry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lidroid.xutils.HttpUtils
的用法示例。
在下文中一共展示了HttpUtils.configDefaultHttpCacheExpiry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultAddress
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
void getDefaultAddress(){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
HttpUtils httpUtils = new HttpUtils();
httpUtils.configDefaultHttpCacheExpiry(100);
httpUtils.send(HttpRequest.HttpMethod.GET, ApiStores.getDefaultAddress, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
defaultAddress = new Gson().fromJson(responseInfo.result, ResponseAddress.class).data;
if (defaultAddress == null) {
selectedAddr = false;
} else {
if (defaultAddress.name != null) {
selectedAddr = true;
tv_address_ame.setText("收件人:" + defaultAddress.name);
tv_address_phone.setText(defaultAddress.mobile);
tv_address_address.setText(defaultAddress.province + defaultAddress.city + defaultAddress.city + defaultAddress.region + defaultAddress.town + defaultAddress.detail);
} else {
selectedAddr = false;
tv_address_ame.setText("收件人:");
tv_address_phone.setText("");
tv_address_address.setText("");
}
}
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("获取默认地址失败", context);
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例2: checkUserExeist
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void checkUserExeist(String phone, final ApiCallBack apiCallBack) {
HttpUtils http = new HttpUtils();
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
http.configDefaultHttpCacheExpiry(0);
RequestParams params = new RequestParams();
params.addQueryStringParameter("phone", phone);
http.send(HttpRequest.HttpMethod.POST,
RcpUri.INTERFACE_URI_CHECK_EXEIST, params,
new RequestCallBack<String>() {
@SuppressWarnings("rawtypes")
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if(code == Constants.SUCCESS) {
Log.e(TAG, "checkUserExeist success");
apiCallBack.onSuccess(code);
} else {
Log.e(TAG, "checkUserExeist fail, fail msg is " + map.get("msg"));
apiCallBack.onFailure(String.valueOf(code));
}
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "checkUserExeist error", error);
if(!HttpUtil.isNetworkAvailable(mContext)) {
ToastUtils.showMessage(mContext, R.string.no_net);
} else {
apiCallBack.onError(error, msg);
}
}
});
}
示例3: reSetPassword
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void reSetPassword(String phone, String password,
final ApiCallBack apiCallBack) {
HttpUtils http = new HttpUtils();
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
http.configDefaultHttpCacheExpiry(0);
RequestParams params = new RequestParams();
params.addQueryStringParameter("phone", phone);
params.addQueryStringParameter("password", password);
http.send(HttpRequest.HttpMethod.POST,
RcpUri.INTERFACE_URI_RESET_PWD, params,
new RequestCallBack<String>() {
@SuppressWarnings("rawtypes")
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if(code == Constants.SUCCESS) {
Log.e(TAG, "reSetPassword success");
User user = FastjsonUtil.deserialize(
map.get("data").toString(), User.class);
apiCallBack.onSuccess(user);
} else {
Log.e(TAG, "reSetPassword fail, fail msg is " + map.get("msg"));
apiCallBack.onFailure(String.valueOf(code));
}
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "reSetPassword error", error);
if(!HttpUtil.isNetworkAvailable(mContext)) {
ToastUtils.showMessage(mContext, R.string.no_net);
} else {
apiCallBack.onError(error, msg);
}
}
});
}
示例4: getQuTu
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void getQuTu(final Handler handler, int newOrHotFlag, int offset,
int count) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(1000 * 60 * 10); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("newOrHotFlag", String.valueOf(newOrHotFlag));
params.addQueryStringParameter("offset", String.valueOf(offset));
params.addQueryStringParameter("count", String.valueOf(count));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_LIST, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
return;
}
PageResult page = FastjsonUtil.deserialize(
map.get("data").toString(), PageResult.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("pageResult", page);
message.what = Constants.SUCCESS;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例5: refush
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void refush(final Handler handler, int newOrHotFlag, int count) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(0); //缓存超期时间0分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("newOrHotFlag", String.valueOf(newOrHotFlag));
// params.addQueryStringParameter("offset", String.valueOf(1));
params.addQueryStringParameter("count", String.valueOf(count));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_LIST, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
return;
}
PageResult page = FastjsonUtil.deserialize(
map.get("data").toString(), PageResult.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("pageResult", page);
message.what = Constants.SUCCESS_1;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例6: getMeiTu
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void getMeiTu(final Handler handler, int newOrHotFlag, int offset,
int count) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(1000 * 60 * 10); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("newOrHotFlag", String.valueOf(newOrHotFlag));
params.addQueryStringParameter("offset", String.valueOf(offset));
params.addQueryStringParameter("count", String.valueOf(count));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_LIST, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
return;
}
PageResult page = FastjsonUtil.deserialize(
map.get("data").toString(), PageResult.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("pageResult", page);
message.what = Constants.SUCCESS;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例7: refresh
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void refresh(final Handler handler, int newOrHotFlag, int count) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(0); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("newOrHotFlag", String.valueOf(newOrHotFlag));
params.addQueryStringParameter("count", String.valueOf(count));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_LIST, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
return;
}
PageResult page = FastjsonUtil.deserialize(
map.get("data").toString(), PageResult.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("pageResult", page);
message.what = Constants.SUCCESS_1;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例8: refushAll
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void refushAll(final Handler handler, int newOrHotFlag, int count) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(0); //缓存超期时间0分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("newOrHotFlag", String.valueOf(newOrHotFlag));
params.addQueryStringParameter("count", String.valueOf(count));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_LIST, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
try {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
return;
}
PageResult page = FastjsonUtil.deserialize(
map.get("data").toString(), PageResult.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("pageResult", page);
message.what = Constants.SUCCESS_1;
message.setData(bundle);
handler.sendMessage(message);
} catch (Exception e) {
handler.sendEmptyMessage(Constants.FAILURE);
}
}
@Override
public void onFailure(HttpException error, String msg) {
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例9: getCommentByJokeId
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void getCommentByJokeId(final Handler handler, int jokeId, int offset,
int count) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(60); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("qushiId", String.valueOf(jokeId));
params.addQueryStringParameter("offset", String.valueOf(offset));
params.addQueryStringParameter("count", String.valueOf(count));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_GET_COMMENTS, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
return;
}
PageResult page = FastjsonUtil.deserialize(
map.get("data").toString(), PageResult.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("pageResult", page);
message.what = Constants.SUCCESS;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例10: getJokeById
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void getJokeById(final ApiCallBack apiCallBack, Integer jokeId) {
HttpUtils http = new HttpUtils();
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
http.configDefaultHttpCacheExpiry(0);
RequestParams params = new RequestParams();
params.addQueryStringParameter("jokeId", String.valueOf(jokeId));
http.send(HttpRequest.HttpMethod.GET,
RcpUri.INTERFACE_URI_GET_JOKE, params,
new RequestCallBack<String>() {
@SuppressWarnings("rawtypes")
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if(code == Constants.SUCCESS) {
Log.e(TAG, "getJokeById success");
Joke joke = FastjsonUtil.deserialize(
map.get("data").toString(), Joke.class);
apiCallBack.onSuccess(joke);
} else {
Log.e(TAG, "getJokeById fail, fail msg is " + map.get("msg"));
apiCallBack.onFailure(String.valueOf(code));
}
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "getJokeById error", error);
if(!HttpUtil.isNetworkAvailable(mContext)) {
ToastUtils.showMessage(mContext, R.string.no_net);
} else {
apiCallBack.onError(error, msg);
}
}
});
}
示例11: getpostageFee
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
void getpostageFee(){
String goodsIds = "", weights = "";
for (CartGoods goods : cartGoodsList.cartGoodsList) {
goodsIds += goods.goodsId + ",";
if(goods.weight.endsWith("G"))
goods.weight = goods.weight.substring(0, goods.weight.length() - 1);
weights += Integer.parseInt(goods.weight) * goods.num + ",";
}
goodsIds = goodsIds.substring(0, goodsIds.length() - 1);
weights = weights.substring(0, weights.length() - 1);
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("goodsIds", goodsIds);
params.addBodyParameter("weights", weights);
HttpUtils httpUtils = new HttpUtils();
httpUtils.configDefaultHttpCacheExpiry(100);
httpUtils.send(HttpRequest.HttpMethod.POST, ApiStores.getPostageFee, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
postCost = new Gson().fromJson(responseInfo.result, ResponsePostageFee.class).data.postageFee;
if (postCost != -1) {
if (kind.equals("2")) {
iv_price_post.setImageResource(R.mipmap.icon_text_caishenbi);
tv_price_post.setTextColor(context.getResources().getColor(R.color.colorAppRed));
tv_price_post.setText(postCost + "");
} else {
postCost = postCost * 10;
iv_price_post.setImageResource(R.mipmap.icon_text_jifen);
tv_price_post.setTextColor(context.getResources().getColor(R.color.color_yellow_e9));
tv_price_post.setText(postCost + "");
}
calculateMoney();
}
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("获取邮费失败" + s, context);
Log.e("aaa", s);
}
});
}
示例12: addTencentUser
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void addTencentUser(final Handler handler, String openId, String portraitUrl, String nickName,
int sex) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(1000 * 60 * 10); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("openId", openId);
params.addQueryStringParameter("portraitUrl", portraitUrl);
try {
params.addQueryStringParameter("nickName", URLEncoder.encode(nickName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
params.addQueryStringParameter("sex", String.valueOf(sex));
http.send(HttpRequest.HttpMethod.POST,
RcpUri.INTERFACE_URI_ADD_TENCENT_USER, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
Log.e(TAG, "save user failure");
return;
}
Log.e(TAG, "save user success");
User user = FastjsonUtil.deserialize(
map.get("data").toString(), User.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("user", user);
message.what = Constants.SUCCESS;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "save user failure", error);
handler.sendEmptyMessage(Constants.FAILURE);
}
});
}
示例13: addSinaUser
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void addSinaUser(final Handler handler, String uid, String portraitUrl,
String nickName) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(1000 * 60 * 10); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("uid", uid);
params.addQueryStringParameter("portraitUrl", portraitUrl);
try {
params.addQueryStringParameter("nickName", URLEncoder.encode(nickName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
http.send(HttpRequest.HttpMethod.POST,
RcpUri.INTERFACE_URI_ADD_SINA_USER, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
if(handler != null) {
handler.sendEmptyMessage(Constants.FAILURE_2);
}
Log.e(TAG, "save user failure");
return;
}
Log.e(TAG, "save user success");
User user = FastjsonUtil.deserialize(
map.get("data").toString(), User.class);
if(handler != null) {
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("user", user);
message.what = Constants.SUCCESS_2;
message.setData(bundle);
handler.sendMessage(message);
} else {
App.currentUser = user;
App.getInstance().getSpUtil().putObject("user", user);
}
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "save user failure", error);
if(handler != null) {
handler.sendEmptyMessage(Constants.FAILURE_2);
}
}
});
}
示例14: regist
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void regist(final Handler handler, String email, String password) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(1000 * 60 * 10); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("userName", email);
params.addQueryStringParameter("password", password);
http.send(HttpRequest.HttpMethod.POST,
RcpUri.INTERFACE_URI_REGIST, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE_1);
Log.e(TAG, "regist failure");
if(code == 502) { //用户名存在
ToastUtils.showMessage(mContext, R.string.phone_exists);
}
if(code == 504) { //注册失败
ToastUtils.showMessage(mContext, R.string.regist_fail);
}
return;
}
Log.e(TAG, "regist success");
User user = FastjsonUtil.deserialize(
map.get("data").toString(), User.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("user", user);
message.what = Constants.SUCCESS_1;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "regist failure", error);
handler.sendEmptyMessage(Constants.FAILURE_1);
if(!HttpUtil.isNetworkAvailable(mContext)) {
ToastUtils.showMessage(mContext, R.string.no_net);
} else {
ToastUtils.showMessage(mContext, R.string.regist_fail);
}
}
});
}
示例15: login
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
@Override
public void login(final Handler handler, String email, String password) {
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(1000 * 60 * 10); //缓存超期时间10分钟
http.configTimeout(Constants.REQUEST_TIME_OUT); //设置超时时间
RequestParams params = new RequestParams();
params.addQueryStringParameter("userName", email);
params.addQueryStringParameter("password", password);
http.send(HttpRequest.HttpMethod.POST,
RcpUri.INTERFACE_URI_LOGIN, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String rs = responseInfo.result;
Map map = FastjsonUtil.json2Map(rs);
int code = Integer.parseInt(String.valueOf(map.get("code")));
if (code != 200) {
//请求失败
handler.sendEmptyMessage(Constants.FAILURE);
Log.e(TAG, "login failure");
if(code == 503) { //用户名不存在
ToastUtils.showMessage(mContext, R.string.no_account);
return;
}
if(code == 504) { //登录密码错误
ToastUtils.showMessage(mContext, R.string.password_error);
return;
}
ToastUtils.showMessage(mContext, R.string.login_fail);
}
Log.e(TAG, "login success");
User user = FastjsonUtil.deserialize(
map.get("data").toString(), User.class);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putSerializable("user", user);
message.what = Constants.SUCCESS;
message.setData(bundle);
handler.sendMessage(message);
}
@Override
public void onFailure(HttpException error, String msg) {
Log.e(TAG, "login failure", error);
handler.sendEmptyMessage(Constants.FAILURE);
if(!HttpUtil.isNetworkAvailable(mContext)) {
ToastUtils.showMessage(mContext, R.string.no_net);
} else {
ToastUtils.showMessage(mContext, R.string.login_fail);
}
}
});
}