Beispiel #1
0
  protected void startActivity() {
    PreferenceUtil.getInstance(LoginActivity.this).setLogin(true);

    if (service.queryName(userName).size() > 0)
      service.updateTime(userName, RspBodyBaseBean.getTime());
    else service.insert(userName, RspBodyBaseBean.getTime());

    if (NetWork.isConnect(context)) {
      RequstClient.doRequestPersonalInfo(
          new CustomResponseHandler(this, false) {
            @Override
            public void onSuccess(int statusCode, Header[] headers, String content) {
              super.onSuccess(statusCode, headers, content);
              if (content != null && !content.equals("")) {
                try {
                  JSONObject jsonObject = new JSONObject(content);
                  String error = jsonObject.optString("error");
                  if (error.equals("0")) {
                    String dataResult = jsonObject.optString("data");
                    JSONObject codeJson = new JSONObject(dataResult);
                    Personal personal =
                        new Personal(
                            codeJson.getString("icon_img"),
                            codeJson.getString("name"),
                            codeJson.getString("score"),
                            codeJson.getString("tel_no"),
                            codeJson.getString("email"),
                            codeJson.getString("viply"),
                            codeJson.getString("security_lv"));
                    String name = "";
                    if (!personal.getName().equals("") && personal.getName() != null)
                      name = personal.getName();
                    else if (!personal.getTel_no().equals("") && personal.getTel_no() != null)
                      name = personal.getTel_no();
                    else if (!personal.getEmail().equals("") && personal.getEmail() != null)
                      name = personal.getEmail();
                    AppTools.NAME = name;
                    AppTools.ICONIMG = personal.getIco_img();
                    AppTools.VIPLV = personal.getViply();
                    AppTools.EMAIL = personal.getEmail();
                    AppTools.TEL = personal.getTel_no();
                    AppTools.PSWLV = personal.getSecurity_lv();
                    AppTools.SCORE = personal.getScore();
                    AppTools.LOGIN = true;
                    LoginActivity.this.finish();
                  } else MyToast.showShort(context, jsonObject.optString("msg"));
                } catch (JSONException e) {
                  System.out.println("e==" + e.getMessage().toString());
                  e.printStackTrace();
                }
              } else MyToast.showShort(context, "网络异常,请求超时");
            }
          });
    } else {
      MyToast.showShort(context, "网络异常,请检查网络");
    }
  }
Beispiel #2
0
 private void loadData() {
   if (NetWork.isConnect(context)) {
     RequstClient.doRequestCollect(
         new CustomResponseHandler(this) {
           @Override
           public void onSuccess(int statusCode, Header[] headers, String content) {
             super.onSuccess(statusCode, headers, content);
             if (content != null
                 && !content.equals("")
                 && !content.equals("-500")
                 && content.contains("error")) {
               try {
                 JSONObject jsonObject = new JSONObject(content);
                 String error = jsonObject.optString("error");
                 if (error.equals("0")) {
                   String data = jsonObject.optString("data");
                   JSONArray addressArray = new JSONArray(data);
                   JSONObject collect_goods = null;
                   CollectItem map = null;
                   for (int i = 0; i < addressArray.length(); i++) {
                     collect_goods = addressArray.getJSONObject(i);
                     map = new CollectItem();
                     map.id = collect_goods.getString("collect_goods_id");
                     map.img = collect_goods.getString("collect_goods_img");
                     map.title = collect_goods.getString("collect_goods_title");
                     map.price = collect_goods.getString("collect_goods_pice");
                     map.oldprice = collect_goods.getString("collect_goods_original_pice");
                     collectItems.add(map);
                   }
                   initView();
                 } else if (error.equals("-1")) {
                   String msg = jsonObject.optString("msg");
                   DisplayToast(msg);
                 }
               } catch (JSONException e) {
                 e.printStackTrace();
               }
               if (collectItems.size() == 0) {
                 no_collection.setVisibility(View.VISIBLE);
                 have_collection.setVisibility(View.GONE);
               } else {
                 no_collection.setVisibility(View.GONE);
                 have_collection.setVisibility(View.VISIBLE);
                 del_all.setVisibility(View.VISIBLE);
               }
             } else {
               DisplayToast(getString(R.string.network_please_relogin));
             }
           }
         });
   } else {
     MyToast.showShort(context, getString(R.string.network_please_check));
   }
 }
Beispiel #3
0
  /** 登录数据状态处理 */
  private void doLogin() {
    userName = mLogin_name_edt.getText().toString();
    userPass = mLogin_pswd_edt.getText().toString();
    if (userName.length() == 0) {
      DisplayToast("用户名不能为空");
      return;
    }
    if (userPass.length() == 0) {
      DisplayToast("密码不能为空");
      return;
    }
    if (NetWork.isConnect(LoginActivity.this)) {
      RequstClient.doLogin(
          userName,
          userPass,
          new CustomResponseHandler(this) {
            @Override
            public void onSuccess(int statusCode, Header[] headers, String content) {
              super.onSuccess(statusCode, headers, content);
              if (content != null && !content.equals("") && content.contains("error")) {
                JSONObject jsonObject;
                try {
                  jsonObject = new JSONObject(content);
                  String error = jsonObject.optString("error");
                  msgString = jsonObject.optString("msg");
                  if (error.equals("0")) {
                    if (ToolsManager.isMobileNO(userName)) AppTools.LOGINTYPE = 1;
                    else if (ToolsManager.isEmail(userName)) AppTools.LOGINTYPE = 2;
                    else AppTools.LOGINTYPE = 3;

                    String dataResult = jsonObject.optString("data");
                    JSONObject codeJson = new JSONObject(dataResult);
                    AppTools.UID = codeJson.getString("uid");
                    PreferenceUtil.getInstance(context).setName(userName);
                    PreferenceUtil.getInstance(context).setPsw(userPass);
                    startActivity();
                  } else {
                    DisplayToast(msgString);
                  }
                } catch (JSONException e) {
                  e.printStackTrace();
                }

              } else {
                DisplayToast(getString(R.string.network_please_relogin));
              }
            }
          });
    } else {
      DisplayToast("网络异常,登陆失败");
    }
  }
Beispiel #4
0
  /** 进行新数据提交 */
  private void CancelCollection() {
    if (adapter != null) {
      for (int i = 0; i < adapter.collect_check_state.length; i++) {
        if (adapter.collect_check_state[i] == false) {
          collectIds.add(adapter.childs.get(i).id);
        }
      }
      if (collectIds.size() > 0) {
        String sCollectId = "";
        for (int i = 0; i < collectIds.size(); i++) {
          sCollectId += collectIds.get(i).toString().trim() + ",";
        }
        if (NetWork.isConnect(context)) {
          RequstClient.doDelCollect(
              3,
              13,
              sCollectId,
              5,
              new CustomResponseHandler(this) {
                @Override
                public void onSuccess(int statusCode, Header[] headers, String content) {
                  super.onSuccess(statusCode, headers, content);
                  if (content.contains("error")) {
                    JSONObject jsonObject;
                    try {
                      jsonObject = new JSONObject(content);
                      String error = jsonObject.optString("error");
                      if (!error.equals("0")) {
                        DisplayToast(jsonObject.optString("msg"));
                      }
                    } catch (JSONException e) {
                      e.printStackTrace();
                    }
                  } else {
                    DisplayToast(getString(R.string.network_please_check));
                  }
                }
              });

        } else {
          MyToast.showShort(context, getString(R.string.network_please_check));
        }
      }
    }
    finish();
  }