Java 类com.facebook.internal.Utility 实例源码

项目:kognitivo    文件:AccessTokenManager.java   
private void setCurrentAccessToken(AccessToken currentAccessToken, boolean saveToCache) {
    AccessToken oldAccessToken = this.currentAccessToken;
    this.currentAccessToken = currentAccessToken;
    tokenRefreshInProgress.set(false);
    this.lastAttemptedTokenExtendDate = new Date(0);

    if (saveToCache) {
        if (currentAccessToken != null) {
            accessTokenCache.save(currentAccessToken);
        } else {
            accessTokenCache.clear();
            Utility.clearFacebookCookies(FacebookSdk.getApplicationContext());
        }
    }

    if (!Utility.areObjectsEqual(oldAccessToken, currentAccessToken)) {
        sendCurrentAccessTokenChangedBroadcast(oldAccessToken, currentAccessToken);
    }
}
项目:AndroidBackendlessChat    文件:FacebookDialog.java   
@Override
Bundle setBundleExtras(Bundle extras) {
    putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
    putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);
    putExtra(extras, NativeProtocol.EXTRA_TITLE, name);
    putExtra(extras, NativeProtocol.EXTRA_SUBTITLE, caption);
    putExtra(extras, NativeProtocol.EXTRA_DESCRIPTION, description);
    putExtra(extras, NativeProtocol.EXTRA_LINK, link);
    putExtra(extras, NativeProtocol.EXTRA_IMAGE, picture);
    putExtra(extras, NativeProtocol.EXTRA_PLACE_TAG, place);
    putExtra(extras, NativeProtocol.EXTRA_TITLE, name);
    putExtra(extras, NativeProtocol.EXTRA_REF, ref);

    extras.putBoolean(NativeProtocol.EXTRA_DATA_FAILURES_FATAL, dataErrorsFatal);
    if (!Utility.isNullOrEmpty(friends)) {
        extras.putStringArrayList(NativeProtocol.EXTRA_FRIEND_TAGS, friends);
    }
    return extras;
}
项目:chat-sdk-android-push-firebase    文件:PlacePickerFragment.java   
/**
 * Sets the search text and reloads the data in the control. This is used to provide search-box
 * functionality where the user may be typing or editing text rapidly. It uses a timer to avoid repeated
 * requerying, preferring to wait until the user pauses typing to refresh the data. Note that this
 * method will NOT update the text in the search box, if any, as it is intended to be called as a result
 * of changes to the search box (and is public to enable applications to provide their own search box
 * UI instead of the default one).
 *
 * @param searchText                 the search text
 * @param forceReloadEventIfSameText if true, will reload even if the search text has not changed; if false,
 *                                   identical search text will not force a reload
 */
public void onSearchBoxTextChanged(String searchText, boolean forceReloadEventIfSameText) {
    if (!forceReloadEventIfSameText && Utility.stringsEqualOrEmpty(this.searchText, searchText)) {
        return;
    }

    if (TextUtils.isEmpty(searchText)) {
        searchText = null;
    }
    this.searchText = searchText;

    // If search text is being set in response to user input, it is wasteful to send a new request
    // with every keystroke. Send a request the first time the search text is set, then set up a 2-second timer
    // and send whatever changes the user has made since then. (If nothing has changed
    // in 2 seconds, we reset so the next change will cause an immediate re-query.)
    hasSearchTextChangedSinceLastQuery = true;
    if (searchTextTimer == null) {
        searchTextTimer = createSearchTextTimer();
    }
}
项目:kognitivo    文件:LikeActionController.java   
@Override
protected void processSuccess(GraphResponse response) {
    JSONArray dataSet = Utility.tryGetJSONArrayFromResponse(
            response.getJSONObject(),
            "data");
    if (dataSet != null) {
        for (int i = 0; i < dataSet.length(); i++) {
            JSONObject data = dataSet.optJSONObject(i);
            if (data != null) {
                objectIsLiked = true;
                JSONObject appData = data.optJSONObject("application");
                AccessToken accessToken = AccessToken.getCurrentAccessToken();
                if (appData != null &&
                        accessToken != null &&
                        Utility.areObjectsEqual(
                                accessToken.getApplicationId(),
                                appData.optString("id"))) {
                    unlikeToken = data.optString("id");
                }
            }
        }
    }
}
项目:kognitivo    文件:WebDialogParameters.java   
public static Bundle create(AppGroupCreationContent appGroupCreationContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            appGroupCreationContent.getName());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            appGroupCreationContent.getDescription());

    AppGroupCreationContent.AppGroupPrivacy privacy =
            appGroupCreationContent.getAppGroupPrivacy();
    if (privacy != null) {
        Utility.putNonEmptyString(
                webParams,
                ShareConstants.WEB_DIALOG_PARAM_PRIVACY,
                privacy.toString().toLowerCase(Locale.ENGLISH));
    }

    return webParams;
}
项目:kognitivo    文件:WebDialogParameters.java   
public static Bundle create(ShareOpenGraphContent shareOpenGraphContent) {
    Bundle params = new Bundle();

    Utility.putNonEmptyString(
            params,
            ShareConstants.WEB_DIALOG_PARAM_ACTION_TYPE,
            shareOpenGraphContent.getAction().getActionType());

    try {
        JSONObject ogJSON = ShareInternalUtility.toJSONObjectForWeb(shareOpenGraphContent);
        ogJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject(ogJSON, false);
        if (ogJSON != null) {
            Utility.putNonEmptyString(
                    params,
                    ShareConstants.WEB_DIALOG_PARAM_ACTION_PROPERTIES,
                    ogJSON.toString());
        }
    } catch (JSONException e) {
        throw new FacebookException("Unable to serialize the ShareOpenGraphContent to JSON", e);
    }

    return params;
}
项目:kognitivo    文件:WebDialogParameters.java   
public static Bundle createForFeed(ShareLinkContent shareLinkContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            shareLinkContent.getContentTitle());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            shareLinkContent.getContentDescription());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_LINK,
            Utility.getUriString(shareLinkContent.getContentUrl()));

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_PICTURE,
            Utility.getUriString(shareLinkContent.getImageUrl()));

    return webParams;
}
项目:kognitivo    文件:NativeDialogParameters.java   
private static Bundle create(
        ShareOpenGraphContent openGraphContent,
        JSONObject openGraphActionJSON,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(openGraphContent, dataErrorsFatal);

    // Strip namespace from preview property name
    String previewProperty = ShareInternalUtility.getFieldNameAndNamespaceFromFullName(
            openGraphContent.getPreviewPropertyName()).second;

    Utility.putNonEmptyString(
            params,
            ShareConstants.PREVIEW_PROPERTY_NAME,
            previewProperty);
    Utility.putNonEmptyString(
            params,
            ShareConstants.ACTION_TYPE,
            openGraphContent.getAction().getActionType());

    Utility.putNonEmptyString(
            params,
            ShareConstants.ACTION,
            openGraphActionJSON.toString());

    return params;
}
项目:kognitivo    文件:NativeDialogParameters.java   
private static Bundle createBaseParameters(ShareContent content, boolean dataErrorsFatal) {
    Bundle params = new Bundle();

    Utility.putUri(params, ShareConstants.CONTENT_URL, content.getContentUrl());
    Utility.putNonEmptyString(params, ShareConstants.PLACE_ID, content.getPlaceId());
    Utility.putNonEmptyString(params, ShareConstants.REF, content.getRef());

    params.putBoolean(ShareConstants.DATA_FAILURES_FATAL, dataErrorsFatal);

    List<String> peopleIds = content.getPeopleIds();
    if (!Utility.isNullOrEmpty(peopleIds)) {
        params.putStringArrayList(
                ShareConstants.PEOPLE_IDS,
                new ArrayList<String>(peopleIds));
    }

    return params;
}
项目:kognitivo    文件:ShareContentValidation.java   
private static void validatePhotoForApi(SharePhoto photo, Validator validator) {
    if (photo == null) {
        throw new FacebookException("Cannot share a null SharePhoto");
    }

    Bitmap photoBitmap = photo.getBitmap();
    Uri photoUri = photo.getImageUrl();

    if (photoBitmap == null) {
        if (photoUri == null) {
            throw new FacebookException(
                    "SharePhoto does not have a Bitmap or ImageUrl specified");
        }

        if (Utility.isWebUri(photoUri) && !validator.isOpenGraphContent()) {
            throw new FacebookException(
                    "Cannot set the ImageUrl of a SharePhoto to the Uri of an image on the " +
                            "web when sharing SharePhotoContent");
        }
    }
}
项目:kognitivo    文件:ShareContentValidation.java   
private static void validateOpenGraphContent(
        ShareOpenGraphContent openGraphContent, Validator validator) {
    validator.validate(openGraphContent.getAction());

    String previewPropertyName = openGraphContent.getPreviewPropertyName();
    if (Utility.isNullOrEmpty(previewPropertyName)) {
        throw new FacebookException("Must specify a previewPropertyName.");
    }

    if (openGraphContent.getAction().get(previewPropertyName) == null) {
        throw new FacebookException(
                "Property \"" + previewPropertyName + "\" was not found on the action. " +
                        "The name of the preview property must match the name of an " +
                        "action property.");
    }
}
项目:kognitivo    文件:LegacyNativeDialogParameters.java   
private static Bundle create(
        ShareOpenGraphContent openGraphContent,
        JSONObject openGraphActionJSON,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(openGraphContent, dataErrorsFatal);

    Utility.putNonEmptyString(
            params,
            ShareConstants.LEGACY_PREVIEW_PROPERTY_NAME,
            openGraphContent.getPreviewPropertyName());
    Utility.putNonEmptyString(
            params,
            ShareConstants.LEGACY_ACTION_TYPE,
            openGraphContent.getAction().getActionType());

    Utility.putNonEmptyString(
            params,
            ShareConstants.LEGACY_ACTION,
            openGraphActionJSON.toString());

    return params;
}
项目:kognitivo    文件:LegacyNativeDialogParameters.java   
private static Bundle createBaseParameters(ShareContent content, boolean dataErrorsFatal) {
    Bundle params = new Bundle();

    Utility.putUri(params, ShareConstants.LEGACY_LINK, content.getContentUrl());
    Utility.putNonEmptyString(params, ShareConstants.LEGACY_PLACE_TAG, content.getPlaceId());
    Utility.putNonEmptyString(params, ShareConstants.LEGACY_REF, content.getRef());

    params.putBoolean(ShareConstants.LEGACY_DATA_FAILURES_FATAL, dataErrorsFatal);

    List<String> peopleIds = content.getPeopleIds();
    if (!Utility.isNullOrEmpty(peopleIds)) {
        params.putStringArrayList(
                ShareConstants.LEGACY_FRIEND_TAGS,
                new ArrayList<>(peopleIds));
    }

    return params;
}
项目:kognitivo    文件:VideoUploader.java   
private static void issueResponse(
        final UploadContext uploadContext,
        final FacebookException error,
        final String videoId) {
    // Remove the UploadContext synchronously
    // Once the UploadContext is removed, this is the only reference to it.
    removePendingUpload(uploadContext);

    Utility.closeQuietly(uploadContext.videoStream);

    if (uploadContext.callback != null) {
        if (error != null) {
            ShareInternalUtility.invokeOnErrorCallback(uploadContext.callback, error);
        } else if (uploadContext.isCanceled) {
            ShareInternalUtility.invokeOnCancelCallback(uploadContext.callback);
        } else {
            ShareInternalUtility.invokeOnSuccessCallback(uploadContext.callback, videoId);
        }
    }
}
项目:kognitivo    文件:VideoUploader.java   
private static void registerAccessTokenTracker() {
    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken,
                AccessToken currentAccessToken) {
            if (oldAccessToken == null) {
                // If we never had an access token, then there would be no pending uploads.
                return;
            }

            if (currentAccessToken == null ||
                    !Utility.areObjectsEqual(
                            currentAccessToken.getUserId(),
                            oldAccessToken.getUserId())) {
                // Cancel any pending uploads since the user changed.
                cancelAllRequests();
            }
        }
    };
}
项目:kognitivo    文件:VideoUploader.java   
@Override
protected void handleSuccess(JSONObject jsonObject)
        throws JSONException {
    String startOffset = jsonObject.getString(PARAM_START_OFFSET);
    String endOffset = jsonObject.getString(PARAM_END_OFFSET);

    if (Utility.areObjectsEqual(startOffset, endOffset)) {
        enqueueUploadFinish(
                uploadContext,
                0);
    } else {
        enqueueUploadChunk(
                uploadContext,
                startOffset,
                endOffset,
                0);
    }
}
项目:kognitivo    文件:ShareApi.java   
private void shareLinkContent(final ShareLinkContent linkContent,
                              final FacebookCallback<Sharer.Result> callback) {
    final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            final JSONObject data = response.getJSONObject();
            final String postId = (data == null ? null : data.optString("id"));
            ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
        }
    };
    final Bundle parameters = new Bundle();
    this.addCommonParameters(parameters, linkContent);
    parameters.putString("message", this.getMessage());
    parameters.putString("link", Utility.getUriString(linkContent.getContentUrl()));
    parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl()));
    parameters.putString("name", linkContent.getContentTitle());
    parameters.putString("description", linkContent.getContentDescription());
    parameters.putString("ref", linkContent.getRef());
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            getGraphPath("feed"),
            parameters,
            HttpMethod.POST,
            requestCallback).executeAsync();
}
项目:AndroidBackendlessChat    文件:PlacePickerFragment.java   
/**
 * Sets the search text and reloads the data in the control. This is used to provide search-box
 * functionality where the user may be typing or editing text rapidly. It uses a timer to avoid repeated
 * requerying, preferring to wait until the user pauses typing to refresh the data. Note that this
 * method will NOT update the text in the search box, if any, as it is intended to be called as a result
 * of changes to the search box (and is public to enable applications to provide their own search box
 * UI instead of the default one).
 *
 * @param searchText                 the search text
 * @param forceReloadEventIfSameText if true, will reload even if the search text has not changed; if false,
 *                                   identical search text will not force a reload
 */
public void onSearchBoxTextChanged(String searchText, boolean forceReloadEventIfSameText) {
    if (!forceReloadEventIfSameText && Utility.stringsEqualOrEmpty(this.searchText, searchText)) {
        return;
    }

    if (TextUtils.isEmpty(searchText)) {
        searchText = null;
    }
    this.searchText = searchText;

    // If search text is being set in response to user input, it is wasteful to send a new request
    // with every keystroke. Send a request the first time the search text is set, then set up a 2-second timer
    // and send whatever changes the user has made since then. (If nothing has changed
    // in 2 seconds, we reset so the next change will cause an immediate re-query.)
    hasSearchTextChangedSinceLastQuery = true;
    if (searchTextTimer == null) {
        searchTextTimer = createSearchTextTimer();
    }
}
项目:kognitivo    文件:LoginMethodHandler.java   
static AccessToken createAccessTokenFromNativeLogin(
        Bundle bundle,
        AccessTokenSource source,
        String applicationId) {
    Date expires = Utility.getBundleLongAsDate(
            bundle, NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH, new Date(0));
    ArrayList<String> permissions = bundle.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
    String token = bundle.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);

    if (Utility.isNullOrEmpty(token)) {
        return null;
    }

    String userId = bundle.getString(NativeProtocol.EXTRA_USER_ID);

    return new AccessToken(
            token,
            applicationId,
            userId,
            permissions,
            null,
            source,
            expires,
            new Date());
}
项目:chat-sdk-android-push-firebase    文件:FacebookDialog.java   
/**
 * 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;
}
项目:chat-sdk-android-push-firebase    文件:LoginButton.java   
private boolean initializeActiveSessionWithCachedToken(Context context) {
    if (context == null) {
        return false;
    }

    Session session = Session.getActiveSession();
    if (session != null) {
        return session.isOpened();
    }

    String applicationId = Utility.getMetadataApplicationId(context);
    if (applicationId == null) {
        return false;
    }

    return Session.openActiveSessionFromCache(context) != null;
}
项目:kognitivo    文件:AppLinkData.java   
/**
 * 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);
        }
    });
}
项目:kognitivo    文件:ProfileManager.java   
private void setCurrentProfile(Profile currentProfile, boolean writeToCache) {
    Profile oldProfile = this.currentProfile;
    this.currentProfile = currentProfile;

    if (writeToCache) {
        if (currentProfile != null) {
            profileCache.save(currentProfile);
        } else {
            profileCache.clear();
        }
    }

    if (!Utility.areObjectsEqual(oldProfile, currentProfile)) {
        sendCurrentProfileChangedBroadcast(oldProfile, currentProfile);
    }
}
项目:kognitivo    文件:AccessToken.java   
@SuppressLint("FieldGetter")
static AccessToken createFromRefresh(AccessToken current, Bundle bundle) {
    // Only tokens obtained via SSO support refresh. Token refresh returns the expiration date
    // in seconds from the epoch rather than seconds from now.
    if (current.source != AccessTokenSource.FACEBOOK_APPLICATION_WEB &&
            current.source != AccessTokenSource.FACEBOOK_APPLICATION_NATIVE &&
            current.source != AccessTokenSource.FACEBOOK_APPLICATION_SERVICE) {
        throw new FacebookException("Invalid token source: " + current.source);
    }

    Date expires = Utility.getBundleLongAsDate(bundle, EXPIRES_IN_KEY, new Date(0));
    String token = bundle.getString(ACCESS_TOKEN_KEY);

    if (Utility.isNullOrEmpty(token)) {
        return null;
    }
    return new AccessToken(
            token,
            current.applicationId,
            current.getUserId(),
            current.getPermissions(),
            current.getDeclinedPermissions(),
            current.source,
            expires,
            new Date());
}
项目:AndroidBackendlessChat    文件:SharedPreferencesTokenCachingStrategy.java   
/**
 * 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);
}
项目:AndroidBackendlessChat    文件:NativeAppCallAttachmentStore.java   
/**
 * 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);
            }
        }
    });
}
项目:kognitivo    文件:TestUserManager.java   
/**
 * Constructor.
 *
 * @param testApplicationSecret The application secret.
 * @param testApplicationId     The application id.
 */
public TestUserManager(String testApplicationSecret, String testApplicationId) {
    if (Utility.isNullOrEmpty(testApplicationId)
            || Utility.isNullOrEmpty(testApplicationSecret)) {
        throw new FacebookException("Must provide app ID and secret");
    }

    this.testApplicationSecret = testApplicationSecret;
    this.testApplicationId = testApplicationId;
}
项目:chat-sdk-android-push-firebase    文件:AccessToken.java   
static AccessToken createFromWebBundle(List<String> requestedPermissions, Bundle bundle, AccessTokenSource source) {
    Date expires = getBundleLongAsDate(bundle, EXPIRES_IN_KEY, new Date());
    String token = bundle.getString(ACCESS_TOKEN_KEY);

    // With Login v4, we now get back the actual permissions granted, so update the permissions to be the real thing
    String grantedPermissions = bundle.getString("granted_scopes");
    if (!Utility.isNullOrEmpty(grantedPermissions)) {
        requestedPermissions =  new ArrayList<String>(Arrays.asList(grantedPermissions.split(",")));
    }

    return createNew(requestedPermissions, token, expires, source);
}
项目:AndroidBackendlessChat    文件:AccessToken.java   
private static AccessToken createFromBundle(List<String> requestedPermissions, Bundle bundle,
        AccessTokenSource source,
        Date expirationBase) {
    String token = bundle.getString(ACCESS_TOKEN_KEY);
    Date expires = getBundleLongAsDate(bundle, EXPIRES_IN_KEY, expirationBase);

    if (Utility.isNullOrEmpty(token) || (expires == null)) {
        return null;
    }

    return new AccessToken(token, expires, requestedPermissions, source, new Date());
}
项目:chat-sdk-android-push-firebase    文件:WebDialog.java   
protected BuilderBase(Context context, String action) {
    Session activeSession = Session.getActiveSession();
    if (activeSession != null && activeSession.isOpened()) {
        this.session = activeSession;
    } else {
        String applicationId = Utility.getMetadataApplicationId(context);
        if (applicationId != null) {
            this.applicationId = applicationId;
        } else {
            throw new FacebookException("Attempted to create a builder without an open" +
                    " Active Session or a valid default Application ID.");
        }
    }
    finishInit(context, action, null);
}
项目:chat-sdk-android-push-firebase    文件:TestSession.java   
private static synchronized TestSession createTestSession(Activity activity, List<String> permissions, Mode mode,
        String sessionUniqueUserTag) {
    if (Utility.isNullOrEmpty(testApplicationId) || Utility.isNullOrEmpty(testApplicationSecret)) {
        throw new FacebookException("Must provide app ID and secret");
    }

    if (Utility.isNullOrEmpty(permissions)) {
        permissions = Arrays.asList("email", "publish_actions");
    }

    return new TestSession(activity, permissions, new TestTokenCachingStrategy(), sessionUniqueUserTag,
            mode);
}
项目:kognitivo    文件:LikeActionController.java   
@Override
protected void processSuccess(GraphResponse response) {
    JSONObject results = Utility.tryGetJSONObjectFromResponse(
            response.getJSONObject(),
            objectId);
    if (results != null) {
        // See if we can get the OG object Id out
        JSONObject ogObject = results.optJSONObject("og_object");
        if (ogObject != null) {
            verifiedObjectId = ogObject.optString("id");
        }
    }
}
项目:kognitivo    文件:LikeActionController.java   
@Override
protected void processSuccess(GraphResponse response) {
    JSONObject results = Utility.tryGetJSONObjectFromResponse(
            response.getJSONObject(),
            objectId);
    if (results != null) {
        verifiedObjectId = results.optString("id");
        objectIsPage = !Utility.isNullOrEmpty(verifiedObjectId);
    }
}
项目:kognitivo    文件:LikeActionController.java   
@Override
protected void processSuccess(GraphResponse response) {
    JSONArray dataSet = Utility.tryGetJSONArrayFromResponse(
            response.getJSONObject(),
            "data");
    if (dataSet != null && dataSet.length() > 0) {
        objectIsLiked = true;
    }
}
项目:kognitivo    文件:LikeActionController.java   
@Override
protected void processSuccess(GraphResponse response) {
    JSONObject engagementResults = Utility.tryGetJSONObjectFromResponse(
            response.getJSONObject(),
            "engagement");
    if (engagementResults != null) {
        // Missing properties in the response should default to cached like status
        likeCountStringWithLike =
                engagementResults.optString(
                        "count_string_with_like",
                        likeCountStringWithLike);

        likeCountStringWithoutLike =
                engagementResults.optString(
                        "count_string_without_like",
                        likeCountStringWithoutLike);

        socialSentenceStringWithLike =
                engagementResults.optString(
                        "social_sentence_with_like",
                        socialSentenceStringWithLike);

        socialSentenceStringWithoutLike =
                engagementResults.optString(
                        "social_sentence_without_like",
                        socialSentenceStringWithoutLike);
    }
}
项目:kognitivo    文件:WebDialogParameters.java   
public static Bundle createForFeed(ShareFeedContent shareFeedContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_TO_PARAM,
            shareFeedContent.getToId());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_LINK_PARAM,
            shareFeedContent.getLink());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_PICTURE_PARAM,
            shareFeedContent.getPicture());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_SOURCE_PARAM,
            shareFeedContent.getMediaSource());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_NAME_PARAM,
            shareFeedContent.getLinkName());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_CAPTION_PARAM,
            shareFeedContent.getLinkCaption());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_DESCRIPTION_PARAM,
            shareFeedContent.getLinkDescription());

    return webParams;
}
项目:AndroidBackendlessChat    文件:LoginButton.java   
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
项目:kognitivo    文件:NativeDialogParameters.java   
private static Bundle create(
        ShareVideoContent videoContent,
        String videoUrl,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(videoContent, dataErrorsFatal);

    Utility.putNonEmptyString(params, ShareConstants.TITLE, videoContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.DESCRIPTION, videoContent.getContentDescription());
    Utility.putNonEmptyString(params, ShareConstants.VIDEO_URL, videoUrl);

    return params;
}
项目:kognitivo    文件:ShareContentValidation.java   
private static void validatePhotoForWebDialog(SharePhoto photo, Validator validator) {
    if (photo == null) {
        throw new FacebookException("Cannot share a null SharePhoto");
    }

    Uri imageUri = photo.getImageUrl();
    if (imageUri == null || !Utility.isWebUri(imageUri)) {
        throw new FacebookException(
                "SharePhoto must have a non-null imageUrl set to the Uri of an image " +
                        "on the web");
    }
}
项目:AndroidBackendlessChat    文件:FacebookDialog.java   
@Override
Bundle setBundleExtras(Bundle extras) {
    putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
    putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);
    putExtra(extras, NativeProtocol.EXTRA_PLACE_TAG, place);
    extras.putStringArrayList(NativeProtocol.EXTRA_PHOTOS, imageAttachmentUrls);

    if (!Utility.isNullOrEmpty(friends)) {
        extras.putStringArrayList(NativeProtocol.EXTRA_FRIEND_TAGS, friends);
    }
    return extras;
}