本文整理匯總了Java中com.facebook.internal.Validate.notNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Validate.notNull方法的具體用法?Java Validate.notNull怎麽用?Java Validate.notNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.internal.Validate
的用法示例。
在下文中一共展示了Validate.notNull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: save
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Persists all supported data types present in the passed in Bundle, to the
* cache
*
* @param bundle
* The Bundle containing information to be cached
*/
public void save(Bundle bundle) {
Validate.notNull(bundle, "bundle");
SharedPreferences.Editor editor = cache.edit();
for (String key : bundle.keySet()) {
try {
serializeKey(key, bundle, editor);
} catch (JSONException e) {
// Error in the bundle. Don't store a partial cache.
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e);
// Bypass the commit and just return. This cancels the entire edit transaction
return;
}
}
boolean successfulCommit = editor.commit();
if (!successfulCommit) {
Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful");
}
}
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:30,代碼來源:SharedPreferencesTokenCachingStrategy.java
示例2: validate
import com.facebook.internal.Validate; //導入方法依賴的package包/類
public static void validate(GameRequestContent content) {
Validate.notNull(content.getMessage(), "message");
if (content.getObjectId() != null ^
(content.getActionType() == GameRequestContent.ActionType.ASKFOR
|| content.getActionType() == GameRequestContent.ActionType.SEND)) {
throw new IllegalArgumentException(
"Object id should be provided if and only if action type is send or askfor");
}
// parameters to, filters, suggestions are mutually exclusive
int mutex = 0;
if (content.getTo() != null) {
mutex++;
}
if (content.getSuggestions() != null) {
mutex++;
}
if (content.getFilters() != null) {
mutex++;
}
if (mutex > 1) {
throw new IllegalArgumentException(
"Parameters to, filters and suggestions are mutually exclusive");
}
}
示例3: SharedPreferencesTokenCachingStrategy
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Creates a {@link SharedPreferencesTokenCachingStrategy SharedPreferencesTokenCachingStrategy} instance
* that is distinct for the passed in cacheKey.
*
* @param context
* The Context object to use to get the SharedPreferences object.
*
* @param cacheKey
* Identifies a distinct set of token information.
*
* @throws NullPointerException if the passed in Context is null
*/
public SharedPreferencesTokenCachingStrategy(Context context, String cacheKey) {
Validate.notNull(context, "context");
this.cacheKey = Utility.isNullOrEmpty(cacheKey) ? DEFAULT_CACHE_KEY : cacheKey;
// If the application context is available, use that. However, if it isn't
// available (possibly because of a context that was created manually), use
// the passed in context directly.
Context applicationContext = context.getApplicationContext();
context = applicationContext != null ? applicationContext : context;
this.cache = context.getSharedPreferences(
this.cacheKey,
Context.MODE_PRIVATE);
}
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:28,代碼來源:SharedPreferencesTokenCachingStrategy.java
示例4: fetchDeferredAppLinkData
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Asynchronously fetches app link information that might have been stored for use after
* installation of the app
*
* @param context The context
* @param applicationId Facebook application Id. If null, it is taken from the manifest
* @param completionHandler CompletionHandler to be notified with the AppLinkData object or null
* if none is available. Must not be null.
*/
public static void fetchDeferredAppLinkData(
Context context,
String applicationId,
final CompletionHandler completionHandler) {
Validate.notNull(context, "context");
Validate.notNull(completionHandler, "completionHandler");
if (applicationId == null) {
applicationId = Utility.getMetadataApplicationId(context);
}
Validate.notNull(applicationId, "applicationId");
final Context applicationContext = context.getApplicationContext();
final String applicationIdCopy = applicationId;
FacebookSdk.getExecutor().execute(new Runnable() {
@Override
public void run() {
fetchDeferredAppLinkFromServer(
applicationContext, applicationIdCopy, completionHandler);
}
});
}
示例5: setExecutor
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Sets the Executor used by the SDK for non-AsyncTask background work.
*
* @param executor
* the Executor to use; must not be null.
*/
public static void setExecutor(Executor executor) {
Validate.notNull(executor, "executor");
synchronized (LOCK) {
Settings.executor = executor;
}
}
示例6: getSource
import com.facebook.internal.Validate; //導入方法依賴的package包/類
public static AccessTokenSource getSource(Bundle bundle) {
Validate.notNull(bundle, "bundle");
if (bundle.containsKey(TOKEN_SOURCE_KEY)) {
return (AccessTokenSource) bundle.getSerializable(TOKEN_SOURCE_KEY);
} else {
boolean isSSO = bundle.getBoolean(IS_SSO_KEY);
return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW;
}
}
示例7: BuilderBase
import com.facebook.internal.Validate; //導入方法依賴的package包/類
protected BuilderBase(Context context, Session session, String action, Bundle parameters) {
Validate.notNull(session, "session");
if (!session.isOpened()) {
throw new FacebookException("Attempted to use a Session that was not open.");
}
this.session = session;
finishInit(context, action, parameters);
}
示例8: Builder
import com.facebook.internal.Validate; //導入方法依賴的package包/類
Builder(Activity activity) {
Validate.notNull(activity, "activity");
this.activity = activity;
applicationId = Utility.getMetadataApplicationId(activity);
appCall = new PendingCall(NativeProtocol.DIALOG_REQUEST_CODE);
}
示例9: putPermissions
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Puts the list of permissions into a Bundle.
*
* @param bundle
* A Bundle in which the list of permissions should be stored.
* @param value
* The List<String> representing the list of permissions,
* or null.
*
* @throws NullPointerException if the passed in Bundle or permissions list are null
*/
public static void putPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
arrayList = new ArrayList<String>(value);
}
bundle.putStringArrayList(PERMISSIONS_KEY, arrayList);
}
示例10: AppEventsLogger
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Constructor is private, newLogger() methods should be used to build an instance.
*/
private AppEventsLogger(Context context, String applicationId, AccessToken accessToken) {
Validate.notNull(context, "context");
this.contextName = Utility.getActivityName(context);
if (accessToken == null) {
accessToken = AccessToken.getCurrentAccessToken();
}
// If we have a session and the appId passed is null or matches the session's app ID:
if (accessToken != null &&
(applicationId == null || applicationId.equals(accessToken.getApplicationId()))
) {
accessTokenAppId = new AccessTokenAppIdPair(accessToken);
} else {
// If no app ID passed, get it from the manifest:
if (applicationId == null) {
applicationId = Utility.getMetadataApplicationId(context);
}
accessTokenAppId = new AccessTokenAppIdPair(null, applicationId);
}
synchronized (staticLock) {
if (applicationContext == null) {
applicationContext = context.getApplicationContext();
}
}
initializeTimersIfNeeded();
}
示例11: getSource
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* Gets the cached enum indicating the source of the token from the Bundle.
*
* @param bundle
* A Bundle in which the enum was stored.
* @return enum indicating the source of the token
*
* @throws NullPointerException if the passed in Bundle is null
*/
public static AccessTokenSource getSource(Bundle bundle) {
Validate.notNull(bundle, "bundle");
if (bundle.containsKey(TokenCachingStrategy.TOKEN_SOURCE_KEY)) {
return (AccessTokenSource) bundle.getSerializable(TokenCachingStrategy.TOKEN_SOURCE_KEY);
} else {
boolean isSSO = bundle.getBoolean(TokenCachingStrategy.IS_SSO_KEY);
return isSSO ? AccessTokenSource.FACEBOOK_APPLICATION_WEB : AccessTokenSource.WEB_VIEW;
}
}
示例12: setImageAttachmentsForObject
import com.facebook.internal.Validate; //導入方法依賴的package包/類
/**
* <p>Specifies a list of images for an Open Graph object referenced by the action that should be uploaded
* prior to publishing the action. The images may be marked as being
* user-generated -- refer to
* <a href="https://developers.facebook.com/docs/opengraph/howtos/adding-photos-to-stories/">this article</a>
* for more information.
* The action must already have been set prior to calling this method, and
* the action must have a GraphObject-valued property with the specified property name. This method will
* generate unique names for the image attachments and update the graph object to refer to these
* attachments. Note that calling setObject again after calling this method, or modifying the value of the
* specified property, will not clear the image attachments already set, but the new action (or objects)
* will have no reference to the existing attachments.</p>
* <p/>
* <p>In order for the images to be provided to the Facebook application as part of the app call, the
* NativeAppCallContentProvider must be specified correctly in the application's AndroidManifest.xml.</p>
*
* @param objectProperty the name of a property on the action that corresponds to an Open Graph object;
* the object must be marked as a new object to be created
* (i.e., {@link com.facebook.model.OpenGraphObject#getCreateObject()} must return
* true) or an exception will be thrown
* @param objectProperty the name of a property on the action that corresponds to an Open Graph object
* @param bitmaps a list of Files containing bitmaps to be uploaded and attached to the Open Graph object
* @param isUserGenerated if true, specifies that the user_generated flag should be set for these images
* @return this instance of the builder
*/
public CONCRETE setImageAttachmentsForObject(String objectProperty, List<Bitmap> bitmaps,
boolean isUserGenerated) {
Validate.notNull(objectProperty, "objectProperty");
Validate.containsNoNulls(bitmaps, "bitmaps");
if (action == null) {
throw new FacebookException("Can not set attachments prior to setting action.");
}
List<String> attachmentUrls = addImageAttachments(bitmaps);
updateObjectAttachmentUrls(objectProperty, attachmentUrls, isUserGenerated);
@SuppressWarnings("unchecked")
CONCRETE result = (CONCRETE) this;
return result;
}
示例13: putToken
import com.facebook.internal.Validate; //導入方法依賴的package包/類
public static void putToken(Bundle bundle, String value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
bundle.putString(TOKEN_KEY, value);
}
示例14: putLastRefreshMilliseconds
import com.facebook.internal.Validate; //導入方法依賴的package包/類
public static void putLastRefreshMilliseconds(Bundle bundle, long value) {
Validate.notNull(bundle, "bundle");
bundle.putLong(LAST_REFRESH_DATE_KEY, value);
}
示例15: getToken
import com.facebook.internal.Validate; //導入方法依賴的package包/類
public static String getToken(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getString(TOKEN_KEY);
}