Back to project page uppidy-android-sdk.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...
If you think the Android project uppidy-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uppidy.android.sdk.api.impl; //from w ww. j av a2s.co m import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.codehaus.jackson.JsonNode; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import com.uppidy.android.sdk.api.ApiContactInfo; import com.uppidy.android.sdk.api.ApiProfile; import com.uppidy.android.sdk.api.UppidyApi; import com.uppidy.android.sdk.api.UserOperations; class UserTemplate extends AbstractUppidyOperations implements UserOperations { private final UppidyApi uppidyApi; public UserTemplate(UppidyApi uppidyApi, boolean isAuthorizedForUser) { super(isAuthorizedForUser); this.uppidyApi = uppidyApi; } public ApiProfile getUserProfile() { requireAuthorization(); return getUserProfile("me"); } public ApiProfile getUserProfile(String userId) { return uppidyApi.fetchObject(userId + "/profile", ApiProfile.class); } public byte[] getUserProfileImage(String imageType) { requireAuthorization(); return getUserProfileImage("me", imageType); } public byte[] getUserProfileImage(String userId, String imageType) { return uppidyApi.fetchImage(userId, "picture", imageType); } public List<String> getUserPermissions() { JsonNode responseNode = uppidyApi.fetchObject("me/permissions", JsonNode.class); return deserializePermissionsNodeToList(responseNode); } public List<ApiContactInfo> search(String query) { requireAuthorization(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); queryParams.add("query", query); return uppidyApi.fetchConnections("search", "user", ApiContactInfo.class, queryParams); } private List<String> deserializePermissionsNodeToList(JsonNode jsonNode) { JsonNode dataNode = jsonNode.get("data"); List<String> permissions = new ArrayList<String>(); for (Iterator<JsonNode> elementIt = dataNode.getElements(); elementIt.hasNext(); ) { JsonNode permissionsElement = elementIt.next(); for (Iterator<String> fieldNamesIt = permissionsElement.getFieldNames(); fieldNamesIt.hasNext(); ) { permissions.add(fieldNamesIt.next()); } } return permissions; } }