コード例 #1
0
 public void setView(SearchResultItem item) {
   ImageUtil.setRoundRectangleImageFromURL(
       MyApplication.getmContext(),
       item.getImageURL(),
       R.drawable.detailpage_bike_image_noneimage,
       bicycle_picture,
       MyApplication.getmContext()
           .getResources()
           .getDimension(R.dimen.view_search_result_item_bicycle_picture_image_view_round_radius));
   bicycle_name.setText(item.getBicycle_name().toString());
   String heightString = "~145cm";
   switch (item.getHeight().toString()) {
     case "01":
       heightString = "~145cm";
       break;
     case "02":
       heightString = "145cm~155cm";
       break;
     case "03":
       heightString = "155cm~165cm";
       break;
     case "04":
       heightString = "165cm~175cm";
       break;
     case "05":
       heightString = "175cm~185cm";
       break;
     case "06":
       heightString = "185cm~";
       break;
   }
   height.setText(heightString);
   String typeString = "보급형";
   switch (item.getType().toString()) {
     case "A":
       typeString = "보급형";
       break;
     case "B":
       typeString = "산악용";
       break;
     case "C":
       typeString = "하이브리드";
       break;
     case "D":
       typeString = "픽시";
       break;
     case "E":
       typeString = "폴딩";
       break;
     case "F":
       typeString = "미니벨로";
       break;
     case "G":
       typeString = "전기자전거";
       break;
   }
   type.setText(typeString);
   payment.setText(decimalFormat.format(Long.parseLong(item.getPayment())) + "원");
   distance.setText((Math.round(item.getDistance() * 10.0) / 10.0) + "km");
 }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_finally_payment);
    Toolbar toolbar = (Toolbar) findViewById(R.id.activity_finally_payment_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setCustomView(R.layout.toolbar);

    ButterKnife.bind(this);

    /* 툴바 배경 */
    if (Build.VERSION.SDK_INT < 23)
      toolbarLayout.setBackgroundColor(getResources().getColor(R.color.bikeeWhite));
    else toolbarLayout.setBackgroundColor(getResources().getColor(R.color.bikeeWhite, getTheme()));

    /* 툴바 왼쪽 */
    toolbarLeftBackIconImageView.setVisibility(View.VISIBLE);
    toolbarLeftBackIconImageView.setImageResource(R.drawable.icon_before);

    /* 툴바 가운데 */
    toolbarCenterTextView.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT < 23)
      toolbarCenterTextView.setTextColor(getResources().getColor(R.color.bikeeBlack));
    else
      toolbarCenterTextView.setTextColor(getResources().getColor(R.color.bikeeBlack, getTheme()));
    toolbarCenterTextView.setText("결제하기");

    intent = getIntent();
    bicycleId = intent.getStringExtra("BICYCLE_ID");
    bicycleImage = intent.getStringExtra("BICYCLE_IMAGE");
    bicycleName = intent.getStringExtra("BICYCLE_NAME");
    listerId = intent.getStringExtra("LISTER_ID");
    listerName = intent.getStringExtra("LISTER_NAME");
    reservationId = intent.getStringExtra("RESERVATION_ID");
    rentalStartDate = (Date) intent.getSerializableExtra("RENTAL_START_DATE");
    rentalEndDate = (Date) intent.getSerializableExtra("RENTAL_END_DATE");
    rentalPeriod = intent.getStringExtra("RENTAL_PERIOD");
    rentalPrice = intent.getIntExtra("RENTAL_PRICE", -1);
    renterEmail = PropertyManager.getInstance().getEmail();
    renterName = PropertyManager.getInstance().getName();
    cardId = intent.getStringExtra("CARD_ID");

    ImageUtil.setRoundRectangleImageFromURL(
        this,
        bicycleImage,
        R.drawable.detailpage_bike_image_noneimage,
        bicyclePictureImageView,
        getResources()
            .getDimension(
                R.dimen
                    .activity_finally_payment_bicycle_information_bicycle_picture_image_view_round_radius));
    bicycleTitleTextView.setText(bicycleName);
    listerNameTextView.setText(listerName);
    SimpleDateFormat simpleDateFormat =
        new SimpleDateFormat("MM/dd ah:mm", java.util.Locale.getDefault());
    rentalStartDateTextView.setText(simpleDateFormat.format(rentalStartDate));
    rentalEndDateTextView.setText(simpleDateFormat.format(rentalEndDate));
    rentalPeriodTextView.setText(rentalPeriod);
    paymentTextView.setText("" + rentalPrice);

    NetworkManager.getInstance()
        .receiveCardToken(
            null,
            new Callback<CardTokenReceiveObject>() {
              @Override
              public void onResponse(
                  Call<CardTokenReceiveObject> call, Response<CardTokenReceiveObject> response) {
                if (BuildConfig.DEBUG) Log.d(TAG, "receiveCardToken onResponse");

                CardTokenReceiveObject cardTokenReceiveObject = response.body();
                cardTokenReceiveObject.getToken();

                IAmPortSendObject iAmPortSendObject = new IAmPortSendObject();
                iAmPortSendObject.setMerchant_uid("bikee_" + new Date().getTime());
                // TODO : 가격 입력, 현재 하드코딩됨
                iAmPortSendObject.setAmount(1000);

                IAmPortNetworkManager.getInstance()
                    .prepayment(
                        cardTokenReceiveObject.getToken(),
                        iAmPortSendObject,
                        null,
                        new Callback<IAmPortReceiveObject>() {
                          @Override
                          public void onResponse(
                              Call<IAmPortReceiveObject> call,
                              Response<IAmPortReceiveObject> response) {
                            IAmPortReceiveObject iAmPortReceiveObject = response.body();

                            if (BuildConfig.DEBUG) Log.d(TAG, "prepayment onResponse");

                            if (iAmPortReceiveObject.getCode().equals("0")) {
                              if (BuildConfig.DEBUG) Log.d(TAG, "prepayment 사전 결제 성공");

                              paymentSendObject = new PaymentSendObject();
                              paymentSendObject.setAmount(
                                  iAmPortReceiveObject.getResponse().getAmount());
                              paymentSendObject.setMerchant_uid(
                                  iAmPortReceiveObject.getResponse().getMerchant_uid());
                              paymentSendObject.setLister(listerId);
                              paymentSendObject.setBike(bicycleId);
                              paymentSendObject.setName(bicycleName);
                              paymentSendObject.setBuyer_email(renterEmail);
                              paymentSendObject.setBuyer_name(renterName);
                            } else {
                              if (BuildConfig.DEBUG) Log.d(TAG, "prepayment 사전 결제 실패");
                            }
                          }

                          @Override
                          public void onFailure(Call<IAmPortReceiveObject> call, Throwable t) {
                            if (BuildConfig.DEBUG) Log.d(TAG, "prepayment onFailure", t);
                          }
                        });
              }

              @Override
              public void onFailure(Call<CardTokenReceiveObject> call, Throwable t) {
                if (BuildConfig.DEBUG) Log.d(TAG, "receiveCardToken onFailure", t);
              }
            });
  }