本文整理汇总了Java中com.facebook.model.GraphObject类的典型用法代码示例。如果您正苦于以下问题:Java GraphObject类的具体用法?Java GraphObject怎么用?Java GraphObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphObject类属于com.facebook.model包,在下文中一共展示了GraphObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryAppSettings
import com.facebook.model.GraphObject; //导入依赖的package包/类
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {
// Cache the last app checked results.
if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
return fetchedAppSettings.get(applicationId);
}
Bundle appSettingsParams = new Bundle();
appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));
Request request = Request.newGraphPathRequest(null, applicationId, null);
request.setParameters(appSettingsParams);
GraphObject supportResponse = request.executeAndWait().getGraphObject();
FetchedAppSettings result = new FetchedAppSettings(
safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING),
safeGetStringFromResponse(supportResponse, NUX_CONTENT),
safeGetBooleanFromResponse(supportResponse, NUX_ENABLED)
);
fetchedAppSettings.put(applicationId, result);
return result;
}
示例2: setAppEventAttributionParameters
import com.facebook.model.GraphObject; //导入依赖的package包/类
public static void setAppEventAttributionParameters(GraphObject params,
AttributionIdentifiers attributionIdentifiers, String hashedDeviceAndAppId, boolean limitEventUsage) {
// Send attributionID if it exists, otherwise send a hashed device+appid specific value as the advertiser_id.
if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
params.setProperty("attribution", attributionIdentifiers.getAttributionId());
}
if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
} else if (hashedDeviceAndAppId != null) {
params.setProperty("advertiser_id", hashedDeviceAndAppId);
}
params.setProperty("application_tracking_enabled", !limitEventUsage);
}
示例3: getPictureUriOfGraphObject
import com.facebook.model.GraphObject; //导入依赖的package包/类
protected URI getPictureUriOfGraphObject(T graphObject) {
String uri = null;
Object o = graphObject.getProperty(PICTURE);
if (o instanceof String) {
uri = (String) o;
} else if (o instanceof JSONObject) {
ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
ItemPictureData data = itemPicture.getData();
if (data != null) {
uri = data.getUrl();
}
}
if (uri != null) {
try {
return new URI(uri);
} catch (URISyntaxException e) {
}
}
return null;
}
示例4: compareGraphObjects
import com.facebook.model.GraphObject; //导入依赖的package包/类
private static int compareGraphObjects(GraphObject a, GraphObject b, Collection<String> sortFields,
Collator collator) {
for (String sortField : sortFields) {
String sa = (String) a.getProperty(sortField);
String sb = (String) b.getProperty(sortField);
if (sa != null && sb != null) {
int result = collator.compare(sa, sb);
if (result != 0) {
return result;
}
} else if (!(sa == null && sb == null)) {
return (sa == null) ? -1 : 1;
}
}
return 0;
}
示例5: queryAppSettings
import com.facebook.model.GraphObject; //导入依赖的package包/类
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {
// Cache the last app checked results.
if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
return fetchedAppSettings.get(applicationId);
}
Bundle appSettingsParams = new Bundle();
appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));
Request request = Request.newGraphPathRequest(null, applicationId, null);
request.setParameters(appSettingsParams);
GraphObject supportResponse = request.executeAndWait().getGraphObject();
FetchedAppSettings result = new FetchedAppSettings(
safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING));
fetchedAppSettings.put(applicationId, result);
return result;
}
示例6: deleteTestAccount
import com.facebook.model.GraphObject; //导入依赖的package包/类
private void deleteTestAccount(String testAccountId, String appAccessToken) {
Bundle parameters = new Bundle();
parameters.putString("access_token", appAccessToken);
Request request = new Request(null, testAccountId, parameters, HttpMethod.DELETE);
Response response = request.executeAndWait();
FacebookRequestError error = response.getError();
GraphObject graphObject = response.getGraphObject();
if (error != null) {
Log.w(LOG_TAG, String.format("Could not delete test account %s: %s", testAccountId, error.getException().toString()));
} else if (graphObject.getProperty(Response.NON_JSON_RESPONSE_PROPERTY) == (Boolean) false
|| graphObject.getProperty(Response.SUCCESS_KEY) == (Boolean) false) {
Log.w(LOG_TAG, String.format("Could not delete test account %s: unknown reason", testAccountId));
}
}
示例7: setAppEventAttributionParameters
import com.facebook.model.GraphObject; //导入依赖的package包/类
public static void setAppEventAttributionParameters(GraphObject params,
AttributionIdentifiers attributionIdentifiers, String hashedDeviceAndAppId, boolean limitEventUsage) {
// Send attributionID if it exists, otherwise send a hashed device+appid specific value as the advertiser_id.
if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
params.setProperty("attribution", attributionIdentifiers.getAttributionId());
}
if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
} else if (hashedDeviceAndAppId != null) {
params.setProperty("advertiser_id", hashedDeviceAndAppId);
}
params.setProperty("application_tracking_enabled", !limitEventUsage);
}
示例8: setAppEventAttributionParameters
import com.facebook.model.GraphObject; //导入依赖的package包/类
public static void setAppEventAttributionParameters(
GraphObject params,
AttributionIdentifiers attributionIdentifiers,
String anonymousAppDeviceGUID,
boolean limitEventUsage) {
if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
params.setProperty("attribution", attributionIdentifiers.getAttributionId());
}
if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
}
params.setProperty("anon_id", anonymousAppDeviceGUID);
params.setProperty("application_tracking_enabled", !limitEventUsage);
}
示例9: setAppEventExtendedDeviceInfoParameters
import com.facebook.model.GraphObject; //导入依赖的package包/类
public static void setAppEventExtendedDeviceInfoParameters(GraphObject params, Context appContext) {
JSONArray extraInfoArray = new JSONArray();
extraInfoArray.put(EXTRA_APP_EVENTS_INFO_FORMAT_VERSION);
// Application Manifest info:
String pkgName = appContext.getPackageName();
int versionCode = -1;
String versionName = "";
try {
PackageInfo pi = appContext.getPackageManager().getPackageInfo(pkgName, 0);
versionCode = pi.versionCode;
versionName = pi.versionName;
} catch (PackageManager.NameNotFoundException e) {
// Swallow
}
// Application Manifest info:
extraInfoArray.put(pkgName);
extraInfoArray.put(versionCode);
extraInfoArray.put(versionName);
params.setProperty("extinfo", extraInfoArray.toString());
}
示例10: showPublishResult
import com.facebook.model.GraphObject; //导入依赖的package包/类
private void showPublishResult(String message, GraphObject result, FacebookRequestError error) {
String title = null;
String alertMessage = null;
if (error == null) {
title = getString(R.string.success);
alertMessage = getString(R.string.successfully_posted_post, message);
} else {
title = getString(R.string.error);
alertMessage = error.getErrorMessage();
}
new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(alertMessage)
.setPositiveButton(R.string.ok, null)
.show();
}
示例11: deleteTestAccount
import com.facebook.model.GraphObject; //导入依赖的package包/类
private void deleteTestAccount(String testAccountId, String appAccessToken) {
Bundle parameters = new Bundle();
parameters.putString("access_token", appAccessToken);
Request request = new Request(null, testAccountId, parameters, HttpMethod.DELETE);
Response response = request.executeAndWait();
FacebookRequestError error = response.getError();
GraphObject graphObject = response.getGraphObject();
if (error != null) {
Log.w(LOG_TAG, String.format("Could not delete test account %s: %s", testAccountId, error.getException().toString()));
} else if (graphObject.getProperty(Response.NON_JSON_RESPONSE_PROPERTY) == (Boolean) false) {
Log.w(LOG_TAG, String.format("Could not delete test account %s: unknown reason", testAccountId));
}
}
示例12: Response
import com.facebook.model.GraphObject; //导入依赖的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;
}
示例13: getGraphObjectAs
import com.facebook.model.GraphObject; //导入依赖的package包/类
/**
* The single graph object returned for this request, if any, cast into a particular type of GraphObject.
*
* @param graphObjectClass the GraphObject-derived interface to cast the graph object into
* @return the graph object returned, or null if none was returned (or if the result was a list)
* @throws FacebookException If the passed in Class is not a valid GraphObject interface
*/
public final <T extends GraphObject> T getGraphObjectAs(Class<T> graphObjectClass) {
if (graphObject == null) {
return null;
}
if (graphObjectClass == null) {
throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
}
return graphObject.cast(graphObjectClass);
}
示例14: createResponseFromObject
import com.facebook.model.GraphObject; //导入依赖的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());
}
}
示例15: safeGetBooleanFromResponse
import com.facebook.model.GraphObject; //导入依赖的package包/类
private static boolean safeGetBooleanFromResponse(GraphObject response, String propertyName) {
Object result = false;
if (response != null) {
result = response.getProperty(propertyName);
}
if (!(result instanceof Boolean)) {
result = false;
}
return (Boolean) result;
}