@Override
          public void onClick(View v) {

            int position = (Integer) v.getTag(R.id.tag_key_position);
            LocationData item = mItems.get(position);

            EditText et = (EditText) mFragmentView.findViewById(R.id.address);
            et.setText(item.getAddress());

            doOk(item);
          }
Пример #2
0
  public ApiResponse locationFare(
      LocationData from, LocationData to, Long pickupMillis, String vehiclePk, int paymentMethod) {
    ApiRequest req =
        new ApiRequest(
            Office.getApiUrl() + "/passenger/v1/locations/fare",
            TDApplication.getSessionManager().getAccessToken());

    try {
      JSONObject pickup = new JSONObject();
      pickup.put("lat", from.getLatitude());
      pickup.put("lng", from.getLongitude());
      req.addRequestParam("pickup_location", pickup);

      JSONObject dropoff = new JSONObject();
      dropoff.put("lat", to.getLatitude());
      dropoff.put("lng", to.getLongitude());
      req.addRequestParam("dropoff_location", dropoff);

      if (pickupMillis != null) {
        Time t = new Time();
        t.set(pickupMillis);
        String timeStr = t.format3339(false).replace(".000+", "+"); // FIXME API BUG
        req.addRequestParam("pickup_time", timeStr);
      }

      String method = PaymentMethod.CASH_STRING;
      switch (paymentMethod) {
        case PaymentMethod.ACCOUNT:
          method = PaymentMethod.ACCOUNT_STRING;
          break;

        case PaymentMethod.CARD:
          method = PaymentMethod.CARD_STRING;
          break;

        case PaymentMethod.CASH:
        default:
          method = PaymentMethod.CASH_STRING;
          break;
      }
      req.addRequestParam("payment_method", method);

      if (vehiclePk != null) {
        req.addRequestParam("car_type", vehiclePk);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    return doPostRequest(req);
  }
  @Override
  protected void onPostCreateView() {

    ImageView iv = (ImageView) mFragmentView.findViewById(R.id.icon);
    EditText et = (EditText) mFragmentView.findViewById(R.id.address);

    int imgId = R.drawable.ic_launcher;
    int hintId = R.string.address_search_generic_hint;
    switch (mType) {
      case SearchActivity.TYPE_PICKUP:
        imgId = R.drawable.map_marker_pickup;
        hintId = R.string.address_search_pickup_hint;
        break;
      case SearchActivity.TYPE_DROPOFF:
        imgId = R.drawable.map_marker_dropoff;
        hintId = R.string.address_search_dropoff_hint;
        break;
    }
    iv.setImageResource(imgId);

    et.setText((mAddress != null) ? mAddress.getAddress() : "");
    et.setHint(hintId);

    et.setOnEditorActionListener(mOnEditorActionListener);
    et.addTextChangedListener(mTextWatcher);

    WebnetTools.setVisibility(
        mFragmentView, R.id.button_voice_search, mVoiceSearchAvailable ? View.VISIBLE : View.GONE);

    int[] ids = {R.id.button_voice_search, R.id.button_clear};
    for (int id : ids) {
      View v = mFragmentView.findViewById(id);
      if (v != null) {
        v.setOnClickListener(mOnClickListener);
      }
    }

    WebnetTools.setVisibility(mFragmentView, R.id.button_clear, View.GONE);

    ListView lv = (ListView) mFragmentView.findViewById(R.id.list);
    mAdapter = new ListAdapter(mParentActivity, 0, mItems);
    lv.setAdapter(mAdapter);
  }