@Override public BookingInfo getCurrencyRate(BookingInfo bookingInfo) throws IllegalArgumentException { logger.info("getCurrencyRate " + bookingInfo.getCurrency()); Float rate = currencyManager.getRate(bookingInfo.getCurrency()); if (rate == null) { logger.info("getCurrencyRate is null, defaulting to USD "); bookingInfo.setCurrency(Currency.USD); } bookingInfo.setRate(rate); logger.info("getCurrencyRate " + bookingInfo.getRate()); return bookingInfo; }
/** * DESCRIPTION: Constructs and populates a View for display of the GasRecord date at the index of * the List specified by the position parameter. * * @see android.widget.ArrayAdapter#getView(int, android.view.View, android.view.ViewGroup) */ @Override public View getView(int position, View view, ViewGroup parent) { // create a view for the row if it doesn't already exist if (view == null) { LayoutInflater inflater = activity.getLayoutInflater(); view = inflater.inflate(R.layout.row_gas_log_list, null); } // get widgets from the view TextView columnDate = (TextView) view.findViewById(R.id.columnDate); TextView columnOdometer = (TextView) view.findViewById(R.id.columnOdometer); TextView columnGallons = (TextView) view.findViewById(R.id.columnGallons); TextView columnMileage = (TextView) view.findViewById(R.id.columnMileage); TextView rowCost = (TextView) view.findViewById(R.id.rowCost); TextView rowNotes = (TextView) view.findViewById(R.id.rowNotes); // populate row widgets from record data GasRecord record = records.get(position); // date columnDate.setText(record.getDateString()); // odometer (bold if tank is full) if (record.isFullTank()) { columnOdometer.setText(Html.fromHtml("<b>" + record.getOdometerString() + "</b>")); } else { columnOdometer.setText(record.getOdometerString()); } // gallons columnGallons.setText(record.getGallonsString()); // mpg String mileage = ""; if (record.hasCalculation()) { mileage = record.getCalculation().getMileageString(); if (mileage.length() > "9999.99".length()) { mileage = "#VAL!"; } if (record.isCalculationHidden()) { mileage = "---"; } } columnMileage.setText(mileage); // cost (don't display if zero) if (!isCostDisplayable || (record.getCost() == 0d)) { rowCost.setVisibility(View.GONE); } else { String cost = String.format( "<b>%s</b>: %s (%s %s)", App.getContext().getString(R.string.cost_label), CurrencyManager.getInstance().getSymbolicFormatter().format(record.getCost()), CurrencyManager.getInstance() .getSymbolicFractionalFormatter() .format(record.getPrice()), units.getLiquidVolumeRatioLabel()); rowCost.setText(Html.fromHtml(cost)); rowCost.setVisibility(View.VISIBLE); } // notes (don't display if blank) String notes = record.getNotes(); if (!isNotesDisplayable || (notes == null) || notes.trim().isEmpty()) { rowNotes.setVisibility(View.GONE); } else { notes = String.format("<b>%s</b>: %s", App.getContext().getString(R.string.notes_label), notes); rowNotes.setText(Html.fromHtml(notes)); rowNotes.setVisibility(View.VISIBLE); } // return the view return view; }