use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.
the class EngineManager method createSyncMeEngine.
/**
* Create instance of SyncMeEngine.
*/
private synchronized void createSyncMeEngine() {
final MainApplication app = (MainApplication) mService.getApplication();
mSyncMeEngine = new SyncMeEngine(mService, mUiEventCallback, app.getDatabase());
addEngine(mSyncMeEngine);
}
use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processPushEvent.
/**
* This method process the "pc" push event.
* @param resp Response - server response normally containing a "pc"
* PushEvent data type
* @return boolean - TRUE if a push event was found in the response
*/
private boolean processPushEvent(final DecodedResponse resp) {
if (resp.mDataTypes == null || resp.mDataTypes.size() == 0) {
return false;
}
BaseDataType dataType = resp.mDataTypes.get(0);
if ((dataType == null) || dataType.getType() != BaseDataType.PUSH_EVENT_DATA_TYPE) {
return false;
}
PushEvent pushEvent = (PushEvent) dataType;
LogUtils.logV("SyncMeEngine processPushMessage():" + pushEvent.mMessageType);
switch(pushEvent.mMessageType) {
case PROFILE_CHANGE:
addGetMeProfileContactRequest();
break;
default:
break;
}
return true;
}
use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processGetMyChangesResponse.
/**
* Processes the response from a GetMyChanges request. The me profile data
* will be merged in the local database if the response is successful.
* Otherwise the processor will complete with a suitable error.
* @param resp Response from server.
*/
private void processGetMyChangesResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeEngine processGetMyChangesResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges changes = (ContactChanges) resp.mDataTypes.get(0);
Contact currentMeProfile = new Contact();
status = SyncMeDbUtils.fetchMeProfile(mDbHelper, currentMeProfile);
switch(status) {
case SUCCESS:
SyncMeDbUtils.updateMeProfile(mDbHelper, currentMeProfile, changes.mUserProfile);
break;
case // this is the 1st time sync
ERROR_NOT_FOUND:
currentMeProfile.copy(changes.mUserProfile);
status = SyncMeDbUtils.setMeProfile(mDbHelper, currentMeProfile);
setFirstTimeMeSyncComplete(true);
break;
default:
completeUiRequest(status);
return;
}
final String url = fetchThumbnailUrlFromProfile(changes.mUserProfile);
if (url != null) {
downloadMeProfileThumbnail(url, currentMeProfile.localContactID);
} else {
completeUiRequest(status);
}
storeMeProfileRevisionInDb(changes.mCurrentServerVersion);
} else {
completeUiRequest(status);
}
}
use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.
the class SyncMeEngineTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// delete the database
getInstrumentation().getTargetContext().deleteDatabase(HelperClasses.getDatabaseName());
// create an application instance
mApplication = (MainApplication) Instrumentation.newApplication(MainApplication.class, getInstrumentation().getTargetContext());
mApplication.onCreate();
mEngineTester = new EngineTestFramework(this);
mEngine = new SyncMeEngine(getInstrumentation().getTargetContext(), mEngineTester, mApplication.getDatabase());
mEngineTester.setEngine(mEngine);
Log.i(LOG_TAG, "**** setUp() end ****");
}
Aggregations