Java Code Examples for com.facebook.FacebookCallback#onSuccess()

The following examples show how to use com.facebook.FacebookCallback#onSuccess() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoinAppGroupDialog.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
@Override
protected void registerCallbackImpl (
        final CallbackManagerImpl callbackManager,
        final FacebookCallback<Result> callback) {
    final ResultProcessor resultProcessor = (callback == null)
            ? null
            : new ResultProcessor(callback) {
        @Override
        public void onSuccess(AppCall appCall, Bundle results) {
            callback.onSuccess(new Result(results));
        }
    };

    CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() {
        @Override
        public boolean onActivityResult(int resultCode, Intent data) {
            return ShareInternalUtility.handleActivityResult(
                    getRequestCode(),
                    resultCode,
                    data,
                    resultProcessor);
        }
    };

    callbackManager.registerCallback(getRequestCode(), callbackManagerCallback);
}
 
Example 2
Source File: CreateAppGroupDialog.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
@Override
protected void registerCallbackImpl(
        final CallbackManagerImpl callbackManager,
        final FacebookCallback<Result> callback) {
    final ResultProcessor resultProcessor = (callback == null)
            ? null
            : new ResultProcessor(callback) {
        @Override
        public void onSuccess(AppCall appCall, Bundle results) {
            callback.onSuccess(new Result(results.getString("id")));
        }
    };

    CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() {
        @Override
        public boolean onActivityResult(int resultCode, Intent data) {
            return ShareInternalUtility.handleActivityResult(
                    getRequestCode(),
                    resultCode,
                    data,
                    resultProcessor);
        }
    };

    callbackManager.registerCallback(getRequestCode(), callbackManagerCallback);
}
 
Example 3
Source File: ShareInternalUtility.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
static void invokeOnSuccessCallback(
        FacebookCallback<Sharer.Result> callback,
        String postId) {
    logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_SUCCEEDED, null);
    if (callback != null) {
        callback.onSuccess(new Sharer.Result(postId));
    }
}
 
Example 4
Source File: LikeDialog.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
@Override
protected void registerCallbackImpl (
        final CallbackManagerImpl callbackManager,
        final FacebookCallback<Result> callback) {
    final ResultProcessor resultProcessor = (callback == null)
            ? null
            : new ResultProcessor(callback) {
        @Override
        public void onSuccess(AppCall appCall, Bundle results) {
            callback.onSuccess(new Result(results));
        }
    };

    CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() {
        @Override
        public boolean onActivityResult(int resultCode, Intent data) {
            return ShareInternalUtility.handleActivityResult(
                    getRequestCode(),
                    resultCode,
                    data,
                    resultProcessor);
        }
    };

    callbackManager.registerCallback(
            getRequestCode(),
            callbackManagerCallback);
}
 
Example 5
Source File: AppInviteDialog.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
protected void registerCallbackImpl(
        final CallbackManagerImpl callbackManager,
        final FacebookCallback<Result> callback) {
    final ResultProcessor resultProcessor = (callback == null)
            ? null
            : new ResultProcessor(callback) {
        @Override
        public void onSuccess(AppCall appCall, Bundle results) {
            String gesture = ShareInternalUtility.getNativeDialogCompletionGesture(results);
            if ("cancel".equalsIgnoreCase(gesture)) {
                callback.onCancel();
            } else {
                callback.onSuccess(new Result(results));
            }
        }
    };

    CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() {
        @Override
        public boolean onActivityResult(int resultCode, Intent data) {
            return ShareInternalUtility.handleActivityResult(
                    getRequestCode(),
                    resultCode,
                    data,
                    resultProcessor);
        }
    };

    callbackManager.registerCallback(
            getRequestCode(),
            callbackManagerCallback);
}
 
Example 6
Source File: GameRequestDialog.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
@Override
protected void registerCallbackImpl(
        final CallbackManagerImpl callbackManager,
        final FacebookCallback<Result> callback) {
    final ResultProcessor resultProcessor = (callback == null)
            ? null
            : new ResultProcessor(callback) {
        @Override
        public void onSuccess(AppCall appCall, Bundle results) {
            if (results != null) {
                callback.onSuccess(new Result(results));
            } else {
                onCancel(appCall);
            }
        }
    };

   callbackManager.registerCallback(
            getRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return ShareInternalUtility.handleActivityResult(
                            getRequestCode(),
                            resultCode,
                            data,
                            resultProcessor);
                }
            });
}
 
Example 7
Source File: LoginManager.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private void finishLogin(
        AccessToken newToken,
        LoginClient.Request origRequest,
        FacebookException exception,
        boolean isCanceled,
        FacebookCallback<LoginResult>  callback) {
    if (newToken != null) {
        AccessToken.setCurrentAccessToken(newToken);
        Profile.fetchProfileForCurrentAccessToken();
    }

    if (callback != null) {
        LoginResult loginResult = newToken != null
                ? computeLoginResult(origRequest, newToken)
                : null;
        // If there are no granted permissions, the operation is treated as cancel.
        if (isCanceled
                || (loginResult != null
                       && loginResult.getRecentlyGrantedPermissions().size() == 0)) {
            callback.onCancel();
        } else if (exception != null) {
            callback.onError(exception);
        } else if (newToken != null) {
            callback.onSuccess(loginResult);
        }
    }
}