com.facebook.internal.Validate类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中com.facebook.internal.Validate类的一些代码示例,展示了Validate类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate类的具体详情如下:
包路径:com.facebook.internal.Validate
类名称:Validate

Validate介绍

[英]com.facebook.internal is solely for the use of other packages within the Facebook SDK for Android. Use of any of the classes in this package is unsupported, and they may be modified or removed without warning at any time.
[中]通用域名格式。脸谱网。internal仅供Android版Facebook SDK中的其他软件包使用。不支持使用此软件包中的任何类,可以随时修改或删除这些类,而无需发出警告。

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

protected FacebookDialogBase(final Activity activity, int requestCode) {
  Validate.notNull(activity, "activity");
  this.activity = activity;
  this.fragmentWrapper = null;
  this.requestCode = requestCode;
}

代码示例来源:origin: facebook/facebook-android-sdk

public Logger(LoggingBehavior behavior, String tag) {
  Validate.notNullOrEmpty(tag, "tag");
  this.behavior = behavior;
  this.tag = LOG_TAG_BASE + tag;
  this.contents = new StringBuilder();
}

代码示例来源:origin: facebook/facebook-android-sdk

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);
    }
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

public static <T> void notEmptyAndContainsNoNulls(Collection<T> container, String name) {
  Validate.containsNoNulls(container, name);
  Validate.notEmpty(container, name);
}

代码示例来源:origin: facebook/facebook-android-sdk

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));
      }
    }
  }
}

代码示例来源:origin: fr.avianey/facebook-android-api

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;
}

代码示例来源:origin: fr.avianey/facebook-android-api

/**
 * 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);
      }
    }
  });
}

代码示例来源:origin: fr.avianey/facebook-android-api

Validate.notNull(objectProperty, "objectProperty");
Validate.containsNoNulls(bitmapFiles, "bitmapFiles");
if (action == null) {
  throw new FacebookException("Can not set attachments prior to setting action.");

代码示例来源:origin: facebook/facebook-android-sdk

Validate.notNull(applicationContext, "applicationContext");
Validate.hasFacebookActivity(applicationContext, false);
Validate.hasInternetPermissions(applicationContext, false);

代码示例来源:origin: facebook/facebook-android-sdk

public void setPriority(int value) {
  Validate.oneOf(
      value, "value", Log.ASSERT, Log.DEBUG, Log.ERROR, Log.INFO, Log.VERBOSE, Log.WARN);
  priority = value;
}

代码示例来源:origin: facebook/facebook-android-sdk

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);
}

代码示例来源:origin: facebook/facebook-android-sdk

@Test
public void testNotEmptylOnEmpty() {
  try {
    Validate.notEmpty(Arrays.asList(new String[] {}), "name");
    fail("expected exception");
  } catch (Exception e) {
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

String accessToken = Validate.hasAppID()+ "|" + Validate.hasClientToken();
parameters.putString(GraphRequest.ACCESS_TOKEN_PARAM, accessToken);
parameters.putString(DeviceRequestsHelper.DEVICE_INFO_PARAM,

代码示例来源:origin: facebook/facebook-android-sdk

public static void hasFacebookActivity(Context context) {
  Validate.hasFacebookActivity(context, true);
}

代码示例来源:origin: fr.avianey/facebook-android-api

/**
 * <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;
}

代码示例来源:origin: facebook/facebook-android-sdk

public static void hasInternetPermissions(Context context) {
  Validate.hasInternetPermissions(context, true);
}

代码示例来源:origin: fr.avianey/facebook-android-api

/**
 * 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;
}

代码示例来源:origin: fr.avianey/facebook-android-api

Validate.notNull(context, "context");
Validate.notNull(callId, "callId");
Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

代码示例来源:origin: fr.avianey/facebook-android-api

Validate.notNull(objectProperty, "objectProperty");
Validate.containsNoNulls(bitmaps, "bitmaps");
if (action == null) {
  throw new FacebookException("Can not set attachments prior to setting action.");

代码示例来源:origin: facebook/facebook-android-sdk

@Test
public void testOneOfOnInvalid() {
  try {
    Validate.oneOf("hit", "name", "hi", "there");
    fail("expected exception");
  } catch (Exception e) {
  }
}

相关文章