Package com.batch.android.inbox
Class InboxDatasource
- java.lang.Object
-
- com.batch.android.inbox.InboxDatasource
-
public final class InboxDatasource extends java.lang.ObjectInbox datasource. Wraps SQLite queries (DAO).
-
-
Constructor Summary
Constructors Constructor Description InboxDatasource(android.content.Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancleanDatabase()Remove notifications older than 90 days Also remove related row in other tablesvoidclose()Close the datasource.booleandeleteNotifications(java.util.List<java.lang.String> notificationIds)Delete notification by IDjava.util.List<InboxCandidateNotificationInternal>getCandidateNotifications(java.lang.String cursor, int limit, long fetcherId)Look in database for cached notificationsprotected android.database.sqlite.SQLiteDatabasegetDatabase()Get database (for test purpose)longgetFetcherID(com.batch.android.inbox.FetcherType type, java.lang.String identifier)Try to get the fetcher ID from the SQLite Create and insert it if it doesn't existjava.util.List<InboxNotificationContentInternal>getNotifications(java.util.List<java.lang.String> notificationIds, long fetcherId)protected longgetNotificationTime(java.lang.String notificationId)protected booleaninsert(InboxNotificationContentInternal notification, long fetcherId)Insert a notification to SQLite.booleaninsertResponse(InboxWebserviceResponse response, long fetcherId)Add a response's notification to the databaseintmarkAllAsRead(long time, long fetcherId)Mark all notification received before a specified time as readvoidmarkNotificationAsDeleted(java.lang.String notificationID)Mark a notification as deleted locallyvoidmarkNotificationAsRead(java.lang.String notificationID)Mark a notification as readjava.lang.StringupdateNotification(JSONObject notification, long fetcherId)Read the notification object and update the row in database We update different values depending on what the server actually sentvoidwipeData()Clear all content
-
-
-
Method Detail
-
wipeData
public void wipeData()
Clear all content
-
close
public void close()
Close the datasource. You should not make any other call to this datasource once this has been called.
-
getDatabase
protected android.database.sqlite.SQLiteDatabase getDatabase()
Get database (for test purpose)- Returns:
-
getNotifications
public java.util.List<InboxNotificationContentInternal> getNotifications(java.util.List<java.lang.String> notificationIds, long fetcherId)
-
getNotificationTime
protected long getNotificationTime(java.lang.String notificationId)
-
getFetcherID
public long getFetcherID(com.batch.android.inbox.FetcherType type, java.lang.String identifier)Try to get the fetcher ID from the SQLite Create and insert it if it doesn't exist- Parameters:
type-identifier-
-
getCandidateNotifications
public java.util.List<InboxCandidateNotificationInternal> getCandidateNotifications(@Nullable java.lang.String cursor, int limit, long fetcherId)
Look in database for cached notifications- Parameters:
cursor-fetcherId-- Returns:
-
insertResponse
public boolean insertResponse(InboxWebserviceResponse response, long fetcherId)
Add a response's notification to the database- Parameters:
response- response to addfetcherId-
-
insert
protected boolean insert(InboxNotificationContentInternal notification, long fetcherId)
Insert a notification to SQLite.- Parameters:
notification- Notification to insertfetcherId- Fetcher id- Returns:
- If the insert succeeded or not
-
updateNotification
public java.lang.String updateNotification(JSONObject notification, long fetcherId)
Read the notification object and update the row in database We update different values depending on what the server actually sent- Parameters:
notification-fetcherId-- Returns:
-
markAllAsRead
public int markAllAsRead(long time, long fetcherId)Mark all notification received before a specified time as read- Parameters:
time-fetcherId-- Returns:
-
markNotificationAsRead
public void markNotificationAsRead(java.lang.String notificationID)
Mark a notification as read- Parameters:
notificationID- the notification identifier
-
markNotificationAsDeleted
public void markNotificationAsDeleted(java.lang.String notificationID)
Mark a notification as deleted locally- Parameters:
notificationID- the notification identifier
-
deleteNotifications
public boolean deleteNotifications(java.util.List<java.lang.String> notificationIds)
Delete notification by ID- Parameters:
notificationIds- IDs of the notifications to delete- Returns:
- boolean
-
cleanDatabase
public boolean cleanDatabase()
Remove notifications older than 90 days Also remove related row in other tables
-
-