本文整理汇总了Java中com.facebook.model.GraphObjectList类的典型用法代码示例。如果您正苦于以下问题:Java GraphObjectList类的具体用法?Java GraphObjectList怎么用?Java GraphObjectList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphObjectList类属于com.facebook.model包,在下文中一共展示了GraphObjectList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Response
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObject graphObject, GraphObjectList<GraphObject> graphObjects, boolean isFromCache, FacebookRequestError error) {
this.request = request;
this.connection = connection;
this.rawResponse = rawResponse;
this.graphObject = graphObject;
this.graphObjectList = graphObjects;
this.isFromCache = isFromCache;
this.error = error;
}
示例2: createResponseFromObject
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object,
boolean isFromCache, Object originalResult) throws JSONException {
if (object instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) object;
FacebookRequestError error =
FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection);
if (error != null) {
if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) {
Session session = request.getSession();
if (session != null) {
session.closeAndClearTokenInformation();
}
}
return new Response(request, connection, error);
}
Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY);
if (body instanceof JSONObject) {
GraphObject graphObject = GraphObject.Factory.create((JSONObject) body);
return new Response(request, connection, body.toString(), graphObject, isFromCache);
} else if (body instanceof JSONArray) {
GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList(
(JSONArray) body, GraphObject.class);
return new Response(request, connection, body.toString(), graphObjectList, isFromCache);
}
// We didn't get a body we understand how to handle, so pretend we got nothing.
object = JSONObject.NULL;
}
if (object == JSONObject.NULL) {
return new Response(request, connection, object.toString(), (GraphObject)null, isFromCache);
} else {
throw new FacebookException("Got unexpected object type in response, class: "
+ object.getClass().getSimpleName());
}
}
示例3: addResults
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private void addResults(Response response) {
SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() :
new SimpleGraphObjectCursor<T>(cursor);
PagedResults result = response.getGraphObjectAs(PagedResults.class);
boolean fromCache = response.getIsFromCache();
GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass);
boolean haveData = data.size() > 0;
if (haveData) {
nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT);
cursorToModify.addGraphObjects(data, fromCache);
cursorToModify.setMoreObjectsAvailable(true);
}
if (!haveData) {
cursorToModify.setMoreObjectsAvailable(false);
cursorToModify.setFromCache(fromCache);
nextRequest = null;
}
// Once we get any set of results NOT from the cache, stop trying to get any future ones
// from it.
if (!fromCache) {
skipRoundtripIfCached = false;
}
deliverResult(cursorToModify);
}
示例4: Response
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
Response(Request request, HttpURLConnection connection, GraphObjectList<GraphObject> graphObjects,
boolean isFromCache) {
this.request = request;
this.connection = connection;
this.graphObject = null;
this.graphObjectList = graphObjects;
this.isFromCache = isFromCache;
this.error = null;
}
示例5: createResponseFromObject
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object,
boolean isFromCache, Object originalResult) throws JSONException {
if (object instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) object;
FacebookRequestError error =
FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection);
if (error != null) {
if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) {
Session session = request.getSession();
if (session != null) {
session.closeAndClearTokenInformation();
}
}
return new Response(request, connection, error);
}
Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY);
if (body instanceof JSONObject) {
GraphObject graphObject = GraphObject.Factory.create((JSONObject) body);
return new Response(request, connection, graphObject, isFromCache);
} else if (body instanceof JSONArray) {
GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList(
(JSONArray) body, GraphObject.class);
return new Response(request, connection, graphObjectList, isFromCache);
}
// We didn't get a body we understand how to handle, so pretend we got nothing.
object = JSONObject.NULL;
}
if (object == JSONObject.NULL) {
return new Response(request, connection, (GraphObject)null, isFromCache);
} else {
throw new FacebookException("Got unexpected object type in response, class: "
+ object.getClass().getSimpleName());
}
}
示例6: typedListFromResponse
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private static <T extends GraphObject> List<T> typedListFromResponse(Response response, Class<T> clazz) {
GraphMultiResult multiResult = response.getGraphObjectAs(GraphMultiResult.class);
if (multiResult == null) {
return null;
}
GraphObjectList<GraphObject> data = multiResult.getData();
if (data == null) {
return null;
}
return data.castToListOf(clazz);
}
示例7: updateObjectAttachmentUrls
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
final OpenGraphObject object;
try {
object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
if (object == null) {
throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
}
} catch (FacebookGraphObjectException exception) {
throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
}
if (!object.getCreateObject()) {
throw new IllegalArgumentException(
"The Open Graph object in '" + objectProperty + "' is not marked for creation");
}
GraphObjectList<GraphObject> attachments = object.getImage();
if (attachments == null) {
attachments = GraphObject.Factory.createList(GraphObject.class);
}
for (String url : attachmentUrls) {
GraphObject graphObject = GraphObject.Factory.create();
graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
if (isUserGenerated) {
graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
}
attachments.add(graphObject);
}
object.setImage(attachments);
}
示例8: addResults
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private void addResults(Response response) {
SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() :
new SimpleGraphObjectCursor<T>(cursor);
PagedResults result = response.getGraphObjectAs(PagedResults.class);
boolean fromCache = response.getIsFromCache();
GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass);
boolean haveData = data.size() > 0;
if (haveData) {
nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT);
cursorToModify.addGraphObjects(data, fromCache);
if (nextRequest != null) {
cursorToModify.setMoreObjectsAvailable(true);
} else {
cursorToModify.setMoreObjectsAvailable(false);
}
}
if (!haveData) {
cursorToModify.setMoreObjectsAvailable(false);
cursorToModify.setFromCache(fromCache);
nextRequest = null;
}
// Once we get any set of results NOT from the cache, stop trying to get any future ones
// from it.
if (!fromCache) {
skipRoundtripIfCached = false;
}
deliverResult(cursorToModify);
}
示例9: createResponseFromObject
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private static Response createResponseFromObject(Request paramRequest, HttpURLConnection paramHttpURLConnection, Object paramObject1, boolean paramBoolean, Object paramObject2)
{
if ((paramObject1 instanceof JSONObject))
{
JSONObject localJSONObject = (JSONObject)paramObject1;
FacebookRequestError localFacebookRequestError = FacebookRequestError.checkResponseAndCreateError(localJSONObject, paramObject2, paramHttpURLConnection);
if (localFacebookRequestError != null)
{
if (localFacebookRequestError.getErrorCode() == 190)
{
Session localSession = paramRequest.getSession();
if (localSession != null)
localSession.closeAndClearTokenInformation();
}
return new Response(paramRequest, paramHttpURLConnection, localFacebookRequestError);
}
Object localObject = Utility.getStringPropertyAsJSON(localJSONObject, "body", "FACEBOOK_NON_JSON_RESULT");
if ((localObject instanceof JSONObject))
{
GraphObject localGraphObject = GraphObject.Factory.create((JSONObject)localObject);
return new Response(paramRequest, paramHttpURLConnection, localObject.toString(), localGraphObject, paramBoolean);
}
if ((localObject instanceof JSONArray))
{
GraphObjectList localGraphObjectList = GraphObject.Factory.createList((JSONArray)localObject, GraphObject.class);
return new Response(paramRequest, paramHttpURLConnection, localObject.toString(), localGraphObjectList, paramBoolean);
}
paramObject1 = JSONObject.NULL;
}
if (paramObject1 == JSONObject.NULL)
return new Response(paramRequest, paramHttpURLConnection, paramObject1.toString(), null, paramBoolean);
throw new FacebookException("Got unexpected object type in response, class: " + paramObject1.getClass().getSimpleName());
}
示例10: addResults
import com.facebook.model.GraphObjectList; //导入依赖的package包/类
private void addResults(Response paramResponse)
{
SimpleGraphObjectCursor localSimpleGraphObjectCursor;
if ((this.cursor == null) || (!this.appendResults))
localSimpleGraphObjectCursor = new SimpleGraphObjectCursor();
else
localSimpleGraphObjectCursor = new SimpleGraphObjectCursor(this.cursor);
PagedResults localPagedResults = (PagedResults)paramResponse.getGraphObjectAs(PagedResults.class);
boolean bool = paramResponse.getIsFromCache();
GraphObjectList localGraphObjectList = localPagedResults.getData().castToListOf(this.graphObjectClass);
int i;
if (localGraphObjectList.size() > 0)
i = 1;
else
i = 0;
int j = i;
if (i != 0)
{
this.nextRequest = paramResponse.getRequestForPagedResults(Response.PagingDirection.NEXT);
localSimpleGraphObjectCursor.addGraphObjects(localGraphObjectList, bool);
localSimpleGraphObjectCursor.setMoreObjectsAvailable(true);
}
if (j == 0)
{
localSimpleGraphObjectCursor.setMoreObjectsAvailable(false);
localSimpleGraphObjectCursor.setFromCache(bool);
this.nextRequest = null;
}
if (!bool)
this.skipRoundtripIfCached = false;
deliverResult(localSimpleGraphObjectCursor);
}