Пример #1
0
 private void getIntentTrainInfo() {
   Bundle bundle = this.getIntent().getExtras();
   try {
     if (bundle != null) {
       if (bundle.containsKey("TrainListItemString")) {
         JSONObject jsonObject = new JSONObject(bundle.getString("TrainListItemString"));
         ti = JSONHelper.parseObject(jsonObject, TrainListItem.class);
       }
       if (bundle.containsKey("SeatListString")) {
         JSONArray array = new JSONArray(bundle.getString("SeatListString"));
         ArrayList<Seat> seats = new ArrayList<Seat>();
         Boolean hasSelectedASeatBoolean = false;
         for (int i = 0; i < array.length(); i++) {
           Seat seat = new Seat();
           seat.setPrice(array.getJSONObject(i).getString("price"));
           seat.setShengyu(array.getJSONObject(i).getString("shengyu"));
           seat.setType(array.getJSONObject(i).getString("type"));
           seats.add(seat);
           if (!hasSelectedASeatBoolean && !seat.getShengyu().equals("0")) {
             selectedSeatIndex = i;
             ticket_price = Float.valueOf(array.getJSONObject(i).getString("price"));
             hasSelectedASeatBoolean = true;
           }
         }
         ti.setSeatList(seats);
       }
       if (bundle.containsKey("startdate")) {
         Calendar c = Calendar.getInstance();
         startdate = bundle.getString("startdate");
         start_date_tv.setText(startdate);
         String sd = startdate + " " + ti.getGoTime() + ":00";
         Date date = new SimpleDateFormat("yy-MM-dd HH:mm:ss").parse(sd);
         c.setTime(date);
         Time run_time = new Time(ti.getRunTime());
         c.set(Calendar.HOUR_OF_DAY, c.get(Calendar.HOUR_OF_DAY) + Time.HOUR);
         c.set(Calendar.MINUTE, c.get(Calendar.MINUTE) + Time.MINUTE);
         String arriveDay = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
         end_date_tv.setText(arriveDay);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #2
0
 private String getPassengers() {
   String psgsString = "";
   ArrayList<TrainOrderPassenger> trainOrderPassengerList = new ArrayList<TrainOrderPassenger>();
   for (int i = 0; i < passengerList.size(); i++) {
     TrainOrderPassenger trainOrderPassenger = new TrainOrderPassenger();
     trainOrderPassenger.setCardNo(passengerList.get(i).getIdentificationNum());
     trainOrderPassenger.setCardType(passengerList.get(i).getIdentificationType());
     trainOrderPassenger.setIncAmount(String.valueOf(baoxian_unitPrice));
     trainOrderPassenger.setPhone(
         passengerList.get(i).getMobie() == null ? "" : passengerList.get(i).getMobie());
     trainOrderPassenger.setSaleprice(ticket_price + "");
     trainOrderPassenger.setSeatType(seat_Type);
     try { // URLEncoder.encode(passengerList.get(i).getPassengerName(),
       // "utf-8")
       trainOrderPassenger.setPsgName(passengerList.get(i).getPassengerName());
       trainOrderPassenger.setTicketType(passengerList.get(i).getPassengerType());
     } catch (Exception e) {
       // TODO: handle exception
     }
     trainOrderPassengerList.add(trainOrderPassenger);
   }
   psgsString = JSONHelper.toJSON(trainOrderPassengerList);
   return psgsString;
 }
Пример #3
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   try {
     switch (resultCode) {
       case ActivityInlandAirlineticketSelectPassengers.SELECTED_FINISH:
         Bundle b = null;
         if (data != null) {
           b = data.getExtras();
         } else break;
         String passengerListString = "", allPassengerListString = "";
         if (b != null && b.containsKey(SELECTEDPASSENGERSLIST)) {
           passengerListString = b.getString(SELECTEDPASSENGERSLIST);
         }
         if (b != null && b.containsKey(ALLPASSENGERSLIST)) {
           allPassengerListString = b.getString(ALLPASSENGERSLIST);
         } else break;
         try {
           passengerList.clear();
           passengerList =
               (ArrayList<Passenger>)
                   JSONHelper.parseCollection(passengerListString, List.class, Passenger.class);
           allPassengerList =
               (ArrayList<Passenger>)
                   JSONHelper.parseCollection(allPassengerListString, List.class, Passenger.class);
           passengerList =
               ActivityInlandAirlineticketBooking.removeDuplictePassengers(passengerList);
           caculateMoney();
           if (passengerList.size() > 0) {
             add_passager_tv.setText("修改乘客");
             passenger_head_divid_line.setVisibility(View.VISIBLE);
           } else if (passengerList.size() == 0) {
             add_passager_tv.setText("新增乘客");
             passenger_head_divid_line.setVisibility(View.GONE);
           }
           ListAdapter adapter = new PassengerListAdapter(context, passengerList);
           passenger_listview.setAdapter(adapter);
           ActivityInlandAirlineticketBooking.setListViewHeightBasedOnChildren(passenger_listview);
         } catch (Exception e) {
           e.printStackTrace();
           break;
         }
         break;
       default:
         break;
     }
     if (requestCode == CONTANCT_REQUEST_CODE) { // 联系人
       if (data == null) return;
       Bundle b = data.getExtras();
       if (b != null && b.containsKey("pickedPhoneNum")) {
         String myNum = b.getString("pickedPhoneNum");
         if (myNum.startsWith("17951")) {
           myNum = myNum.substring(5);
         } else if (myNum.startsWith("+86")) {
           myNum = myNum.substring(3);
         }
         contact_person_phone_et.setText(myNum);
       }
     } else if (requestCode == BAOXIAN_REQUEST_CODE) {
       if (data == null) return;
       Bundle b = data.getExtras();
       if (b != null && b.containsKey(ActivityTrainBaoxian.BAOXIAN_BUNDSTRING)) {
         String baoxian = b.getString(ActivityTrainBaoxian.BAOXIAN_BUNDSTRING);
         baoxian_price_and_count_tv.setText(baoxian);
         if (baoxian.equals(ActivityTrainBaoxian.No_Baoxian)) {
           baoxian_unitPrice = 0;
         } else if (baoxian.equals(ActivityTrainBaoxian.Baoxian_Five)) {
           baoxian_unitPrice = 5;
         } else if (baoxian.equals(ActivityTrainBaoxian.Baoxian_Ten)) {
           baoxian_unitPrice = 10;
         }
       }
       caculateMoney();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #4
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();
          }
        }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    try {
      super.onCreate(savedInstanceState);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.activity_hotel_location);
      ((MyApplication) getApplication()).addActivity(this);

      mMapView = (MapView) findViewById(R.id.bmapView);
      mBaidumap = mMapView.getMap();

      ((ImageButton) findViewById(R.id.back_imgbtn))
          .setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  finish();
                }
              });

      mLocationClient = new LocationClient(this.getApplicationContext());
      mLocationClient.registerLocationListener(new MyLocationListener());
      InitLocation();
      mLocationClient.start();
      mLocationClient.requestLocation();

      HotelDetail maphotel = null;
      Marker marker = null;
      BitmapDescriptor mIconMaker;
      OverlayOptions overlayOptions = null;
      Bundle bundle = this.getIntent().getExtras();
      if (bundle != null)
        if (bundle.containsKey("hotel"))
          try {
            maphotel = JSONHelper.parseObject(bundle.getString("hotel"), HotelDetail.class);
          } catch (Exception e) {
            e.printStackTrace();
          }
      LatLng latLng =
          new LatLng(Double.parseDouble(maphotel.getY()), Double.parseDouble(maphotel.getX()));
      hotelY = Double.parseDouble(maphotel.getY());
      hotelX = Double.parseDouble(maphotel.getX());
      View view = getMapView(maphotel.getHotelname(), maphotel.getMin_price());
      mIconMaker = BitmapDescriptorFactory.fromView(view);
      // 图标
      overlayOptions = new MarkerOptions().position(latLng).icon(mIconMaker).zIndex(5);
      marker = (Marker) (mBaidumap.addOverlay(overlayOptions));

      // 设定中心点坐标
      MapStatus mMapStatus = new MapStatus.Builder().target(latLng).zoom(16).build();
      // 定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
      MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
      mBaidumap.setMapStatus(mMapStatusUpdate);

      mBaidumap.setOnMarkerClickListener(
          new OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(final Marker marker) {
              // startNavi();
              return true;
            }
          });

      ((ImageButton) findViewById(R.id.navi_imgbtn))
          .setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                  startNavi();
                }
              });
    } catch (Exception e) {
      e.printStackTrace();
    }
  }