private void fromCursor(Cursor cursor) { mPresence = getInt(cursor, Data.PRESENCE, -1); mStatus = getString(cursor, Data.STATUS); mTimestamp = getLong(cursor, Data.STATUS_TIMESTAMP, -1); mResPackage = getString(cursor, Data.STATUS_RES_PACKAGE); mIconRes = getInt(cursor, Data.STATUS_ICON, -1); mLabelRes = getInt(cursor, Data.STATUS_LABEL, -1); }
/** * Attempt updating this {@link DataStatus} based on values at the * current row of the given {@link Cursor}. */ public void possibleUpdate(Cursor cursor) { final boolean hasStatus = !isNull(cursor, Data.STATUS); final boolean hasTimestamp = !isNull(cursor, Data.STATUS_TIMESTAMP); // Bail early when not valid status, or when previous status was // found and we can't compare this one. if (!hasStatus) return; if (isValid() && !hasTimestamp) return; if (hasTimestamp) { // Compare timestamps and bail if older status final long newTimestamp = getLong(cursor, Data.STATUS_TIMESTAMP, -1); if (newTimestamp < mTimestamp) return; mTimestamp = newTimestamp; } // Fill in remaining details from cursor fromCursor(cursor); }