Search in sources :

Example 16 with ActivityItem

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;
}
Also used : ActivityContact(com.vodafone360.people.datatypes.ActivityContact) Cursor(android.database.Cursor) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Aggregations

ActivityItem (com.vodafone360.people.datatypes.ActivityItem)13 ArrayList (java.util.ArrayList)10 ServiceStatus (com.vodafone360.people.service.ServiceStatus)7 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)5 Cursor (android.database.Cursor)3 MediumTest (android.test.suitebuilder.annotation.MediumTest)3 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)3 ContentValues (android.content.ContentValues)2 Flag (com.vodafone360.people.datatypes.ActivityItem.Flag)2 Visibility (com.vodafone360.people.datatypes.ActivityItem.Visibility)2 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)2 SQLException (android.database.SQLException)1 SQLiteStatement (android.database.sqlite.SQLiteStatement)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 TimelineSummaryItem (com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)1 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)1 Identity (com.vodafone360.people.datatypes.Identity)1 ServerError (com.vodafone360.people.datatypes.ServerError)1 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)1