Example #1
0
  /**
   * Initialize a FillUp based on a set of ContentValues. This is likely to be used when saving a
   * new FillUp into the database. By initializing the data before sending, we can perform sanity
   * checks to make sure that there isn't anything weird with the data before we commit it to the
   * database.
   *
   * @param values A ContentValues mapping of the data to load.
   */
  public FillUp(ContentValues values) {
    this((CalculationEngine) null);

    Double price = values.getAsDouble(PRICE);
    if (price != null) {
      setPrice(price);
    }

    Double odometer = values.getAsDouble(ODOMETER);
    if (odometer != null) {
      setOdometer(odometer);
    }

    Long time = values.getAsLong(DATE);
    if (time != null) {
      setDate(time);
    }

    Double amount = values.getAsDouble(AMOUNT);
    if (amount != null) {
      setAmount(amount);
    }

    Double latitude = values.getAsDouble(LATITUDE);
    if (latitude != null) {
      setLatitude(latitude);
    }

    Double longitude = values.getAsDouble(LONGITUDE);
    if (longitude != null) {
      setLongitude(longitude);
    }

    String comment = values.getAsString(COMMENT);
    if (comment != null) {
      setComment(comment);
    }

    Long vehicleId = values.getAsLong(VEHICLE_ID);
    if (vehicleId != null) {
      setVehicleId(vehicleId);
    }

    Integer isPartial = values.getAsInteger(PARTIAL);
    if (isPartial != null) {
      setPartial(isPartial == 1);
    }
  }