public static FacebookException getExceptionFromErrorData(Bundle errorData) { if (errorData == null) { return null; } String type = errorData.getString(BRIDGE_ARG_ERROR_TYPE); if (type == null) { type = errorData.getString(STATUS_ERROR_TYPE); } String description = errorData.getString(BRIDGE_ARG_ERROR_DESCRIPTION); if (description == null) { description = errorData.getString(STATUS_ERROR_DESCRIPTION); } if (type != null && type.equalsIgnoreCase(ERROR_USER_CANCELED)) { return new FacebookOperationCanceledException(description); } /* TODO parse error values and create appropriate exception class */ return new FacebookException(description); }
public static FacebookException getExceptionFromErrorData(Bundle errorData) { if (errorData == null) { return null; } String type = errorData.getString(BRIDGE_ARG_ERROR_TYPE); if (type == null) { type = errorData.getString(STATUS_ERROR_TYPE); } String description = errorData.getString(BRIDGE_ARG_ERROR_DESCRIPTION); if (description == null) { description = errorData.getString(STATUS_ERROR_DESCRIPTION); } if (type == null || !type.equalsIgnoreCase(ERROR_USER_CANCELED)) { return new FacebookException(description); } return new FacebookOperationCanceledException(description); }
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); } } }
public static Exception getExceptionFromErrorData(Bundle errorData) { if (errorData == null) { return null; } String type = errorData.getString(BRIDGE_ARG_ERROR_TYPE); if (type == null) { type = errorData.getString(STATUS_ERROR_TYPE); } String description = errorData.getString(BRIDGE_ARG_ERROR_DESCRIPTION); if (description == null) { description = errorData.getString(STATUS_ERROR_DESCRIPTION); } if (type != null && type.equalsIgnoreCase(ERROR_USER_CANCELED)) { return new FacebookOperationCanceledException(description); } /* TODO parse error values and create appropriate exception class */ return new FacebookException(description); }
private void callDialogListener(Bundle paramBundle, FacebookException paramFacebookException) { if (this.mListener == null) return; if (paramBundle != null) { this.mListener.onComplete(paramBundle); return; } if ((paramFacebookException instanceof FacebookDialogException)) { FacebookDialogException localFacebookDialogException = (FacebookDialogException)paramFacebookException; DialogError localDialogError = new DialogError(localFacebookDialogException.getMessage(), localFacebookDialogException.getErrorCode(), localFacebookDialogException.getFailingUrl()); this.mListener.onError(localDialogError); return; } if ((paramFacebookException instanceof FacebookOperationCanceledException)) { this.mListener.onCancel(); return; } FacebookError localFacebookError = new FacebookError(paramFacebookException.getMessage()); this.mListener.onFacebookError(localFacebookError); }
public final void onComplete(Bundle paramBundle, FacebookException paramFacebookException) { if (paramFacebookException == null) { if (paramBundle.getString("post_id") != null) { ϳ.ˊ(this.ˊ.ͺ, true, false, false); return; } ϳ.ˊ(this.ˊ.ͺ, false, false, true); return; } if ((paramFacebookException instanceof FacebookOperationCanceledException)) { ϳ.ˊ(this.ˊ.ͺ, false, false, true); return; } ϳ.ˊ(this.ˊ.ͺ, false, true, false); }
public static Exception getExceptionFromErrorData(Bundle errorData) { if (errorData == null) { return null; } // TODO This is not going to work for JS dialogs, where the keys are not STATUS_ERROR_TYPE etc. // TODO However, it should keep existing dialogs functional String type = errorData.getString(STATUS_ERROR_TYPE); String description = errorData.getString(STATUS_ERROR_DESCRIPTION); if (type != null && type.equalsIgnoreCase(ERROR_USER_CANCELED)) { return new FacebookOperationCanceledException(description); } /* TODO parse error values and create appropriate exception class */ return new FacebookException(description); }
public static boolean handleActivityResult( int requestCode, int resultCode, Intent data, ResultProcessor resultProcessor) { AppCall appCall = getAppCallFromActivityResult(requestCode, resultCode, data); if (appCall == null) { return false; } NativeAppCallAttachmentStore.cleanupAttachmentsForCall(appCall.getCallId()); if (resultProcessor == null) { return true; } FacebookException exception = NativeProtocol.getExceptionFromErrorData( NativeProtocol.getErrorDataFromResultIntent(data)); if (exception != null) { if (exception instanceof FacebookOperationCanceledException) { resultProcessor.onCancel(appCall); } else { resultProcessor.onError(appCall, exception); } } else { // If here, we did not find an error in the result. Bundle results = NativeProtocol.getSuccessResultsFromIntent(data); resultProcessor.onSuccess(appCall, results); } return true; }
public static Bundle createBundleForException(FacebookException e) { if (e == null) { return null; } Bundle errorBundle = new Bundle(); errorBundle.putString(BRIDGE_ARG_ERROR_DESCRIPTION, e.toString()); if (e instanceof FacebookOperationCanceledException) { errorBundle.putString(BRIDGE_ARG_ERROR_TYPE, ERROR_USER_CANCELED); } return errorBundle; }
/** Re authenticate after session state changed.*/ public static Promise<Object, BError, Void> onSessionStateChange(Session session, SessionState state, Exception exception) { if (DEBUG) Timber.i("Session changed state"); // If we can start the login process with no errors this promise wont be used. // The returned promise will be from the loginWithFacebook. Deferred<Object, BError, Void> deferred = new DeferredObject<>(); if (exception != null) { exception.printStackTrace(); if (exception instanceof FacebookOperationCanceledException) { deferred.reject(new BError(BError.Code.EXCEPTION, exception)); return deferred.promise(); } } if (state.isOpened()) { if (DEBUG) Timber.i("Session is open."); // We will need this session later to make request. userFacebookAccessToken = Session.getActiveSession().getAccessToken(); return loginWithFacebook(); } else if (state.isClosed()) { // Logged out of Facebook if (DEBUG) Timber.i("Session is closed."); deferred.reject(new BError(BError.Code.SESSION_CLOSED, "Facebook session is closed.")); } return deferred.promise(); }
protected void setFacebookLogin(){ facebookLogin.setOnErrorListener(new LoginButton.OnErrorListener() { @Override public void onError(FacebookException error) { if (error instanceof FacebookOperationCanceledException) return; else if (error.getMessage() != null && error.getMessage().equals("Log in attempt aborted.")) return; showAlertToast("Facebook error: " + error.getMessage() + " " + error.getClass().getSimpleName()); } }); facebookLogin.setReadPermissions(Arrays.asList("email", "user_friends")); }
public void onSessionStateChange(Session session, SessionState state, Exception exception){ if (!getNetworkAdapter().facebookEnabled()) { return; } if (exception != null) { exception.printStackTrace(); if (exception instanceof FacebookOperationCanceledException) { return; } }else showOrUpdateProgDialog(getString(R.string.authenticating)); BFacebookManager.onSessionStateChange(session, state, exception).done(new DoneCallback<Object>() { @Override public void onDone(Object o) { if (DEBUG) Timber.i("Connected to facebook"); afterLogin(); } }).fail(new FailCallback<BError>() { @Override public void onFail(BError bError) { if (DEBUG) Timber.i(TAG, "Error connecting to Facebook"); // Toast.makeText(LoginActivity.this, "Failed connect to facebook.", Toast.LENGTH_SHORT).show(); showAlertToast( getString(R.string.login_activity_facebook_connection_fail_toast) ); BFacebookManager.logout(ChatSDKAbstractLoginActivity.this); dismissProgDialog(); } }); }