Example #1
0
  public void sendRideRequest() {
    try {
      homeCallbacks.showProgress(true, R.string.loading_loading);
      // showProgress(true, R.string.loading_loading);
      // AppTripsSet tripsSet = DataStore.getInstance().getSearchTripSet();

      AppArea orig = DataStore.getInstance().getAreaById(trip.getOriginId());
      AppArea dest = DataStore.getInstance().getAreaById(trip.getDestId());
      String destId = "-1";
      String origId = "-1";
      if (orig != null) origId = orig.getId();
      if (dest != null) destId = dest.getId();

      // if(tripsSet != null){
      destId = trip.getDestId(); // tripsSet.getToAreaSet();
      origId = trip.getOriginId(); // tripsSet.getFromAreaSet();
      // }

      DataStore.getInstance().sendRideRequest(origId, destId, trip.getId(), callbackRequestRide);
      //			Intent i = new Intent(this, ConversationActivity.class);
      //			i.putExtra("contact", trip.getUser().getJsonString());
      //			startActivity(i);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #2
0
  public void updateFrag(AppTrip trip) {
    if (trip != null) {
      this.trip = trip;
      try {
        AppUser driver = trip.getUser();
        String meId = DataStore.getInstance().getMe().getId();
        AppArea dest = DataStore.getInstance().getAreaById(trip.getDestId());
        AppArea orign = DataStore.getInstance().getAreaById(trip.getOriginId());
        boolean isMe = meId.equals(driver.getId());
        if (isMe) tvName.setText(R.string.me);
        else tvName.setText(driver.getFirstName());

        // init
        btnsContainer.setAlpha(1f);
        btnCall.setEnabled(true);
        btnChat.setEnabled(true);
        btnSendRequest.setEnabled(true);
        tvFull.setVisibility(View.GONE);
        // end init

        if (trip.isFull()) {
          tvFull.setVisibility(View.VISIBLE);
          btnSendRequest.setEnabled(false);
        }
        tvPrice.setText(trip.getPrice() + "\n" + getString(R.string.main_trip_card_price_suffix));
        tvJob.setText(driver.getJob());
        tvTime.setText(getString(R.string.main_trip_card_time_prefix) + " " + trip.getTime());
        if (orign != null)
          tvOrig.setText(getString(R.string.frag_trip_card_from) + orign.getName());
        if (dest != null) tvDest.setText(getString(R.string.frag_trip_card_to) + dest.getName());

        String date = "";
        if (trip.isReccuring()) {
          date =
              getString(R.string.main_trip_card_days_prefix)
                  + " "
                  + trip.getweekDaysString(getResources());
        } else {
          date = getString(R.string.main_trip_card_date_prefix) + " " + trip.getDate();
        }
        tvDate.setText(date);
        if (isMe) {
          btnsContainer.setAlpha(0.4f);
          btnCall.setEnabled(false);
          btnChat.setEnabled(false);
          btnSendRequest.setEnabled(false);
        } else {
          btnsContainer.setAlpha(1f);
          btnCall.setEnabled(true);
          btnChat.setEnabled(true);
          btnSendRequest.setEnabled(true);
        }
        if (trip.isMobileNumberEnabled()) btnCall.setVisibility(View.VISIBLE);
        else btnCall.setVisibility(View.GONE);
        if (trip.HasBookedByUserBefore()) {
          btnSendRequest.setAlpha(0.4f);
          btnSendRequest.setEnabled(false);
        }
        PhotoProvider.getInstance().displayProfilePicture(driver.getPhotoPath(), ivUser);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }