@SuppressWarnings("static-access")
  @Override
  protected void onPostExecute(String result) {
    super.onPostExecute(result);
    this.result = result;

    LogUtils.d(result); // TODO

    if (!StringUtil.isEmptyString(result)) {
      try {
        this.jsonResult = MyGson.getInstance().fromJson(result, BaseResult.class);
      } catch (Exception e) {
        this.jsonResult = Constants.JSON_ERROR;
        e.printStackTrace();
      }
    } else {
      this.jsonResult = Constants.SERVER_ERROR;
    }
    try {
      JSONObject jo = new JSONObject(result).getJSONObject("resultParm");
      Map<String, String> map = new HashMap<String, String>();
      Iterator<String> keys = jo.keys();

      while (keys.hasNext()) {
        String k = keys.next();
        map.put(k, jo.getString(k));
      }
      this.jsonResult.setResultParam(map);
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (dataReturnListener != null) {
      dataReturnListener.onDataReturn(Tasktag, jsonResult, result);
    }
  }
Exemplo n.º 2
0
  @Override
  protected String doInBackground(Object... executeParams) {
    String url = (String) executeParams[0];
    String method = (String) executeParams[2];
    @SuppressWarnings("unchecked")
    Map<String, String> parames = (Map<String, String>) executeParams[1];
    try {
      if (method.equals(POST)) {
        return HttpConnection.doPOSTMethod(url, parames);
      } else {
        return HttpConnection.doGETMethod(url, parames);
      }

    } catch (Exception e) {
      LogUtils.e(e.toString());
    }
    return "";
  }
Exemplo n.º 3
0
  @Override
  public void onClick(View v) {
    String tag = (String) v.getTag();
    if (tag.equals("EDIT")) {
      String text = (String) editBtn.getText();
      if (text.equals("编辑")) {
        data = getData();
        listView.setAdapter(new CarEditAdapter(getActivity(), data));
        commitBtn.setClickable(false);
        editBtn.setText("完成");
      } else if (text.equals("完成")) {
        data = getData();
        listView.setAdapter(new CarAdapter(getActivity(), data));
        editBtn.setText("编辑");
        commitBtn.setClickable(true);
      }
    } else if (tag.equals("COMMIT")) {
      if (getPrice() == 0f) {
        msg = new MessageDialog(getActivity());
        msg.setMessage("所选商品数量为0!");
        msg.show();
      } else if (Constants.user.getUserId() == null) {
        LogUtils.v("用户没有登录");
        DoubleButtonMessageDialog doubleBtnMsg =
            new DoubleButtonMessageDialog(getActivity(), "你还没有登录!");
        doubleBtnMsg.setPositiveButton(
            "登录",
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                getActivity().startActivity(intent);
              }
            });
        doubleBtnMsg.setNegativeButton("返回", null);
        doubleBtnMsg.show();
      } else {
        Intent intent = new Intent(getActivity(), SubmitOrder.class);
        getActivity().startActivity(intent);
      }
    }
    setPrice();
  }