Esempio n. 1
0
  /** 保存car */
  private void saveCar() {
    Car car = (Car) SharedTools.readObject(SharedTools.Car);
    if (car.getId() != null) {
      saveDialog = Util.createLoadingDialog(MainActivity.this, "正在保存,请稍后...");
      saveDialog.show();
      String json = new Gson().toJson(car);
      MLog.i("保存车辆信息:" + json);
      JSONObject jsonObject = null;
      try {
        jsonObject = new JSONObject(json);
      } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      ListenerJSONObject lj =
          new ListenerJSONObject() {

            @Override
            public void onErrorResponse(VolleyError error) {
              // TODO Auto-generated method stub
              saveDialog.dismiss();
              MLog.i(error.toString());
              ToastUtil.showNetworkError(MainActivity.this);
            }

            @Override
            public void onResponse(JSONObject response) {
              // TODO Auto-generated method stub
              MLog.i("保存车辆信息返回:" + response);
              try {
                Boolean status = response.getBoolean("Success");
                if (status) {
                  // 保存车辆信息成功
                  saveCheckCarOrder();
                } else {
                  // 保存车辆信息失败
                  saveDialog.dismiss();
                  String Message = response.getString("Message");
                  if (Message != null && !Message.equals("")) {
                    ToastUtil.show(MainActivity.this, "保存失败!," + Message);
                  } else {
                    ToastUtil.show(MainActivity.this, "保存失败!");
                  }
                }
              } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
          };

      HttpVolley.sendNetworkConnectionJson(Urls.UpdateCar, jsonObject, lj);
    } else {
      ToastUtil.show(MainActivity.this, "车辆信息错误!");
    }
  }
Esempio n. 2
0
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    clearSelection();
    // 开启一个Fragment事务
    transaction = fragmentManager.beginTransaction();
    // 先隐藏掉所有的Fragment,以防止有多个Fragment显示在界面上的情况
    hideFragments(transaction);

    switch (v.getId()) {
      case R.id.ll_main_jiedai: // 接待Fragment
        tv_head_titled.setText(R.string.tv_head_jiedai);
        ib_main_jiedai.setImageResource(R.drawable.jiedai2);
        tv_main_jiedai.setTextColor(Color.parseColor("#3A8BCC"));
        if (jiedaiFragment == null) {
          // 如果jiedaiFragment为空,则创建一个并添加到界面上
          jiedaiFragment = new JieDaiFragment();
          transaction.add(R.id.fl_main_center, jiedaiFragment);
        } else {
          // 如果jiedaiFragment不为空,则直接将它显示出来
          transaction.show(jiedaiFragment);
          // transaction.attach(jiedaiFragment);
        }
        iv_head_two.setVisibility(View.VISIBLE);
        tv_head_save.setVisibility(View.GONE);
        iv_head_two.setBackgroundResource(R.drawable.add_kh);
        iv_head_two.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent();
                intent.setClass(MainActivity.this, AddClientActivity.class);
                startActivity(intent);
              }
            });
        break;
      case R.id.ll_main_chache: // 查车Fragment
        chaCheFragment();
        break;
      case R.id.ll_main_gdcx: // 工单查询Fragment
        tv_head_titled.setText(R.string.tv_head_gdcx);
        ib_main_gdcx.setImageResource(R.drawable.gongdanchaxun2);
        tv_main_gdcx.setTextColor(Color.parseColor("#3A8BCC"));
        if (gdcxFragment == null) {
          // 如果gdcxFragment为空,则创建一个并添加到界面上
          gdcxFragment = new GongDanChaXunFragment();
          transaction.add(R.id.fl_main_center, gdcxFragment);
          MLog.i("创建工单查询");
        } else {
          // 如果gdcxFragment不为空,则直接将它显示出来
          transaction.show(gdcxFragment);
          MLog.i("显示工单查询");
          // transaction.attach(gdcxFragment);
        }
        iv_head_two.setVisibility(View.VISIBLE);
        tv_head_save.setVisibility(View.GONE);
        iv_head_two.setBackgroundResource(R.drawable.wodexinxi);
        iv_head_two.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent();
                intent.setClass(MainActivity.this, PersonalInformationActivity.class);
                startActivityForResult(intent, Constants.PERSONALINFORMATION_TCDL);
              }
            });
        break;
    }
    transaction.commit();
  }