Пример #1
0
        @SuppressLint("ResourceAsColor")
        @Override
        public void onClick(View v) {
          try {
            switch (v.getId()) {
              case R.id.back_imgbtn:
                finish();
                break;
              case R.id.home_imgbtn:
                startActivity(new Intent(context, MainActivity.class));
                break;
              case R.id.lianxiren_icon_imgbtn:
                startActivityForResult(
                    new Intent(context, com.jike.shanglv.SeclectCity.ContactListActivity.class),
                    CONTANCT_REQUEST_CODE);
                break;
              case R.id.modify_seat_tv:
                finish();
                break;
              case R.id.djsx_tv:
              case R.id.yanzhengma_iv:
                getValidCodePic();
                break;
              case R.id.add_passager_rl:
                Intent intent =
                    new Intent(context, ActivityInlandAirlineticketSelectPassengers.class);
                intent.putExtra(ActivityInlandAirlineticketSelectPassengers.SYSTYPE, "2");
                intent.putExtra(ActivityInlandAirlineticketSelectPassengers.TITLE_NAME, "选择旅客");
                intent.putExtra(ALLPASSENGERSLIST, JSONHelper.toJSON(allPassengerList));
                intent.putExtra(SELECTEDPASSENGERSLIST, JSONHelper.toJSON(passengerList));
                startActivityForResult(intent, ADD_PASSENGERS_FORRESULET_CODE);
                break;
              case R.id.baoxian_price_and_count_tv:
              case R.id.baoxian_check_imgbtn:
              case R.id.baoxian_rl:
                Intent intent_bx = new Intent(context, ActivityTrainBaoxian.class);
                intent_bx.putExtra(
                    ActivityTrainBaoxian.BAOXIAN_BUNDSTRING,
                    baoxian_price_and_count_tv.getText().toString().trim());
                startActivityForResult(intent_bx, BAOXIAN_REQUEST_CODE);
                break;
              case R.id.order_now_btn:
                if (selectedSeatIndex == -1) {
                  order_now_btn.setEnabled(false);
                  break;
                }
                if (passengerList.size() == 0) {
                  // new AlertDialog.Builder(context).setTitle("乘客不能为空")
                  // .setMessage("请添加乘客信息!")
                  // .setPositiveButton("确定", null).show();
                  final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                  cad.setTitle("请添加乘客信息");
                  cad.setPositiveButton(
                      "确定",
                      new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          cad.dismiss();
                        }
                      });
                  break;
                } else if (remainTicketCount < passengerList.size()) {
                  final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                  cad.setTitle(
                      "当前仅剩余" + remainTicketCount + "张票,无法满足" + passengerList.size() + "个人的预订需求");
                  cad.setPositiveButton(
                      "确定",
                      new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          cad.dismiss();
                        }
                      });
                  break;
                }

                if (yanzhengma_input_et.getText().toString().length() != 4) {
                  // new AlertDialog.Builder(context).setTitle("请输入验证码")
                  // .setPositiveButton("确定", null).show();
                  final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                  cad.setTitle("请输入验证码");
                  cad.setPositiveButton(
                      "确定",
                      new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          cad.dismiss();
                        }
                      });
                  break;
                }
                if (!CommonFunc.isMobileNO(contact_person_phone_et.getText().toString().trim())) {
                  // new
                  // AlertDialog.Builder(context).setTitle("手机号码格式不正确")
                  // .setMessage("请输入合法的手机号码!")
                  // .setPositiveButton("确定", null).show();
                  final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                  cad.setTitle("手机号码格式不正确");
                  cad.setPositiveButton(
                      "确定",
                      new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          cad.dismiss();
                        }
                      });
                  break;
                } else {
                  sp.edit()
                      .putString(
                          SPkeys.trainContactPhone.getString(),
                          contact_person_phone_et.getText().toString())
                      .commit();
                }
                commitOrder();
                break;
              default:
                break;
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
Пример #2
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case VALIDCODE_MSG_CODE:
              djsx_tv.setVisibility(View.VISIBLE);
              yanzhengma_iv.setImageBitmap(validCodeBitmap);
              break;
            case COMMIT_ORDER_MSG_CODE:
              if (commitReturnJson.length() == 0) {
                getValidCodePic(); // 提交失败后需刷新验证码
                yanzhengma_input_et.setText("");
                progressdialog.dismiss();
                // new AlertDialog.Builder(context).setTitle("发生异常,订单提交失败!")
                // .setPositiveButton("确认", null).show();
                final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                cad.setTitle("发生异常,订单提交失败");
                cad.setPositiveButton(
                    "知道了",
                    new OnClickListener() {
                      @Override
                      public void onClick(View arg0) {
                        cad.dismiss();
                      }
                    });
                break;
              }
              JSONTokener jsonParser;
              jsonParser = new JSONTokener(commitReturnJson);
              try {
                JSONObject jsonObject = (JSONObject) jsonParser.nextValue();
                String state = jsonObject.getString("c");

                if (state.equals("0000")) {
                  String orderID = jsonObject.getJSONObject("d").getString("msg");
                  Intent intent = new Intent(context, ActivityTrainOrderDetail.class);
                  intent.putExtra(ActivityTrainOrderDetail.ORDERRECEIPT, orderID);
                  startActivityForResult(intent, NEW_ORDER_DETAIL_CODE);

                } else {
                  // new AlertDialog.Builder(context)
                  // .setTitle(
                  // jsonObject.getJSONObject("d")
                  // .getString("msg"))
                  // .setPositiveButton("确定", null).show();
                  final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                  cad.setTitle(jsonObject.getJSONObject("d").getString("msg"));
                  cad.setPositiveButton(
                      "知道了",
                      new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          cad.dismiss();
                        }
                      });
                  getValidCodePic(); // 提交失败后需刷新验证码
                  yanzhengma_input_et.setText("");
                }
                // else {
                // Toast.makeText(context, "发生异常,提交订单失败!", 0).show();
                // getValidCodePic();//提交失败后需刷新验证码
                // yanzhengma_input_et.setText("");
                // }
                progressdialog.dismiss();
              } catch (Exception e) {
                e.printStackTrace();
                getValidCodePic(); // 提交失败后需刷新验证码
                yanzhengma_input_et.setText("");
                progressdialog.dismiss();
              }
              break;
          }
        }