use of com.vodafone360.people.service.agent.UiAgent in project 360-Engine-for-Android by 360.
the class PresenceEngine method updatePresenceDatabaseNextPage.
/**
* This API makes the presence updates in pages of 10 with a timeout
* after each page. The HandlerAgent is notified after every 10 pages.
*/
private synchronized void updatePresenceDatabaseNextPage() {
UiAgent uiAgent = mEventCallback.getUiAgent();
if (mUsers == null) {
mState = IDLE;
return;
}
int listSize = mUsers.size();
int start = 0;
int end = UPDATE_PRESENCE_PAGE_SIZE;
if (listSize == 0) {
mState = IDLE;
mUsers = null;
notifyUiAgentOfResponse();
return;
} else if (listSize < end) {
end = listSize;
}
List<User> userSubset = mUsers.subList(start, end);
if ((userSubset != null)) {
long idListeningTo = UiAgent.ALL_USERS;
if (uiAgent != null) {
idListeningTo = uiAgent.getLocalContactId();
}
boolean updateUI = PresenceDbUtils.updateDatabase(userSubset, idListeningTo, mDbHelper);
userSubset.clear();
// Send the update notification to UI for every UPDATE_PRESENCE_PAGE_SIZE*NOTIFY_AGENT_PAGE_INTERVAL updates.
if (updateUI) {
if (mUsers.size() == 0 || NOTIFY_AGENT_PAGE_INTERVAL == mIterations) {
if (uiAgent != null) {
uiAgent.updatePresence(idListeningTo);
}
mIterations = 0;
} else {
mIterations++;
}
}
this.setTimeout(UPDATE_PRESENCE_TIMEOUT_MILLS);
}
}
use of com.vodafone360.people.service.agent.UiAgent in project 360-Engine-for-Android by 360.
the class IdentityEngine method pushIdentitiesToUi.
/**
* Pushes the identities retrieved by get my identities or by get available identities
* to the ui.
*
* @param request The request type: either get my identities, or get available identities.
*/
private void pushIdentitiesToUi(ServiceUiRequest request) {
String requestKey = null;
ArrayList<Identity> idBundle = null;
if (request == ServiceUiRequest.GET_AVAILABLE_IDENTITIES) {
requestKey = KEY_AVAILABLE_IDS;
synchronized (mAvailableIdentityList) {
// provide a shallow copy
idBundle = new ArrayList<Identity>(mAvailableIdentityList);
}
} else {
requestKey = KEY_MY_IDS;
synchronized (mMyIdentityList) {
// provide a shallow copy
idBundle = new ArrayList<Identity>(mMyIdentityList);
}
}
// send update to 3rd party identities ui if it is up
Bundle b = new Bundle();
b.putParcelableArrayList(requestKey, idBundle);
UiAgent uiAgent = mEventCallback.getUiAgent();
if (uiAgent != null && uiAgent.isSubscribed()) {
uiAgent.sendUnsolicitedUiEvent(request, b);
}
// end: send update to 3rd party identities ui if it is up
}
use of com.vodafone360.people.service.agent.UiAgent in project 360-Engine-for-Android by 360.
the class RemoteServiceTest method testGetServiceInterface.
/**
* Test getServiceInterface() from RemoteService.
*
* @throws Exception Issue setting up the service.
*/
@MediumTest
public final void testGetServiceInterface() throws Exception {
/**
* Setup test preconditions (i.e. startService). *
*/
startService(new Intent(getContext(), RemoteService.class));
/**
* Perform test (i.e. getServiceInterface). *
*/
IPeopleService mPeopleService = mApplication.getServiceInterface();
/**
* Test if mPeopleService is correctly initialised. *
*/
assertNotNull("IPeopleService should not be NULL", mPeopleService);
IWorkerThreadControl workerThreadControl = (IWorkerThreadControl) FrameworkUtils.get(mPeopleService, "mWorkerThreadControl");
assertNotNull("Expecting mWorkerThreadControl not to be NULL", workerThreadControl);
RemoteService service = (RemoteService) FrameworkUtils.get(mPeopleService, "mService");
assertNotNull("Expecting mService not to be NULL", service);
UiAgent handlerAgent = (UiAgent) FrameworkUtils.get(mPeopleService, "mHandlerAgent");
assertNotNull("Expecting mHandlerAgent not to be NULL", handlerAgent);
ApplicationCache applicationCache = (ApplicationCache) FrameworkUtils.get(mPeopleService, "mApplicationCache");
assertNotNull("Expecting mApplicationCache not to be NULL", applicationCache);
}
use of com.vodafone360.people.service.agent.UiAgent in project 360-Engine-for-Android by 360.
the class PresenceEngine method updateChatDatabase.
/**
* Updates the database with the given ChatMessage and Type.
*
* @param message ChatMessage.
* @param type TimelineSummaryItem.Type.
*/
private void updateChatDatabase(ChatMessage message, TimelineSummaryItem.Type type) {
ChatDbUtils.convertUserIds(message, mDbHelper);
LogUtils.logD("PresenceEngine.updateChatDatabase() with [" + type.name() + "] message");
if (message.getLocalContactId() == null || message.getLocalContactId() < 0) {
LogUtils.logE("PresenceEngine.updateChatDatabase() " + "WILL NOT UPDATE THE DB! - INVALID localContactId = " + message.getLocalContactId());
return;
}
/**
* We mark all incoming messages as unread. *
*/
ChatDbUtils.saveChatMessageAsATimeline(message, type, mDbHelper);
UiAgent uiAgent = mEventCallback.getUiAgent();
if (uiAgent != null && (message.getLocalContactId() != -1)) {
uiAgent.updateChat(message.getLocalContactId(), true, message.getNetworkId());
}
}
Aggregations