use of com.vodafone360.people.datatypes.ActivityItem in project 360-Engine-for-Android by 360.
the class ActivitiesTable method getLatestStatusForContact.
/**
* Returns the latest status event for a contact with the given local contact id.
*
* @param local contact id Server contact ID.
* @param readableDb Readable SQLite database.
* @return The ActivityItem representing the latest status event for given local contact id,
* or null if nothing was found.
*/
public static ActivityItem getLatestStatusForContact(final long localContactId, final SQLiteDatabase readableDb) {
DatabaseHelper.trace(false, "DatabaseHelper getLatestStatusForContact");
Cursor cursor = null;
try {
StringBuffer query = StringBufferPool.getStringBuffer(SQLKeys.SELECT);
query.append(getFullQueryList()).append(SQLKeys.FROM).append(TABLE_NAME).append(SQLKeys.WHERE).append(Field.FLAG).append('&').append(ActivityItem.STATUS_ITEM).append(SQLKeys.AND).append(Field.LOCAL_CONTACT_ID).append('=').append(localContactId).append(" ORDER BY ").append(Field.TIMESTAMP).append(" DESC");
cursor = readableDb.rawQuery(StringBufferPool.toStringThenRelease(query), null);
if (cursor.moveToFirst()) {
final ActivityItem activityItem = new ActivityItem();
final ActivityContact activityContact = new ActivityContact();
ActivitiesTable.getQueryData(cursor, activityItem, activityContact);
return activityItem;
}
} finally {
CloseUtils.close(cursor);
cursor = null;
}
return null;
}
Aggregations