TestSession(Activity paramActivity, List<String> paramList, TokenCachingStrategy paramTokenCachingStrategy, String paramString, TestSession.Mode paramMode) { super(paramActivity, testApplicationId, paramTokenCachingStrategy); Validate.notNull(paramList, "permissions"); Validate.notNullOrEmpty(testApplicationId, "testApplicationId"); Validate.notNullOrEmpty(testApplicationSecret, "testApplicationSecret"); sessionUniqueUserTag = paramString; mode = paramMode; requestedPermissions = paramList; }
public Logger(LoggingBehavior behavior, String tag) { Validate.notNullOrEmpty(tag, "tag"); this.behavior = behavior; this.tag = LOG_TAG_BASE + tag; this.contents = new StringBuilder(); }
/** * 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"); } }
public static String getMetadataApplicationId(Context context) { Validate.notNull(context, "context"); Settings.loadDefaultsFromMetadata(context); return Settings.getApplicationId(); }
public ProfileTracker() { this.isTracking = false; Validate.sdkInitialized(); this.receiver = new ProfileBroadcastReceiver(); this.broadcastManager = LocalBroadcastManager.getInstance(FacebookSdk.getApplicationContext()); startTracking(); }
public static String getMetadataApplicationId(Context context) { Validate.notNull(context, "context"); FacebookSdk.sdkInitialize(context); return FacebookSdk.getApplicationId(); }
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"); } }
void save(Profile profile) { Validate.notNull(profile, "profile"); profile = profile.toJSONObject(); if (profile != null) { sharedPreferences.edit().putString("com.facebook.ProfileManager.CachedProfile", profile.toString()).apply(); } }
TestSession( Activity activity, List<String> permissions, TokenCachingStrategy tokenCachingStrategy, String sessionUniqueUserTag, Mode mode) { super(activity, TestSession.testApplicationId, tokenCachingStrategy); Validate.notNull(permissions, "permissions"); // Validate these as if they were arguments even though they are statics. Validate.notNullOrEmpty(testApplicationId, "testApplicationId"); Validate.notNullOrEmpty(testApplicationSecret, "testApplicationSecret"); this.sessionUniqueUserTag = sessionUniqueUserTag; this.mode = mode; this.requestedPermissions = permissions; }
public static AccessToken createFromNativeLinkingIntent(Intent intent) { Validate.notNull(intent, "intent"); if (intent.getExtras() == null) { return null; } else { return createFromBundle(null, intent.getExtras(), AccessTokenSource.FACEBOOK_APPLICATION_WEB, new Date()); } }
/** * Creates a {@link com.facebook.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); }
/** Constructor is private, newLogger() methods should be used to build an instance. */ private InsightsLogger( Context context, String clientToken, String applicationId, Session session) { Validate.notNull(context, "context"); // Always ensure the client token is present, even if not needed for this particular logging // (because at // some point it will be required). Be harsh by throwing an exception because this is all too // easy to miss // and things will work with authenticated sessions, but start failing with users that don't // have // authenticated sessions. Validate.notNullOrEmpty(clientToken, "clientToken"); if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } this.context = context; this.clientToken = clientToken; this.applicationId = applicationId; this.specifiedSession = session; }
public static Attachment createAttachment(UUID uuid, Uri uri) { Validate.notNull(uuid, "callId"); Validate.notNull(uri, "attachmentUri"); return new Attachment(null, uri, null); }
/** * 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; } }
public void setPriority(int value) { Validate.oneOf( value, "value", Log.ASSERT, Log.DEBUG, Log.ERROR, Log.INFO, Log.VERBOSE, Log.WARN); priority = value; }
void setPermissions(Set set) { Validate.notNull(set, "permissions"); permissions = set; }
public static Attachment createAttachment(UUID uuid, Bitmap bitmap) { Validate.notNull(uuid, "callId"); Validate.notNull(bitmap, "attachmentBitmap"); return new Attachment(bitmap, null, null); }