protected FacebookDialogBase(final Activity activity, int requestCode) { Validate.notNull(activity, "activity"); this.activity = activity; this.fragmentWrapper = null; this.requestCode = requestCode; }
public Logger(LoggingBehavior behavior, String tag) { Validate.notNullOrEmpty(tag, "tag"); this.behavior = behavior; this.tag = LOG_TAG_BASE + tag; this.contents = new StringBuilder(); }
public static void checkCustomTabRedirectActivity(Context context, boolean shouldThrow) { if (!hasCustomTabRedirectActivity(context)) { if (shouldThrow) { throw new IllegalStateException(CUSTOM_TAB_REDIRECT_ACTIVITY_NOT_FOUND_REASON); } else { Log.w(TAG, CUSTOM_TAB_REDIRECT_ACTIVITY_NOT_FOUND_REASON); } } }
public static <T> void notEmptyAndContainsNoNulls(Collection<T> container, String name) { Validate.containsNoNulls(container, name); Validate.notEmpty(container, name); }
public static void hasContentProvider(Context context) { Validate.notNull(context, "context"); String appId = Validate.hasAppID(); PackageManager pm = context.getPackageManager(); if (pm != null) { String providerName = CONTENT_PROVIDER_BASE + appId; if (pm.resolveContentProvider(providerName, 0) == null) { throw new IllegalStateException( String.format(CONTENT_PROVIDER_NOT_FOUND_REASON, providerName)); } } } }
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; }
/** * Adds a number of bitmap attachments associated with a native app call. The attachments will be * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}. * * @param context the Context the call is being made from * @param callId the unique ID of the call * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of * the URI processed by openFile * @throws java.io.IOException */ public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) { Validate.notNull(context, "context"); Validate.notNull(callId, "callId"); Validate.containsNoNulls(imageAttachments.values(), "imageAttachments"); Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments"); addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() { @Override public void processAttachment(Bitmap attachment, File outputFile) throws IOException { FileOutputStream outputStream = new FileOutputStream(outputFile); try { attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream); } finally { Utility.closeQuietly(outputStream); } } }); }
Validate.notNull(objectProperty, "objectProperty"); Validate.containsNoNulls(bitmapFiles, "bitmapFiles"); if (action == null) { throw new FacebookException("Can not set attachments prior to setting action.");
Validate.notNull(applicationContext, "applicationContext"); Validate.hasFacebookActivity(applicationContext, false); Validate.hasInternetPermissions(applicationContext, false);
public void setPriority(int value) { Validate.oneOf( value, "value", Log.ASSERT, Log.DEBUG, Log.ERROR, Log.INFO, Log.VERBOSE, Log.WARN); priority = value; }
public static void setupAppCallForWebDialog( AppCall appCall, String actionName, Bundle parameters) { Validate.hasFacebookActivity(FacebookSdk.getApplicationContext()); Validate.hasInternetPermissions(FacebookSdk.getApplicationContext()); Bundle intentParameters = new Bundle(); intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION, actionName); intentParameters.putBundle(NativeProtocol.WEB_DIALOG_PARAMS, parameters); Intent webDialogIntent = new Intent(); NativeProtocol.setupProtocolRequestIntent( webDialogIntent, appCall.getCallId().toString(), actionName, NativeProtocol.getLatestKnownVersion(), intentParameters); webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); webDialogIntent.setAction(FacebookDialogFragment.TAG); appCall.setRequestIntent(webDialogIntent); }
@Test public void testNotEmptylOnEmpty() { try { Validate.notEmpty(Arrays.asList(new String[] {}), "name"); fail("expected exception"); } catch (Exception e) { } }
String accessToken = Validate.hasAppID()+ "|" + Validate.hasClientToken(); parameters.putString(GraphRequest.ACCESS_TOKEN_PARAM, accessToken); parameters.putString(DeviceRequestsHelper.DEVICE_INFO_PARAM,
public static void hasFacebookActivity(Context context) { Validate.hasFacebookActivity(context, true); }
/** * <p>Specifies a list of images for the Open Graph action that should be uploaded prior to publishing the * action. The action must already have been set prior to calling this method. This method will generate unique * names for the image attachments and update the action to refer to these attachments. Note that calling * setAction again after calling this method will not clear the image attachments already set, but the new * action will have no reference to the existing attachments. 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.</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 bitmaps a list of Bitmaps to be uploaded and attached to the Open Graph action * @param isUserGenerated if true, specifies that the user_generated flag should be set for these images * @return this instance of the builder */ public CONCRETE setImageAttachmentsForAction(List<Bitmap> bitmaps, boolean isUserGenerated) { Validate.containsNoNulls(bitmaps, "bitmaps"); if (action == null) { throw new FacebookException("Can not set attachments prior to setting action."); } List<String> attachmentUrls = addImageAttachments(bitmaps); updateActionAttachmentUrls(attachmentUrls, isUserGenerated); @SuppressWarnings("unchecked") CONCRETE result = (CONCRETE) this; return result; }
public static void hasInternetPermissions(Context context) { Validate.hasInternetPermissions(context, true); }
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(action.getType(), "action.getType()"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } this.action = action; this.actionType = action.getType(); this.previewPropertyName = previewPropertyName; }
Validate.notNull(context, "context"); Validate.notNull(callId, "callId"); Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles"); Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");
Validate.notNull(objectProperty, "objectProperty"); Validate.containsNoNulls(bitmaps, "bitmaps"); if (action == null) { throw new FacebookException("Can not set attachments prior to setting action.");
@Test public void testOneOfOnInvalid() { try { Validate.oneOf("hit", "name", "hi", "there"); fail("expected exception"); } catch (Exception e) { } }