@Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   mDrawerToggle.onConfigurationChanged(newConfig);
   hideSoftKeyboard();
   autoCompView.setFocusable(false);
   autoCompView.setFocusableInTouchMode(true);
 }
  /** 设置地图 */
  private void setUpMap() {
    mMap.setOnMarkerClickListener(this); // 设置点击marker事件监听器
    mMap.setInfoWindowAdapter(this);
    mMap.setOnInfoWindowClickListener(this); // 设置点击infoWindow事件监听器
    mMap.setOnMapLoadedListener(this); // 设置map载入成功事件监听器
    mMap.setOnCameraChangeListener(this);
    routeSearch = new RouteSearch(getActivity());
    routeSearch.setRouteSearchListener(this);
    setLocation();
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[0], 17.904732f));
    startTextView =
        (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_start);
    startTextView.setFocusable(false);
    endTextView =
        (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_goals);
    endTextView.setFocusable(false);
    routeSearchImagebtn = (ImageButton) schoolView.findViewById(R.id.imagebtn_roadsearch_search);
    routeSearchImagebtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            strStart = startTextView.getText().toString().trim();
            strEnd = endTextView.getText().toString().trim();
            if (strStart == null || strStart.length() == 0) {
              Toast.makeText(getActivity(), "请选择起点", Toast.LENGTH_SHORT).show();
              return;
            }
            if (strEnd == null || strEnd.length() == 0) {
              Toast.makeText(getActivity(), "请选择终点", Toast.LENGTH_SHORT).show();
              return;
            }
            if (startPoint != null && endPoint != null) {
              if (NetworkUtils.isConnect(getActivity())) {
                progDialog = ProgressDialog.show(getActivity(), null, "正在搜索", true, true);
                searchRoute();
              } else {
                Toast.makeText(getActivity(), "亲,请检查网络连接", Toast.LENGTH_SHORT).show();
              }

              // searchRouteResult(startPoint, endPoint);
            }
          }
        });
  }
 public void onItemClick(AdapterView adapterView, View view, int position, long id) {
   String value = (String) adapterView.getItemAtPosition(position);
   try {
     userSelectedDestination = URLEncoder.encode(value, "UTF-8");
     autoCompView.setFocusable(false);
     autoCompView.setFocusableInTouchMode(true);
   } catch (UnsupportedEncodingException ex) {
     ex.printStackTrace();
   }
 }
 @Override
 public void onResume() {
   super.onResume(); //  call the superclass method
   if (parking_listings == null) { // Means no results have been saved till now
     try {
       locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
       Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
       locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
       if (location != null) {
         onLocationChanged(location);
         locationManager.removeUpdates(MainActivity.this);
       }
     } catch (SecurityException e) {
       Log.e("PERMISSION_EXCEPTION", "PERMISSION_NOT_GRANTED");
     }
     hideSoftKeyboard();
     autoCompView.setFocusable(false);
     autoCompView.setFocusableInTouchMode(true);
   }
 }
예제 #5
0
  @Override
  public void onClick(View arg0) {
    // TODO Auto-generated method stub
    switch (arg0.getId()) {
      case com.actionbarsherlock.R.id.abs__search_src_text:
        mSEditText.setFocusable(true);
        if (mSEditText.hasFocus() && mSEditText.getEditableText().toString().equals("")) {
          if (!mSEditText.isPopupShowing()) {
            showHistory(true);
          } else {
            mSEditText.dismissDropDown();
          }
        }

        break;

      default:
        break;
    }
  }
  @Override
  public void onClick(final View v) {
    if (v == btnCalendarStart) {
      // Launch Date Picker Dialog
      DatePickerDialog dpdStart =
          new DatePickerDialog(
              this,
              new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  // Display Selected date in textbox
                  txtDateStart.setText(
                      String.format("%02d", dayOfMonth)
                          + "/"
                          + String.format("%02d", (monthOfYear + 1))
                          + "/"
                          + year);
                  startYear = year;
                  startMonth = monthOfYear;
                  startDay = dayOfMonth;
                }
              },
              startYear,
              startMonth,
              startDay);
      dpdStart.show();
    }
    if (v == btnCalendarEnd) {
      // Launch End Date Picker Dialog
      DatePickerDialog dpdEnd =
          new DatePickerDialog(
              this,
              new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  txtDateEnd.setText(
                      String.format("%02d", dayOfMonth)
                          + "/"
                          + String.format("%02d", (monthOfYear + 1))
                          + "/"
                          + year);
                  endYear = year;
                  endMonth = monthOfYear;
                  endDay = dayOfMonth;
                }
              },
              endYear,
              endMonth,
              endDay);
      dpdEnd.show();
    }
    if (v == btnTimeStart) {
      // Launch Time Picker Dialog
      TimePickerDialog tpdStart =
          new TimePickerDialog(
              this,
              new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                  startHour = hourOfDay;
                  startMinute = minute;

                  if (startMinute != 0) {
                    Date startDate =
                        convertStringToDate(
                            startDay, startMonth, startYear, startHour, startMinute);
                    Date startDateRoundedToNearestHour = roundToNearestHour(startDate);

                    SimpleDateFormat sdf =
                        new SimpleDateFormat("dd/MM/yyyy HH:mm"); // the format of your date
                    sdf.setTimeZone(
                        TimeZone.getTimeZone("GMT-5")); // give a timezone reference for formating
                    String formattedDate = sdf.format(startDateRoundedToNearestHour);

                    String[] formattedDateSeparated = formattedDate.split(" ");
                    String[] formatDate = formattedDateSeparated[0].split("/");
                    String[] formatTime = formattedDateSeparated[1].split(":");

                    startDay = Integer.parseInt(formatDate[0]);
                    startMonth = Integer.parseInt(formatDate[1]) - 1;
                    startYear = Integer.parseInt(formatDate[2]);
                    startHour = Integer.parseInt(formatTime[0]);
                    startMinute = Integer.parseInt(formatTime[1]);

                    txtDateStart.setText(
                        String.format("%02d", startDay)
                            + "/"
                            + String.format("%02d", (startMonth + 1))
                            + "/"
                            + startYear);
                  }

                  txtTimeStart.setText(
                      String.format("%02d", startHour) + ":" + String.format("%02d", startMinute));
                }
              },
              startHour,
              startMinute,
              false);
      tpdStart.show();
    }

    if (v == btnTimeEnd) {
      // Launch Time Picker Dialog
      TimePickerDialog tpdEnd =
          new TimePickerDialog(
              this,
              new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                  endHour = hourOfDay;
                  endMinute = minute;
                  if (endMinute != 0) {
                    Date endDate =
                        convertStringToDate(endDay, endMonth, endYear, endHour, endMinute);
                    Date endDateRoundedToNearestHour = roundToNearestHour(endDate);

                    SimpleDateFormat sdf =
                        new SimpleDateFormat("dd/MM/yyyy HH:mm"); // the format of your date
                    sdf.setTimeZone(
                        TimeZone.getTimeZone("GMT-5")); // give a timezone reference for formating
                    String formattedDate = sdf.format(endDateRoundedToNearestHour);

                    String[] formattedDateSeparated = formattedDate.split(" ");
                    String[] formatDate = formattedDateSeparated[0].split("/");
                    String[] formatTime = formattedDateSeparated[1].split(":");

                    endDay = Integer.parseInt(formatDate[0]);
                    endMonth = Integer.parseInt(formatDate[1]) - 1;
                    endYear = Integer.parseInt(formatDate[2]);
                    endHour = Integer.parseInt(formatTime[0]);
                    endMinute = Integer.parseInt(formatTime[1]);

                    txtDateEnd.setText(
                        String.format("%02d", endDay)
                            + "/"
                            + String.format("%02d", (endMonth + 1))
                            + "/"
                            + endYear);
                  }

                  txtTimeEnd.setText(
                      String.format("%02d", endHour) + ":" + String.format("%02d", endMinute));
                }
              },
              endHour,
              endMinute,
              false);
      tpdEnd.show();
    }

    if (v == submitUpdate) {
      if (userSelectedDestination == null) {
        if (apiResults.getListings() != null) {
          mMap = mapFragment.getMap();
          mMap.clear();
        }
        Toast.makeText(MainActivity.this, "Destination cannot be empty", Toast.LENGTH_SHORT).show();
      } else {
        if (doDateTimeValidation()) {
          spinner.setVisibility(View.VISIBLE);
          submitUpdate.setEnabled(false);
          autoCompView.setFocusable(false);
          autoCompView.setFocusableInTouchMode(true);
          submitUpdate.getBackground().setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY);
          String sorting = "rating";
          int checked_restroom = 0;
          int checked_mobile = 0;
          int checked_indoor = 0;
          int checked_attended = 0;
          int checked_security = 0;
          int checked_valet = 0;
          long epoch_start = userSelectedStartDateTime;
          long epoch_end = userSelectedEndDateTime;
          String urlString =
              "http://api.parkwhiz.com/search?destination="
                  + userSelectedDestination
                  + "&key="
                  + getResources().getString(R.string.park_whiz_key)
                  + "&start="
                  + epoch_start
                  + "&end="
                  + epoch_end
                  + "&sort="
                  + sorting
                  + "&restroom="
                  + 0
                  + "&security="
                  + 0
                  + "&valet="
                  + 0
                  + "&indoor="
                  + 0
                  + "&eticket="
                  + 0
                  + "&attended="
                  + 0;

          Toast.makeText(MainActivity.this, "Sending your request", Toast.LENGTH_SHORT).show();
          mMap = mapFragment.getMap();
          mMap.clear();
          apiResults = new GetAPIResults(getBaseContext(), mapFragment, this);
          apiResults.execute(urlString);
          hideSoftKeyboard();
        }
      }
    }
  }