use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class PresenceTable method getUserPresenceByLocalContactId.
/**
* This method returns user/me profile presence state.
*
* @param localContactId - me profile localContactId
* @param readableDatabase - the database to read from
* @return user/me profile presence state wrapped in "User" wrapper class,
* or NULL if the specified localContactId doesn't exist
* @throws SQLException if the database layer throws this exception.
* @throws NullPointerException if the passed in database instance is null.
* @return user - User object filled with presence information.
*/
public static User getUserPresenceByLocalContactId(long localContactId, SQLiteDatabase readableDatabase) throws SQLException, NullPointerException {
if (readableDatabase == null) {
throw new NullPointerException(DEFAULT_ERROR_MESSAGE);
}
User user = null;
if (localContactId < 0) {
LogUtils.logE("PresenceTable.getUserPresenceByLocalContactId(): " + "#localContactId# parameter is -1 ");
return user;
}
Cursor c = null;
try {
c = readableDatabase.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE " + Field.LOCAL_CONTACT_ID + "=" + localContactId, null);
ArrayList<NetworkPresence> networkPresence = new ArrayList<NetworkPresence>();
user = new User();
// i.e. 0
int onlineStatus = OnlineStatus.OFFLINE.ordinal();
while (c.moveToNext()) {
user.setLocalContactId(c.getLong(LOCAL_CONTACT_ID));
String userId = c.getString(USER_ID);
int networkId = c.getInt(NETWORK_ID);
int statusId = c.getInt(NETWORK_STATUS);
if (statusId > onlineStatus) {
onlineStatus = statusId;
}
networkPresence.add(new NetworkPresence(userId, networkId, statusId));
}
if (!networkPresence.isEmpty()) {
user.setOverallOnline(onlineStatus);
user.setPayload(networkPresence);
}
} finally {
CloseUtils.close(c);
c = null;
}
return user;
}
use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class PresenceTable method getUserPresence.
/**
* This method fills the provided user object with presence information.
*
* @param user User - the user with a localContactId != -1
* @param readableDatabase - the database to read from
* @return user/me profile presence state wrapped in "User" wrapper class,
* or NULL if the specified localContactId doesn't exist
* @throws SQLException if the database layer throws this exception.
* @throws NullPointerException if the passed in database instance is null.
*/
public static void getUserPresence(User user, SQLiteDatabase readableDatabase) throws SQLException, NullPointerException {
if (readableDatabase == null) {
throw new NullPointerException(DEFAULT_ERROR_MESSAGE);
}
if (user.getLocalContactId() < 0) {
LogUtils.logE("PresenceTable.getUserPresenceByLocalContactId(): " + "#localContactId# parameter is -1 ");
return;
}
Cursor c = null;
try {
c = readableDatabase.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE " + Field.LOCAL_CONTACT_ID + "=" + user.getLocalContactId(), null);
if (c != null) {
// i.e. 0
int onlineStatus = OnlineStatus.OFFLINE.ordinal();
ArrayList<NetworkPresence> payload = user.getPayload();
payload.clear();
while (c.moveToNext()) {
String userId = c.getString(USER_ID);
int networkId = c.getInt(NETWORK_ID);
int statusId = c.getInt(NETWORK_STATUS);
if (statusId > onlineStatus) {
onlineStatus = statusId;
}
payload.add(new NetworkPresence(userId, networkId, statusId));
}
user.setOverallOnline(onlineStatus);
}
} finally {
CloseUtils.close(c);
c = null;
}
}
use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class ContactSyncEngine method setFirstTimeNativeSyncComplete.
/**
* Helper function to update the database when the state of the
* {@link #mFirstTimeNativeSyncComplete} flag changes.
*
* @param value New value to the flag. True indicates that the native fetch
* part of the first time sync has been completed. The flag is
* never set to false again by the engine, it will be only set to
* false when a remove user data is done (and the database is
* deleted).
* @return SUCCESS or a suitable error code if the database could not be
* updated.
*/
private ServiceStatus setFirstTimeNativeSyncComplete(boolean value) {
if (mFirstTimeSyncComplete == value) {
return ServiceStatus.SUCCESS;
}
PersistSettings setting = new PersistSettings();
setting.putFirstTimeNativeSyncComplete(value);
ServiceStatus status = mDb.setOption(setting);
if (ServiceStatus.SUCCESS == status) {
mFirstTimeNativeSyncComplete = value;
}
return status;
}
Aggregations