예제 #1
0
 private void init() {
   ApplicationContext ac = ApplicationContext.getInstance();
   ac.setContext(getApplicationContext());
   int checked = ac.getChecked();
   if (checked == 0) {
     email = ac.getEmail();
     password = ac.getPassword();
     login(email, password);
   }
 }
예제 #2
0
 @Override
 public void onSuccess(JSONObject obj) {
   switch (SafeJSON.getInt(obj, "checked", -1)) {
     case 0: // 登陆成功
       ApplicationContext ac = ApplicationContext.getInstance();
       ac.saveUserInfo(obj);
       ac.setEmail(email);
       ac.setPassword(password);
       ac.setChecked(0);
       startActivity(new Intent(LoginActivity.this, MainActivity.class));
       finish();
       break;
     case 1:
       Toast.makeText(LoginActivity.this, "邮箱或密码错误", Toast.LENGTH_SHORT).show();
       break;
     case 2:
       Toast.makeText(LoginActivity.this, "账号已被停用", Toast.LENGTH_SHORT).show();
       break;
     default:
       Toast.makeText(LoginActivity.this, "未知错误", Toast.LENGTH_SHORT).show();
   }
 }