Exemplo n.º 1
0
 private void openChat() {
   Intent i = new Intent(getActivity(), ConversationActivity.class);
   i.putExtra("contact", trip.getUser().getJsonString());
   startActivity(i);
 }
Exemplo n.º 2
0
 private void call() {
   String mobileNumber = trip.getUser().getMobileNumber();
   Intent i = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + mobileNumber));
   startActivity(i);
 }
Exemplo n.º 3
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();
      }
    }
  }