params.add("name",username);
params.add("password",password);
NetLoad.doPost(Value.USER_LOGIN, null, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int i, org.apache.http.Header[] headers, byte[] bytes) {
try {
JSONObject jsonObject = new JSONObject(new String(bytes));
String code = jsonObject.getString("code");
if (code.equals("200")){
UserBean bean;
JSONObject json = jsonObject.getJSONObject("msg");
Gson gson = new Gson();
bean = gson.fromJson(json.toString(), UserBean.class);
Value.userBean = bean;
Intent intent;
etUsername.setText("");
etPsw.setText("");
int score = Integer.parseInt(userBean.getScore());
Value.userBean.setScore(score+ Utils.LOGIN_POINT+"");
update(Value.userBean);
Intent it = new Intent();
it.setClass(getApplicationContext(), MainActivity.class);
startActivity(it);
}else{
Toast.makeText(LoginActivity.this, jsonObject.getString("msg"),
Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(int i, org.apache.http.Header[] headers, byte[] bytes,
Throwable throwable) {
}