Search in sources :

Example 21 with Identity

use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.

the class IdentityEngine method getMyChattableIdentities.

/**
 * Takes all third party identities that have a chat capability set to true.
 *
 * @return A list of chattable 3rd party identities the user is signed in to. If the retrieval identities failed the returned list will be empty.
 */
public ArrayList<Identity> getMyChattableIdentities() {
    final ArrayList<Identity> chattableIdentities = new ArrayList<Identity>();
    final ArrayList<Identity> myIdentityList;
    final int identityListSize;
    synchronized (mMyIdentityList) {
        // make a shallow copy
        myIdentityList = new ArrayList<Identity>(mMyIdentityList);
    }
    identityListSize = myIdentityList.size();
    // list if it does
    for (int i = 0; i < identityListSize; i++) {
        Identity identity = myIdentityList.get(i);
        List<IdentityCapability> capabilities = identity.mCapabilities;
        if (null == capabilities) {
            // if the capabilties are null skip to next identity
            continue;
        }
        // run through capabilties and check for chat
        for (int j = 0; j < capabilities.size(); j++) {
            IdentityCapability capability = capabilities.get(j);
            if (null == capability) {
                // skip null capabilities
                continue;
            }
            if ((capability.mCapability == IdentityCapability.CapabilityID.chat) && (capability.mValue)) {
                chattableIdentities.add(identity);
                break;
            }
        }
    }
    return chattableIdentities;
}
Also used : ArrayList(java.util.ArrayList) Identity(com.vodafone360.people.datatypes.Identity) IdentityCapability(com.vodafone360.people.datatypes.IdentityCapability)

Example 22 with Identity

use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.

the class IdentityEngine method handleGetAvailableIdentitiesResponse.

/**
 * Handle Server response to request for available Identities. The response
 * should be a list of Identity items. The request is completed with
 * ServiceStatus.SUCCESS or ERROR_UNEXPECTED_RESPONSE if the data-type
 * retrieved are not Identity items.
 *
 * @param data List of BaseDataTypes generated from Server response.
 */
private void handleGetAvailableIdentitiesResponse(List<BaseDataType> data) {
    LogUtils.logD("IdentityEngine: handleServerGetAvailableIdentitiesResponse");
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.AVAILABLE_IDENTITY_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        synchronized (mAvailableIdentityList) {
            mAvailableIdentityList.clear();
            for (BaseDataType item : data) {
                Identity identity = (Identity) item;
                if (!identity.isIdentityFieldBlankorNull()) {
                    mAvailableIdentityList.add(identity);
                }
            }
        }
    }
    pushIdentitiesToUi(ServiceUiRequest.GET_AVAILABLE_IDENTITIES);
    LogUtils.logD("IdentityEngine: handleGetAvailableIdentitiesResponse complete request.");
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Identity(com.vodafone360.people.datatypes.Identity)

Aggregations

Identity (com.vodafone360.people.datatypes.Identity)17 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)7 ServiceStatus (com.vodafone360.people.service.ServiceStatus)6 ArrayList (java.util.ArrayList)6 Bundle (android.os.Bundle)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)4 Hashtable (java.util.Hashtable)4 Suppress (android.test.suitebuilder.annotation.Suppress)3 IdentityCapability (com.vodafone360.people.datatypes.IdentityCapability)3 ServerError (com.vodafone360.people.datatypes.ServerError)3 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)3 QueueManager (com.vodafone360.people.service.io.QueueManager)3 Request (com.vodafone360.people.service.io.Request)3 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)2 IOException (java.io.IOException)2 URL (java.net.URL)2 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)1