예제 #1
0
  private void check_update() {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("version", "02.03.1505");
    map.put("type", "0");
    MyHttpClient.doPost2(
        LoginActivity.this,
        new NetRespondPost() {
          @Override
          public void netWorkOk(String json) {
            JSONObject jsonObject = JSONObject.parseObject(json);
            String code = jsonObject.getString("code");
            if (code.equals("200")) {
              JSONObject data1 = jsonObject.getJSONObject("data");
              Version_netItem = JSONObject.parseObject(data1.toString(), Version_net.class);
              check_version();
            } else {
              Toast.makeText(LoginActivity.this, jsonObject.getString("desc"), Toast.LENGTH_SHORT)
                  .show();
            }
          }

          @Override
          public void netWorkError() {}
        },
        NewMyPath.checkRoutine_path,
        map,
        null);
  }
예제 #2
0
  private void login() {
    //		final ProgressDialog progressDialog = ProgressDialog.show(this, "请稍等...", "获取数据中...", true);
    final CustomProgressDialog progressDialog = CustomProgressDialog.show(this, "加载中");
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("name", user.getText().toString());
    map.put("pwd", passwd.getText().toString());
    MyHttpClient.doPost1(
        LoginActivity.this,
        new NetRespondPost() {
          @Override
          public void netWorkOk(String json) {
            progressDialog.dismiss();
            // 关闭软键盘
            View view = getWindow().peekDecorView();
            if (view != null) {
              InputMethodManager inputmanger =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }

            JSONObject jsonObject = JSONObject.parseObject(json);
            String code = jsonObject.getString("code");
            if (code.equals("200")) {
              DB.setUsername(LoginActivity.this, user.getText().toString());
              Intent intent = new Intent(LoginActivity.this, NmainActivity.class);

              startActivity(intent);
              finish();
            } else {
              Toast.makeText(LoginActivity.this, jsonObject.getString("desc"), Toast.LENGTH_LONG)
                  .show();
              View view1 = (View) findViewById(R.id.login_error);
              view1.setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void netWorkError() {
            progressDialog.dismiss();
            Net_err.net_err(LoginActivity.this);
          }
        },
        NewMyPath.login_path,
        map);
  }