Exemplo n.º 1
0
 @Override
 protected void parserData(JSONObject response) {
   LogTool.i("登陆应答 :");
   LogTool.i(response.toString());
   android.util.Log.d("xcq", "登录返回数据: " + response.toString());
   //		String str = utils.readFile();
   try {
     //			response = new JSONObject(str);
     JSONObject obj = response.getJSONObject("result");
     String code = obj.getString("code");
     if (RESPONSE_CODE.FAIL_CODE.equals(code)) {
       ToastTool.showText(LoginAtivity.this, obj.getString("msg"));
       return;
     }
     SharedPreferenceUtil.saveUserInfo("user_name", userName, getApplicationContext());
     SharedPreferenceUtil.saveUserInfo("user_password", userPassword, getApplicationContext());
     JSONObject rsObj = obj.getJSONObject("rs");
     SysVar.getInstance(this).saveUserInfo(rsObj);
     Intent intent = new Intent(LoginAtivity.this, MainActivity.class);
     startActivity(intent);
     SysValue.is_login = true;
     this.finish();
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 2
0
 @Override
 public void initView() {
   userName = SharedPreferenceUtil.getUserInfo("user_name", this);
   userPassword = SharedPreferenceUtil.getUserInfo("user_password", this);
   user_name.setText(userName);
   user_pw.setText(userPassword);
   SystemValue.deviceId = SharedPreferenceUtil.getUserInfo(SysValue.KEY_CAMERA_ID, this);
   SystemValue.devicePass = SharedPreferenceUtil.getUserInfo(SysValue.KEY_CAMERA_PWD, this);
   SystemValue.deviceName = SharedPreferenceUtil.getUserInfo(SysValue.KEY_CAMERA_USER, this);
 }
Exemplo n.º 3
0
 @Override
 protected void onActivityResult(int arg0, int arg1, Intent arg2) {
   super.onActivityResult(arg0, arg1, arg2);
   if (null != arg2) {
     String name = arg2.getStringExtra("name");
     user_name.setText(name);
     String pwd = arg2.getStringExtra("pwd");
     user_pw.setText(pwd);
     SharedPreferenceUtil.saveUserInfo("user_name", name, getApplicationContext());
     SharedPreferenceUtil.saveUserInfo("user_password", pwd, getApplicationContext());
   }
 }
Exemplo n.º 4
0
  private void login() {
    userName = CommonUtils.getContentFromEditText(user_name);
    userPassword = CommonUtils.getContentFromEditText(user_pw);
    if (userName.equals("")) {
      ToastTool.showText(LoginAtivity.this, "请输入用户名");

      return;
    }
    if (userPassword.equals("")) {
      ToastTool.showText(LoginAtivity.this, "请输入密码");
      return;
    }
    if (!MatchTool.match(MatchTool.PWD, userPassword)) {
      ToastTool.showText(LoginAtivity.this, "请输入6-16位只包含汉字、字母、数字和特殊字符的密码");
      return;
    }
    LogTool.i("登陆请求:");
    Bundle param = new Bundle();
    param.putString("user", userName);
    param.putString("pwd", userPassword);
    reqData("/data/chklogin.json", param);
    String name = SharedPreferenceUtil.getUserInfo("user_name", this);
    // 清楚本地图片
    if (!name.equals(userName)) {
      LogTool.i("新用户登录");
      utils.deleteBtmap();
    }
  }