コード例 #1
0
ファイル: FillUp.java プロジェクト: sdustinh/android-mileage
  private void load(Cursor c) {
    int index = c.getColumnIndex(VEHICLE_ID);
    if (index >= 0) {
      m_vehicleId = c.getLong(index);
    }

    index = c.getColumnIndex(_ID);
    if (index >= 0) {
      m_id = c.getLong(index);
    }

    index = c.getColumnIndex(PRICE);
    if (index >= 0) {
      m_price = c.getDouble(index);
    }

    index = c.getColumnIndex(AMOUNT);
    if (index >= 0) {
      m_amount = c.getDouble(index);
    }

    index = c.getColumnIndex(ODOMETER);
    if (index >= 0) {
      m_odometer = c.getDouble(index);
    }

    index = c.getColumnIndex(DATE);
    if (index >= 0) {
      setDate(c.getLong(index));
    }

    index = c.getColumnIndex(LATITUDE);
    if (index >= 0) {
      m_latitude = c.getDouble(index);
    }

    index = c.getColumnIndex(LONGITUDE);
    if (index >= 0) {
      m_longitude = c.getDouble(index);
    }

    index = c.getColumnIndex(COMMENT);
    if (index >= 0) {
      m_comment = c.getString(index);
    }

    index = c.getColumnIndex(PARTIAL);
    if (index >= 0) {
      m_partial = c.getInt(index) == 1;
    }
  }
コード例 #2
0
ファイル: FillUp.java プロジェクト: sdustinh/android-mileage
  /**
   * 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);
    }
  }
コード例 #3
0
ファイル: FillUp.java プロジェクト: sdustinh/android-mileage
 public void setDate(long timestamp) {
   Calendar cal = Calendar.getInstance();
   cal.setTimeInMillis(timestamp);
   setDate(cal);
 }