Пример #1
0
  /*Filter Arrival Airport*/
  public static void filterArrivalAirport(String code) {
    Log.e("Filter", "TRUE");

    JSONArray jsonFlight = getFlight(MainFragmentActivity.getContext());
    dataFlightArrival = new ArrayList<>();

    /*Display Arrival*/
    for (int i = 0; i < jsonFlight.length(); i++) {
      JSONObject row = (JSONObject) jsonFlight.opt(i);
      if (code.equals(row.optString("location_code")) && row.optString("status").equals("Y")) {
        Log.e(code, row.optString("location_code"));

        DropDownItem itemFlight = new DropDownItem();
        itemFlight.setText(row.optString("travel_location"));
        itemFlight.setCode(row.optString("travel_location_code" + ""));
        itemFlight.setTag("FLIGHT_DEPARTURE");
        dataFlightArrival.add(itemFlight);
      }
    }
    Log.e("Arrive", dataFlightArrival.toString());
  }
Пример #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.mobile_checkin_1, container, false);
    ButterKnife.inject(this, view);

    /*Preference Manager*/
    pref = new SharedPrefManager(MainFragmentActivity.getContext());

    txtDeparture.setTag(DEPARTURE_FLIGHT);
    txtArrive.setTag(ARRIVAL_FLIGHT);

    /*Retrieve All Flight Data From Preference Manager - Display Flight Data*/
    JSONArray jsonFlight = getFlight(getActivity());
    dataFlightDeparture = new ArrayList<>();

    ArrayList<String> tempFlight = new ArrayList<>();

    /*Get All Airport - remove redundant*/
    List<String> al = new ArrayList<>();
    Set<String> hs = new LinkedHashSet<>();
    for (int i = 0; i < jsonFlight.length(); i++) {
      JSONObject row = (JSONObject) jsonFlight.opt(i);
      al.add(row.optString("location") + "-" + row.optString("location_code"));
    }
    hs.addAll(al);
    al.clear();
    al.addAll(hs);

    /*Display Airport*/
    for (int i = 0; i < al.size(); i++) {
      String flightSplit = al.get(i).toString();
      String[] str1 = flightSplit.split("-");
      String p1 = str1[0];
      String p2 = str1[1];

      DropDownItem itemFlight = new DropDownItem();
      itemFlight.setText(p1);
      itemFlight.setCode(p2);
      itemFlight.setTag("FLIGHT");
      dataFlightDeparture.add(itemFlight);
    }

    /*Departure Flight Clicked*/
    txtDeparture.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            AnalyticsApplication.sendEvent("Click", "txtDeparture");
            popupSelection(dataFlightDeparture, getActivity(), txtDeparture, true);
            // txtDeparture.setText("ARRIVAL AIRPORT");
          }
        });

    /*Arrival Flight Clicked*/
    txtArrive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            AnalyticsApplication.sendEvent("Click", "btnArrivalFlight");
            if (txtDeparture.getTag().toString().equals("NOT SELECTED")) {
              popupAlert("Select Departure Airport First");
            } else {
              popupSelection(dataFlightArrival, getActivity(), txtArrive, true);
            }
          }
        });

    mobileCheckInNext1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            checkinFlight();
            // goCheckin2Page();
          }
        });
    return view;
  }