當前位置: 首頁>>代碼示例>>Java>>正文


Java Validate類代碼示例

本文整理匯總了Java中com.facebook.internal.Validate的典型用法代碼示例。如果您正苦於以下問題:Java Validate類的具體用法?Java Validate怎麽用?Java Validate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Validate類屬於com.facebook.internal包,在下文中一共展示了Validate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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");
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:26,代碼來源:GameRequestValidation.java

示例2: 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);
        }
    });
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:33,代碼來源:AppLinkData.java

示例3: createFromActivity

import com.facebook.internal.Validate; //導入依賴的package包/類
/**
 * Parses out any app link data from the Intent of the Activity passed in.
 * @param activity Activity that was started because of an app link
 * @return AppLinkData if found. null if not.
 */
public static AppLinkData createFromActivity(Activity activity) {
    Validate.notNull(activity, "activity");
    Intent intent = activity.getIntent();
    if (intent == null) {
        return null;
    }

    AppLinkData appLinkData = createFromAlApplinkData(intent);
    if (appLinkData == null) {
        String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY);
        appLinkData = createFromJson(appLinkArgsJsonString);
    }
    if (appLinkData == null) {
        // Try regular app linking
        appLinkData = createFromUri(intent.getData());
    }

    return appLinkData;
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:25,代碼來源:AppLinkData.java

示例4: save

import com.facebook.internal.Validate; //導入依賴的package包/類
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;
        }
    }
    editor.apply();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:23,代碼來源:LegacyTokenHelper.java

示例5: OpenGraphDialogBuilderBase

import com.facebook.internal.Validate; //導入依賴的package包/類
/**
 * 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 actionType          the type of the Open Graph action to be published, which should be the namespace-qualified
 *                            name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type
 *                            of the action passed in.
 * @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
 */
@Deprecated
public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String actionType,
        String previewPropertyName) {
    super(activity);

    Validate.notNull(action, "action");
    Validate.notNullOrEmpty(actionType, "actionType");
    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.");
    }
    String typeOnAction = action.getType();
    if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) {
        throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " +
                "Consider using OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, " +
                "String previewPropertyName) instead.");
    }
    this.action = action;
    this.actionType = actionType;
    this.previewPropertyName = previewPropertyName;
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:38,代碼來源:FacebookDialog.java

示例6: 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,項目名稱:AndroidBackendlessChat,代碼行數:30,代碼來源:SharedPreferencesTokenCachingStrategy.java

示例7: addAttachmentsForCall

import com.facebook.internal.Validate; //導入依賴的package包/類
/**
 * 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);
            }
        }
    });
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:29,代碼來源:NativeAppCallAttachmentStore.java

示例8: OpenGraphDialogBuilderBase

import com.facebook.internal.Validate; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:28,代碼來源:FacebookDialog.java

示例9: 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,項目名稱:chat-sdk-android-push-firebase,代碼行數:28,代碼來源:SharedPreferencesTokenCachingStrategy.java

示例10: getApplicationSignature

import com.facebook.internal.Validate; //導入依賴的package包/類
public static String getApplicationSignature(Context context) {
    Validate.sdkInitialized();
    if (context == null) {
        return null;
    }
    PackageManager packageManager = context.getPackageManager();
    if (packageManager == null) {
        return null;
    }
    try {
        PackageInfo pInfo = packageManager.getPackageInfo(context.getPackageName(), 64);
        Signature[] signatures = pInfo.signatures;
        if (signatures == null || signatures.length == 0) {
            return null;
        }
        try {
            MessageDigest md = MessageDigest.getInstance(CommonUtils.SHA1_INSTANCE);
            md.update(pInfo.signatures[0].toByteArray());
            return Base64.encodeToString(md.digest(), 9);
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
    } catch (NameNotFoundException e2) {
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:27,代碼來源:FacebookSdk.java

示例11: AccessTokenManager

import com.facebook.internal.Validate; //導入依賴的package包/類
AccessTokenManager(LocalBroadcastManager localBroadcastManager,
                   AccessTokenCache accessTokenCache) {

    Validate.notNull(localBroadcastManager, "localBroadcastManager");
    Validate.notNull(accessTokenCache, "accessTokenCache");

    this.localBroadcastManager = localBroadcastManager;
    this.accessTokenCache = accessTokenCache;
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:10,代碼來源:AccessTokenManager.java

示例12: create

import com.facebook.internal.Validate; //導入依賴的package包/類
public static Bundle create(
        UUID callId,
        ShareContent shareContent,
        boolean shouldFailOnDataError) {
    Validate.notNull(shareContent, "shareContent");
    Validate.notNull(callId, "callId");

    Bundle nativeParams = null;
    if (shareContent instanceof ShareLinkContent) {
        final ShareLinkContent linkContent = (ShareLinkContent)shareContent;
        nativeParams = create(linkContent, shouldFailOnDataError);
    } else if (shareContent instanceof SharePhotoContent) {
        final SharePhotoContent photoContent = (SharePhotoContent)shareContent;
        List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
                photoContent,
                callId);

        nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
    } else if (shareContent instanceof ShareVideoContent) {
        final ShareVideoContent videoContent = (ShareVideoContent)shareContent;
        nativeParams = create(videoContent, shouldFailOnDataError);
    } else if (shareContent instanceof ShareOpenGraphContent) {
        final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
        try {
            JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
                    callId, openGraphContent);

            nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
        } catch (final JSONException e) {
            throw new FacebookException(
                    "Unable to create a JSON Object from the provided ShareOpenGraphContent: "
                            + e.getMessage());
        }
    }

    return nativeParams;
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:38,代碼來源:LegacyNativeDialogParameters.java

示例13: addAttachmentFilesForCall

import com.facebook.internal.Validate; //導入依賴的package包/類
/**
 * Adds a number of bitmap attachment files 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 Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:37,代碼來源:NativeAppCallAttachmentStore.java

示例14: save

import com.facebook.internal.Validate; //導入依賴的package包/類
public void save(AccessToken accessToken) {
    Validate.notNull(accessToken, "accessToken");

    JSONObject jsonObject = null;
    try {
        jsonObject = accessToken.toJSONObject();
        sharedPreferences.edit().putString(CACHED_ACCESS_TOKEN_KEY, jsonObject.toString())
                .apply();
    } catch (JSONException e) {
        // Can't recover
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:13,代碼來源:AccessTokenCache.java

示例15: Result

import com.facebook.internal.Validate; //導入依賴的package包/類
Result(
        Request request,
        Code code,
        AccessToken token,
        String errorMessage,
        String errorCode) {
    Validate.notNull(code, "code");
    this.request = request;
    this.token = token;
    this.errorMessage = errorMessage;
    this.code = code;
    this.errorCode = errorCode;
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:14,代碼來源:LoginClient.java


注:本文中的com.facebook.internal.Validate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。