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