|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.database.tables.ActivitiesTable
public abstract class ActivitiesTable
Contains all the functionality related to the activities database table. This class is never instantiated hence all methods must be static.
Nested Class Summary | |
---|---|
static class |
ActivitiesTable.Field
An enumeration of all the field names in the database. |
static class |
ActivitiesTable.TimelineNativeTypes
An enumeration of supported timeline types. |
static class |
ActivitiesTable.TimelineSummaryItem
This class encapsulates a timeline activity item. |
Field Summary | |
---|---|
private static int |
CLEANUP_MAX_AGE_DAYS
Database cleanup will delete any activity older than X days. |
private static int |
CLEANUP_MAX_QUANTITY
Database cleanup will delete older activities after the first X. |
private static int |
NUMBER_OF_MS_IN_A_DAY
Number of milliseconds in a day. |
private static int |
NUMBER_OF_MS_IN_A_SECOND
Number of milliseconds in a second. |
private static java.lang.String |
TABLE_INDEX_NAME
|
private static java.lang.String |
TABLE_NAME
The name of the table as it appears in the database. |
Constructor Summary | |
---|---|
private |
ActivitiesTable()
Private constructor to prevent instantiation. |
Method Summary | |
---|---|
static ServiceStatus |
addActivities(java.util.List<ActivityItem> actList,
SQLiteDatabase writableDb)
Adds a list of activities to table. |
static long |
addChatTimelineEvent(ActivitiesTable.TimelineSummaryItem item,
boolean read,
SQLiteDatabase writableDb)
The method returns the ROW_ID i.e. the INTEGER PRIMARY KEY AUTOINCREMENT field value for the inserted row, i.e. |
static ServiceStatus |
addTimelineEvents(java.util.ArrayList<ActivitiesTable.TimelineSummaryItem> itemList,
boolean isCallLog,
SQLiteDatabase writableDb)
Adds a list of timeline events to the database. |
static void |
cleanupActivityTable(SQLiteDatabase writableDb)
Cleanup the Activity Table by deleting anything older than CLEANUP_MAX_AGE_DAYS, or preventing the total size from exceeding CLEANUP_MAX_QUANTITY. |
static void |
create(SQLiteDatabase writeableDb)
Create Activities Table. |
static ServiceStatus |
deleteActivities(java.lang.Integer flag,
SQLiteDatabase writableDb)
Deletes all activities from the table. |
static ServiceStatus |
deleteTimelineActivities(Context context,
ActivitiesTable.TimelineSummaryItem latestTimelineItem,
SQLiteDatabase writableDb,
SQLiteDatabase readableDb)
Deletes all the timeline activities for a particular contact from the table. |
static ServiceStatus |
deleteTimelineActivity(Context context,
ActivitiesTable.TimelineSummaryItem timelineItem,
SQLiteDatabase writableDb,
SQLiteDatabase readableDb)
Deletes specified timeline activity from the table. |
static ServiceStatus |
fetchActivitiesIds(java.util.List<java.lang.Long> actIdList,
java.lang.Long timeStamp,
SQLiteDatabase readableDb)
Returns a list of activity IDs already synced, in reverse chronological order Fetches from the given timestamp. |
static long |
fetchLatestStatusTimestampForContact(long localContactId,
SQLiteDatabase readableDb)
Returns the timestamp for the newest status event for a given server contact. |
private static java.lang.String |
fetchNameWhereClause(java.lang.Long localContactId,
java.lang.String name)
Returns a string which can be added to the where clause in an SQL query on the activities table, to filter the result for a specific contact or name. |
static ServiceStatus |
fetchNativeIdsFromLocalContactId(java.util.List<java.lang.Integer> nativeItemIdList,
long localContactId,
SQLiteDatabase readableDb)
|
static Cursor |
fetchStatusEventList(long timeStamp,
SQLiteDatabase readableDb)
Fetches a list of status items from the given time stamp. |
static ActivitiesTable.TimelineSummaryItem |
fetchTimeLineDataFromNativeThreadId(java.lang.String threadId,
SQLiteDatabase readableDb)
Returns the TimelineSummaryItem for the corresponding native thread Id. |
static Cursor |
fetchTimelineEventList(java.lang.Long minTimeStamp,
ActivitiesTable.TimelineNativeTypes[] nativeTypes,
SQLiteDatabase readableDb)
Fetches timeline events grouped by local contact ID, name or contact address. |
static Cursor |
fetchTimelineEventsForContact(java.lang.Long timeStamp,
java.lang.Long localContactId,
java.lang.String name,
ActivitiesTable.TimelineNativeTypes[] nativeTypes,
java.lang.String networkName,
SQLiteDatabase readableDb)
Fetches timeline events for a specific contact identified by local contact ID, name or address. |
private static ContentValues |
fillUpdateData(ActivityItem item,
java.lang.Integer contactIdx)
Provides a ContentValues object that can be used to update the table. |
private static boolean |
findNativeActivity(int nativeId,
int type,
SQLiteDatabase readableDb)
Checks if an activity exists in the database. |
private static java.lang.String |
getFullQueryList()
Fetches a comma separated list of table fields which can be used in an SQL SELECT statement as the query projection. |
static ActivitiesTable.TimelineSummaryItem |
getNewestOutgoingChatMessage(SQLiteDatabase readableDb)
Returns the newest outgoing chat message. |
static ActivitiesTable.TimelineSummaryItem |
getNewestUnreadChatMessage(SQLiteDatabase readableDb)
Returns the newest unread chat message. |
static int |
getNumberOfUnreadChatMessages(SQLiteDatabase readableDb)
Returns the number of unread chat messages. |
static int |
getNumberOfUnreadChatMessagesForContactAndNetwork(long localContactId,
java.lang.String network,
SQLiteDatabase readableDb)
Returns the number of unread chat messages for this contact besides this network. |
static int |
getNumberOfUnreadChatUsers(SQLiteDatabase readableDb)
Returns the number of users have currently have unread chat messages. |
static void |
getQueryData(Cursor cursor,
ActivityContact activityContact)
Fetches activities information from a cursor at the current position. |
static void |
getQueryData(Cursor cursor,
ActivityItem activityItem,
ActivityContact activityContact)
Fetches activities information from a cursor at the current position. |
static ActivitiesTable.TimelineSummaryItem |
getTimelineData(Cursor cursor)
Returns the timeline summary data from the current location of the given cursor. |
static int |
markChatTimelineEventsForContactAsRead(java.lang.Long localContactId,
java.lang.String networkName,
SQLiteDatabase writableDb)
Mark the chat timeline events for a given contact as read. |
static void |
removeChatTimelineExceptForContact(java.lang.Long localContactId,
SQLiteDatabase writeableDb)
Removes items from the chat timeline that are not for the given contact. |
private static int |
removeContactGroup(java.lang.Long localContactId,
java.lang.String name,
java.lang.Long newUpdateTime,
int flag,
ActivitiesTable.TimelineNativeTypes[] activityTypes,
SQLiteDatabase writableDb)
Clears the grouping of an activity in the database, if the given activity is newer. |
static void |
removeTimelineContactData(java.lang.Long localContactId,
SQLiteDatabase writeableDb)
Updates the timeline entries in the activities table to remove deleted contact info. |
static void |
updateMessageAsUnsent(long localContactId,
java.lang.String networkId,
SQLiteDatabase writableDb)
This method updates the chat message to a contact with indicated localContactId on the particular networkId as unsent. |
static void |
updateTimelineContactNameAndId(java.lang.String newName,
java.lang.Long localContactId,
SQLiteDatabase witeableDb)
Updates the timeline when a contact name is modified in the database. |
static void |
updateTimelineContactNameAndId(java.lang.String oldName,
java.lang.String newName,
java.lang.Long newLocalContactId,
java.lang.Long newContactId,
SQLiteDatabase witeableDb)
Updates timeline when a new contact is added to the People database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String TABLE_NAME
private static final java.lang.String TABLE_INDEX_NAME
private static final int CLEANUP_MAX_AGE_DAYS
private static final int CLEANUP_MAX_QUANTITY
private static final int NUMBER_OF_MS_IN_A_DAY
private static final int NUMBER_OF_MS_IN_A_SECOND
Constructor Detail |
---|
private ActivitiesTable()
Method Detail |
---|
public static void create(SQLiteDatabase writeableDb)
writeableDb
- A writable SQLite database.private static java.lang.String getFullQueryList()
getQueryData(Cursor, com.vodafone360.people.datatypes.ActivityItem, com.vodafone360.people.datatypes.ActivityContact)
methods can used to fetch data from the cursor.
public static void getQueryData(Cursor cursor, ActivityItem activityItem, ActivityContact activityContact)
getFullQueryList()
method should be used to make the query.
cursor
- The cursor returned by the queryactivityItem
- An empty activity object that will be filled with the
resultactivityContact
- An empty activity contact object that will be
filledpublic static void getQueryData(Cursor cursor, ActivityContact activityContact)
getFullQueryList()
method should be used to make the query.
cursor
- The cursor returned by the query.activityContact
- An empty activity contact object that will be
filledprivate static ContentValues fillUpdateData(ActivityItem item, java.lang.Integer contactIdx)
item
- The source activity itemcontactIdx
- The index of the contact to use for the update, or null
to exclude contact specific information.
public static Cursor fetchStatusEventList(long timeStamp, SQLiteDatabase readableDb)
timeStamp
- Time stamp in millisecondsreadableDb
- Readable SQLite database
getQueryData(Cursor, com.vodafone360.people.datatypes.ActivityItem, com.vodafone360.people.datatypes.ActivityContact)
methods to read
the data)public static ServiceStatus fetchActivitiesIds(java.util.List<java.lang.Long> actIdList, java.lang.Long timeStamp, SQLiteDatabase readableDb)
actIdList
- An empty list which will be filled with the resulttimeStamp
- The time stamp to start the fetchreadableDb
- Readable SQLite database
public static ServiceStatus addActivities(java.util.List<ActivityItem> actList, SQLiteDatabase writableDb)
removeContactGroup(Long, String, Long, int,
TimelineNativeTypes[], SQLiteDatabase)
for more information on how the grouping works.
actList
- The list of activitieswritableDb
- Writable SQLite database
public static ServiceStatus deleteActivities(java.lang.Integer flag, SQLiteDatabase writableDb)
flag
- Can be a bitmap of:
ActivityItem.TIMELINE_ITEM
- Timeline itemsActivityItem.STATUS_ITEM
- Status itemActivityItem.ALREADY_READ
- Items that have been
readwritableDb
- Writable SQLite database
public static ServiceStatus fetchNativeIdsFromLocalContactId(java.util.List<java.lang.Integer> nativeItemIdList, long localContactId, SQLiteDatabase readableDb)
public static ServiceStatus deleteTimelineActivity(Context context, ActivitiesTable.TimelineSummaryItem timelineItem, SQLiteDatabase writableDb, SQLiteDatabase readableDb)
Context
- timelineItem
- TimelineSummaryItem to be deletedwritableDb
- Writable SQLite databasereadableDb
- Readable SQLite database
public static ServiceStatus deleteTimelineActivities(Context context, ActivitiesTable.TimelineSummaryItem latestTimelineItem, SQLiteDatabase writableDb, SQLiteDatabase readableDb)
Context
- timelineItem
- TimelineSummaryItem to be deletedwritableDb
- Writable SQLite databasereadableDb
- Readable SQLite database
public static Cursor fetchTimelineEventList(java.lang.Long minTimeStamp, ActivitiesTable.TimelineNativeTypes[] nativeTypes, SQLiteDatabase readableDb)
minTimeStamp
- Only timeline events from this date will be returnednativeTypes
- A list of native types to filter the result, or null
to return all.readableDb
- Readable SQLite database
getTimelineData(Cursor)
method should be used for
reading the cursor.public static ServiceStatus addTimelineEvents(java.util.ArrayList<ActivitiesTable.TimelineSummaryItem> itemList, boolean isCallLog, SQLiteDatabase writableDb)
itemList
- List of timeline eventsisCallLog
- true to group all activities with call logs, false to
group with messagingwritableDb
- Writable SQLite database
public static long addChatTimelineEvent(ActivitiesTable.TimelineSummaryItem item, boolean read, SQLiteDatabase writableDb)
item
- TimelineSummaryItem.read
- - TRUE if the chat message is outgoing or gets into the
timeline history view for a contact with LocalContactId.writableDb
- Writable SQLite database.
private static int removeContactGroup(java.lang.Long localContactId, java.lang.String name, java.lang.Long newUpdateTime, int flag, ActivitiesTable.TimelineNativeTypes[] activityTypes, SQLiteDatabase writableDb)
fetchNameWhereClause(Long, String)
for more information.
localContactId
- Local contact Id or NULL if the activity is not
associated with a contact.name
- Name of contact or contact address (telephone number, email,
etc).newUpdateTime
- The time that the given activity has occurredflag
- Bitmap of types including:
ActivityItem.TIMELINE_ITEM
- Timeline itemsActivityItem.STATUS_ITEM
- Status itemActivityItem.ALREADY_READ
- Items that have been
readactivityTypes
- A list of native types to include in the grouping.
Currently, only two groups are supported (see above). If this
parameter is null the contact will be added to the
"all group", otherwise the contact is added to the native
group.writableDb
- Writable SQLite database
private static boolean findNativeActivity(int nativeId, int type, SQLiteDatabase readableDb)
nativeId
- The native ID which links the activity with the record in
the native table.type
- The native type (An ordinal from the #TimelineNativeTypes
enumeration)readableDb
- Readable SQLite database
private static java.lang.String fetchNameWhereClause(java.lang.Long localContactId, java.lang.String name)
localContactId
- The local contact ID, or null if the contact does
not exist in the People database.name
- A string containing the name, or a telephone number/email
identifying the contact.
public static ActivitiesTable.TimelineSummaryItem getTimelineData(Cursor cursor)
fetchTimelineEventList(Long, TimelineNativeTypes[],
SQLiteDatabase)
or
#fetchTimelineEventsForContact(Long, Long, String,
TimelineNativeTypes[], SQLiteDatabase)
.
cursor
- Cursor in the required position.
public static Cursor fetchTimelineEventsForContact(java.lang.Long timeStamp, java.lang.Long localContactId, java.lang.String name, ActivitiesTable.TimelineNativeTypes[] nativeTypes, java.lang.String networkName, SQLiteDatabase readableDb)
timeStamp
- Only events from this time will be returnedlocalContactId
- The local contact ID if the contact is in the
People database, or null.name
- The name or address of the contact (required if local contact
ID is NULL).nativeTypes
- A list of required native types to filter the result,
or null to return all timeline events for the contact.readableDb
- Readable SQLite databasenetworkName
- The name of the network the contacts belongs to
(required in order to provide appropriate chat messages
filtering) If the parameter is null messages from all networks
will be returned. The values are the
SocialNetwork.VODAFONE.toString(),
SocialNetwork.GOOGLE.toString(), or
SocialNetwork.MICROSOFT.toString() results.
getTimelineData(Cursor)
.public static int markChatTimelineEventsForContactAsRead(java.lang.Long localContactId, java.lang.String networkName, SQLiteDatabase writableDb)
localContactId
- Local contact ID.networkName
- Name of the SNS.writableDb
- Writable SQLite reference.
public static long fetchLatestStatusTimestampForContact(long localContactId, SQLiteDatabase readableDb)
local
- contact id Server contact IDreadableDb
- Readable SQLite database
public static void updateTimelineContactNameAndId(java.lang.String oldName, java.lang.String newName, java.lang.Long newLocalContactId, java.lang.Long newContactId, SQLiteDatabase witeableDb)
oldName
- The telephone number (since is the name of an activity
that is not associated with a contact)newName
- The new namenewLocalContactId
- The local Contact Id for the added contact.newContactId
- The server Contact Id for the added contact (or null
if the contact has not yet been synced).witeableDb
- Writable SQLite databasepublic static void updateTimelineContactNameAndId(java.lang.String newName, java.lang.Long localContactId, SQLiteDatabase witeableDb)
newName
- The new name.localContactId
- Local contact Id which was modified.witeableDb
- Writable SQLite databasepublic static void removeTimelineContactData(java.lang.Long localContactId, SQLiteDatabase writeableDb)
localContactId
- - the contact id that has been deletedwriteableDb
- - reference to the databasepublic static void removeChatTimelineExceptForContact(java.lang.Long localContactId, SQLiteDatabase writeableDb)
localContactId
- Given contact ID.writeableDb
- Writable SQLite database.public static int getNumberOfUnreadChatUsers(SQLiteDatabase readableDb)
readableDb
- Reference to a readable database.
public static int getNumberOfUnreadChatMessages(SQLiteDatabase readableDb)
readableDb
- Reference to a readable database.
public static int getNumberOfUnreadChatMessagesForContactAndNetwork(long localContactId, java.lang.String network, SQLiteDatabase readableDb)
localContactId
- Given contact ID.network
- SNS name.readableDb
- Reference to a readable database.
public static ActivitiesTable.TimelineSummaryItem getNewestUnreadChatMessage(SQLiteDatabase readableDb)
readableDb
- Reference to a readable database.
public static ActivitiesTable.TimelineSummaryItem getNewestOutgoingChatMessage(SQLiteDatabase readableDb)
readableDb
- Reference to a readable database.
public static void updateMessageAsUnsent(long localContactId, java.lang.String networkId, SQLiteDatabase writableDb)
localContactId
- long - the localContactId of the recipientnetworkId
- String - the network id, @see SocialNetworkwritableDb
- SQLiteDatabase - databasepublic static void cleanupActivityTable(SQLiteDatabase writableDb)
writableDb
- Reference to a writable SQLite Database.public static ActivitiesTable.TimelineSummaryItem fetchTimeLineDataFromNativeThreadId(java.lang.String threadId, SQLiteDatabase readableDb)
threadId
- native thread idreadableDb
- Readable SQLite database
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc