Search in sources :

Example 1 with FacebookOperationCanceledException

use of com.facebook.FacebookOperationCanceledException in project facebook-android-sdk by facebook.

the class CustomTabLoginMethodHandlerTest method testCustomTabHandlesCancel.

@Test
public void testCustomTabHandlesCancel() {
    handler.onComplete(request, null, new FacebookOperationCanceledException());
    final ArgumentCaptor<LoginClient.Result> resultArgumentCaptor = ArgumentCaptor.forClass(LoginClient.Result.class);
    verify(mockLoginClient, times(1)).completeAndValidate(resultArgumentCaptor.capture());
    final LoginClient.Result result = resultArgumentCaptor.getValue();
    assertNotNull(result);
    assertEquals(LoginClient.Result.Code.CANCEL, result.code);
    assertNull(result.token);
    assertNotNull(result.errorMessage);
}
Also used : FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with FacebookOperationCanceledException

use of com.facebook.FacebookOperationCanceledException in project facebook-api-android-maven by avianey.

the class FbDialog method callDialogListener.

private void callDialogListener(Bundle values, FacebookException error) {
    if (mListener == null) {
        return;
    }
    if (values != null) {
        mListener.onComplete(values);
    } else {
        if (error instanceof FacebookDialogException) {
            FacebookDialogException facebookDialogException = (FacebookDialogException) error;
            DialogError dialogError = new DialogError(facebookDialogException.getMessage(), facebookDialogException.getErrorCode(), facebookDialogException.getFailingUrl());
            mListener.onError(dialogError);
        } else if (error instanceof FacebookOperationCanceledException) {
            mListener.onCancel();
        } else {
            FacebookError facebookError = new FacebookError(error.getMessage());
            mListener.onFacebookError(facebookError);
        }
    }
}
Also used : FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException) FacebookDialogException(com.facebook.FacebookDialogException)

Example 3 with FacebookOperationCanceledException

use of com.facebook.FacebookOperationCanceledException in project phonegap-facebook-plugin by Wizcorp.

the class FbDialog method callDialogListener.

private void callDialogListener(Bundle values, FacebookException error) {
    if (mListener == null) {
        return;
    }
    if (values != null) {
        mListener.onComplete(values);
    } else {
        if (error instanceof FacebookDialogException) {
            FacebookDialogException facebookDialogException = (FacebookDialogException) error;
            DialogError dialogError = new DialogError(facebookDialogException.getMessage(), facebookDialogException.getErrorCode(), facebookDialogException.getFailingUrl());
            mListener.onError(dialogError);
        } else if (error instanceof FacebookOperationCanceledException) {
            mListener.onCancel();
        } else {
            FacebookError facebookError = new FacebookError(error.getMessage());
            mListener.onFacebookError(facebookError);
        }
    }
}
Also used : FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException) FacebookDialogException(com.facebook.FacebookDialogException)

Example 4 with FacebookOperationCanceledException

use of com.facebook.FacebookOperationCanceledException in project phonegap-facebook-plugin by Wizcorp.

the class ConnectPlugin method onSessionStateChange.

/*
     * Handles session state changes
     */
private void onSessionStateChange(SessionState state, Exception exception) {
    Log.d(TAG, "onSessionStateChange:" + state.toString());
    if (exception != null && exception instanceof FacebookOperationCanceledException) {
        // only handle FacebookOperationCanceledException to support
        // SDK recovery behavior triggered by getUserInfo
        Log.e(TAG, "exception:" + exception.toString());
        handleError(exception, loginContext);
    } else {
        final Session session = Session.getActiveSession();
        // Check if the session is open
        if (state.isOpened()) {
            if (loginContext != null) {
                // Get user info
                getUserInfo(session, new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        // Create a new result with response data
                        if (loginContext != null) {
                            if (response.getError() != null) {
                                loginContext.error(getFacebookRequestErrorResponse(response.getError()));
                            } else {
                                GraphObject graphObject = response.getGraphObject();
                                Log.d(TAG, "returning login object " + graphObject.getInnerJSONObject().toString());
                                userID = user.getId();
                                loginContext.success(getResponse());
                                loginContext = null;
                            }
                        } else {
                            // Just update the userID in case we force quit the application before
                            userID = user.getId();
                        }
                    }
                });
            } else if (graphContext != null) {
                // Make the graph call
                makeGraphCall();
            }
        } else if (state == SessionState.CLOSED_LOGIN_FAILED && loginContext != null) {
            handleError(new FacebookAuthorizationException("Session was closed and was not closed normally"), loginContext);
        }
    }
}
Also used : Response(com.facebook.Response) FacebookAuthorizationException(com.facebook.FacebookAuthorizationException) FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException) GraphUser(com.facebook.model.GraphUser) GraphUserCallback(com.facebook.Request.GraphUserCallback) Request(com.facebook.Request) GraphObject(com.facebook.model.GraphObject) Session(com.facebook.Session)

Example 5 with FacebookOperationCanceledException

use of com.facebook.FacebookOperationCanceledException in project facebook-android-sdk by facebook.

the class CustomTabLoginMethodHandler method onActivityResult.

@Override
boolean onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode != CUSTOM_TAB_REQUEST_CODE) {
        return super.onActivityResult(requestCode, resultCode, data);
    }
    LoginClient.Request request = loginClient.getPendingRequest();
    if (resultCode == Activity.RESULT_OK) {
        onCustomTabComplete(data.getStringExtra(CustomTabMainActivity.EXTRA_URL), request);
        return true;
    }
    super.onComplete(request, null, new FacebookOperationCanceledException());
    return false;
}
Also used : FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException)

Aggregations

FacebookOperationCanceledException (com.facebook.FacebookOperationCanceledException)12 Bundle (android.os.Bundle)5 FacebookException (com.facebook.FacebookException)5 FacebookDialogException (com.facebook.FacebookDialogException)2 FacebookRequestError (com.facebook.FacebookRequestError)2 FacebookServiceException (com.facebook.FacebookServiceException)2 AppCall (com.facebook.internal.AppCall)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Uri (android.net.Uri)1 CookieSyncManager (android.webkit.CookieSyncManager)1 AccessToken (com.facebook.AccessToken)1 FacebookAuthorizationException (com.facebook.FacebookAuthorizationException)1 Request (com.facebook.Request)1 GraphUserCallback (com.facebook.Request.GraphUserCallback)1 Response (com.facebook.Response)1 Session (com.facebook.Session)1 GraphObject (com.facebook.model.GraphObject)1 GraphUser (com.facebook.model.GraphUser)1 WebDialog (com.facebook.widget.WebDialog)1