Java 类com.facebook.FacebookCallback 实例源码

项目:kognitivo    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:kognitivo    文件:VideoUploader.java   
public static synchronized void uploadAsync(
        ShareVideoContent videoContent,
        String graphNode,
        FacebookCallback<Sharer.Result> callback)
        throws FileNotFoundException {
    if (!initialized) {
        registerAccessTokenTracker();
        initialized = true;
    }

    Validate.notNull(videoContent, "videoContent");
    Validate.notNull(graphNode, "graphNode");
    ShareVideo video = videoContent.getVideo();
    Validate.notNull(video, "videoContent.video");
    Uri videoUri = video.getLocalUrl();
    Validate.notNull(videoUri, "videoContent.video.localUrl");

    UploadContext uploadContext = new UploadContext(videoContent, graphNode, callback);
    uploadContext.initialize();

    pendingUploads.add(uploadContext);

    enqueueUploadStart(
            uploadContext,
            0);
}
项目:kognitivo    文件:VideoUploader.java   
private UploadContext(
        ShareVideoContent videoContent,
        String graphNode,
        FacebookCallback<Sharer.Result> callback) {
    // Store off the access token right away so that under no circumstances will we
    // end up with different tokens between phases. We will rely on the access token tracker
    // to cancel pending uploads.
    this.accessToken = AccessToken.getCurrentAccessToken();
    this.videoUri = videoContent.getVideo().getLocalUrl();
    this.title = videoContent.getContentTitle();
    this.description = videoContent.getContentDescription();
    this.ref = videoContent.getRef();
    this.graphNode = graphNode;
    this.callback = callback;
    this.params = videoContent.getVideo().getParameters();
}
项目: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();
}
项目:kognitivo    文件:JoinAppGroupDialog.java   
@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);
}
项目:kognitivo    文件:CreateAppGroupDialog.java   
@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);
}
项目:kognitivo    文件:LoginManager.java   
/**
 * Registers a login callback to the given callback manager.
 * @param callbackManager The callback manager that will encapsulate the callback.
 * @param callback The login callback that will be called on login completion.
 */
public void registerCallback(
        final CallbackManager callbackManager,
        final FacebookCallback<LoginResult> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }
    ((CallbackManagerImpl) callbackManager).registerCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(
                            resultCode,
                            data,
                            callback);
                }
            }
    );
}
项目:social-login-helper    文件:FacebookHelper.java   
public FacebookHelper(@NonNull FacebookListener facebookListener) {
  mListener = facebookListener;
  mCallBackManager = CallbackManager.Factory.create();
  FacebookCallback<LoginResult> mCallBack = new FacebookCallback<LoginResult>() {
    @Override public void onSuccess(LoginResult loginResult) {
      mListener.onFbSignInSuccess(loginResult.getAccessToken().getToken(),
          loginResult.getAccessToken().getUserId());
    }

    @Override public void onCancel() {
      mListener.onFbSignInFail("User cancelled operation");
    }

    @Override public void onError(FacebookException e) {
      mListener.onFbSignInFail(e.getMessage());
    }
  };
  LoginManager.getInstance().registerCallback(mCallBackManager, mCallBack);
}
项目:android-paypal-example    文件:LoginActivity.java   
@OnClick(R.id.fb_login)
public void setUpFacebookLoginButton() {
    LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
            if(!isNetworkConnected()){
                Snackbar.make(findViewById(android.R.id.content),"please check internet connection"
                        ,Snackbar.LENGTH_SHORT).show();
            }else{
                Snackbar.make(findViewById(android.R.id.content),"unexpected error,please try again later"
                        ,Snackbar.LENGTH_SHORT).show();
            }
        }
    });
}
项目:Stalker    文件:AuthenticateFragment.java   
protected void registerFacebookCallback() {
    LoginManager.getInstance().registerCallback(facebookCallbackManager,
            new FacebookCallback<LoginResult>() {

                @Override
                public void onSuccess(LoginResult loginResult) {
                    // App code
                    Log.d(TAG, "Login Success");
                    handleFacebookAccessToken(loginResult.getAccessToken());
                }

                @Override
                public void onCancel() {
                    // App code
                    Log.d(TAG, "Login canceled");
                }

                @Override
                public void onError(FacebookException exception) {
                    // App code
                    Log.d(TAG, "Login error");
                }
            });
}
项目:firebase-chat-android-architecture-components    文件:ProfileActivity.java   
private void setupFacebookLogin() {
    mFacebookCallbackManager = CallbackManager.Factory.create();

    binding.facebookButton.setReadPermissions("email","public_profile");

    // Callback registration
    binding.facebookButton.registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            firebaseAuthWithFacebook(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Toast.makeText(ProfileActivity.this, "Facebook Authentication cancelled.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(FacebookException exception) {
            Toast.makeText(ProfileActivity.this, "Facebook Authentication failed.", Toast.LENGTH_SHORT).show();
            Timber.e(exception);
        }
    });
}
项目:enklave    文件:LoginFacebook.java   
public LoginFacebook(LoginButton login, Activity context, PreferencesShared pref, final Intent intent) {
    callbackManager = CallbackManager.Factory.create();
    this.context = context;
    preferencesShared = pref;
    login.setReadPermissions(Arrays.asList("public_profile", "user_friends"));
    login.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            //Log.d("facebook", "succes" + loginResult.getAccessToken().getToken() + "id" + loginResult.getAccessToken().getExpires() + "data" + loginResult.getAccessToken().getUserId());
            conectedwithFacebook(loginResult.getAccessToken().getToken(),intent);
        }

        @Override
        public void onCancel() {
            Log.d("intra","facebook");
        }

        @Override
        public void onError(FacebookException error) {
            Log.d("facebook", "error" + error.toString());
        }

    });
}
项目:apn_fb_login    文件:FacebookHelper.java   
public static FacebookCallback<LoginResult> loginResultCallback(final MethodChannel.Result result, final OnLoginSuccessListener onLoginSuccess) {
    return new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            onLoginSuccess.onLoginResult(loginResult);
        }

        @Override
        public void onCancel() {
            result.error(TAG, "Cancelled", null);
        }

        @Override
        public void onError(FacebookException exception) {
            result.error(TAG, exception.getMessage(), null);
        }
    };
}
项目:AndroidBlueprints    文件:FacebookHelper.java   
/**
 * Register call back manager.
 *
 * @param activity the activity
 */
private void registerCallBackManager(final Activity activity) {
    LoginManager.getInstance()
            .registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    mLoginResult = loginResult;
                    getUserProfile(activity);
                }

                @Override
                public void onCancel() {
                    mFacebookLoginResultCallBack.onFacebookLoginCancel();
                }

                @Override
                public void onError(FacebookException error) {
                    mFacebookLoginResultCallBack.onFacebookLoginError(error);
                }
            });
}
项目:AndroidBlueprints    文件:FacebookHelper.java   
/**
 * Register call back manager to Google log in button.
 *
 * @param activity    the activity
 * @param loginButton the login button
 */
private void registerCallBackManager(final Activity activity, LoginButton loginButton) {
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            mLoginResult = loginResult;
            getUserProfile(activity);
        }

        @Override
        public void onCancel() {
            mFacebookLoginResultCallBack.onFacebookLoginCancel();
        }

        @Override
        public void onError(FacebookException error) {
            mFacebookLoginResultCallBack.onFacebookLoginError(error);
        }
    });
}
项目:BizareChat    文件:RegistrationPresenterImpl.java   
@Override
public void setCallbackToLoginFacebookButton() {

    callbackManager = CallbackManager.Factory.create();

    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Bundle param = new Bundle();
            param.putString("fields", "id, email");
            facebookLink(loginResult);
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
            Logger.logExceptionToFabric(error);
        }
    });
}
项目:social-journal    文件:LoginActivity.java   
void initializeFacebookLogin() {
    // Initialize Facebook Login button
    mCallbackManager = CallbackManager.Factory.create();
    LoginButton loginButton = (LoginButton) findViewById(R.id.button_facebook_login);
    loginButton.setReadPermissions("email", "public_profile", "user_posts", "user_photos");
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d(TAG, "facebook:onSuccess:" + loginResult);
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Log.d(TAG, "facebook:onCancel");
            // ...
        }

        @Override
        public void onError(FacebookException error) {
            Log.w(TAG, "facebook:onError", error);
        }
    });
}
项目:android-rss-feed-reader    文件:SignInPresenter.java   
@Override
public void onFacebookLoginBntClick(LoginButton loginButton) {
        mCallbackManager = CallbackManager.Factory.create();
        loginButton.setReadPermissions("email", "public_profile");
        loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                handleFacebookAccessToken(loginResult.getAccessToken());
            }

            @Override
            public void onCancel() {
            }

            @Override
            public void onError(FacebookException error) {
                getView().showSnackBar(error.getMessage());
            }
        });
}
项目:sabbath-school-android    文件:SSLoginViewModel.java   
private void configureFacebookLogin(){
    FacebookSdk.sdkInitialize(context.getApplicationContext());
    ssFacebookCallbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(ssFacebookCallbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    handleFacebookAccessToken(loginResult.getAccessToken());
                }

                @Override
                public void onCancel() {
                    // TODO: Handle unsuccessful / cancel
                }

                @Override
                public void onError(FacebookException exception) {
                    loginFailed(exception.getMessage());
                }
            });
}
项目:HaiNaBaiChuan    文件:LoginFragment.java   
private void initFaceBookLogin() {
    callbackManager = CallbackManager.Factory.create();
    btnLoginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            showDialog();
            presenter.requestFacebook(loginResult);
            LogUtil.e2(loginResult.getAccessToken().toString());
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
项目:vdb-android    文件:BaseActivity.java   
private void setFacebookRule() {
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    EventBus.getDefault().post(MessageEvent.UPDATE_FACEBOOK_PROFILE);
                }

                @Override
                public void onCancel() {
                    Log.d("Teste", "deu errp");
                }

                @Override
                public void onError(FacebookException exception) {
                    Log.d("ErrorF", exception.toString());
                }
            }
    );

    Profile profile = Profile.getCurrentProfile();

    if (profile != null) {
        this.sidebar.showHideLogoff(true);
    } else {
        this.sidebar.showHideLogoff(false);
    }

}
项目:Popdeem-SDK-Android    文件:PDUIConnectSocialAccountFragment.java   
private void registerFacebookLoginManagerCallback() {
        LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                connectFacebookAccount();
            }

            @Override
            public void onCancel() {
                PDAbraLogEvent.log(PDAbraConfig.ABRA_EVENT_CANCELLED_FACEBOOK_LOGIN, null);
//                PDLog.d(PDUISocialLoginFragment.class, "Facebook Login onCancel()");
//                if (getActivity() != null) {
//                    PDUIDialogUtils.showBasicOKAlertDialog(getActivity(), R.string.pd_common_facebook_login_cancelled_title_text, R.string.pd_common_facebook_login_cancelled_message_text);
//                }
            }

            @Override
            public void onError(FacebookException error) {
                PDLog.d(PDUISocialLoginFragment.class, "Facebook Login onError(): " + error.getMessage());
                if (getActivity() != null) {
                    PDUIDialogUtils.showBasicOKAlertDialog(getActivity(), R.string.pd_common_sorry_text, error.getMessage());
                }
            }
        });
    }
项目:Stalker    文件:AuthenticateFragment.java   
protected void registerFacebookCallback() {
    LoginManager.getInstance().registerCallback(facebookCallbackManager,
            new FacebookCallback<LoginResult>() {

                @Override
                public void onSuccess(LoginResult loginResult) {
                    // App code
                    Log.d(TAG, "Login Success");
                    handleFacebookAccessToken(loginResult.getAccessToken());
                }

                @Override
                public void onCancel() {
                    // App code
                    Log.d(TAG, "Login canceled");
                }

                @Override
                public void onError(FacebookException exception) {
                    // App code
                    Log.d(TAG, "Login error");
                }
            });
}
项目:Udacity-Capstone-Project    文件:SessionFragment.java   
private void facebookManger() {
    lBFrgLoginFacebook.setReadPermissions("email");
    lBFrgLoginFacebook.setFragment(this);
    lBFrgLoginFacebook.registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    presenter.doLoginWithFacebook(loginResult);
                    Timber.e(loginResult.toString());
                }

                @Override
                public void onCancel() {
                }

                @Override
                public void onError(FacebookException exception) {
                    EventBus.getDefault().post(new EventSnackBar().withMessage(getString(R.string.error_facebook_connection)));
                }
            });
}
项目:android-oss    文件:LoginToutViewModel.java   
private void registerFacebookCallback() {
  final PublishSubject<String> fbAccessToken = this.facebookAccessToken;
  final BehaviorSubject<FacebookException> fbAuthError = this.facebookAuthorizationError;

  this.callbackManager = CallbackManager.Factory.create();

  LoginManager.getInstance().registerCallback(this.callbackManager, new FacebookCallback<LoginResult>() {
    @Override
    public void onSuccess(final @NonNull LoginResult result) {
      fbAccessToken.onNext(result.getAccessToken().getToken());
    }

    @Override
    public void onCancel() {
      // continue
    }

    @Override
    public void onError(final @NonNull FacebookException error) {
      if (error instanceof FacebookAuthorizationException) {
        fbAuthError.onNext(error);
      }
    }
  });
}
项目:aptoide-client-v8    文件:AddressBookFragment.java   
private void registerFacebookCallback() {
  LoginManager.getInstance()
      .registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override public void onSuccess(LoginResult loginResult) {
          FacebookModel facebookModel = createFacebookModel(loginResult);
          mActionsListener.syncFacebook(facebookModel);
        }

        @Override public void onCancel() {
        }

        @Override public void onError(FacebookException error) {
          Logger.e(this.getClass()
              .getName(), error.getMessage());
        }
      });
}
项目:aptoide-client-v8    文件:AccountNavigator.java   
public void navigateToFacebookSignUpForResult(Collection<String> permissions) {
  facebookLoginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
    @Override public void onSuccess(LoginResult loginResult) {
      facebookLoginSubject.call(
          new FacebookLoginResult(loginResult, FacebookLoginResult.STATE_SUCCESS, null));
    }

    @Override public void onCancel() {
      facebookLoginSubject.call(
          new FacebookLoginResult(null, FacebookLoginResult.STATE_CANCELLED, null));
    }

    @Override public void onError(FacebookException error) {
      facebookLoginSubject.call(
          new FacebookLoginResult(null, FacebookLoginResult.STATE_ERROR, error));
    }
  });
  facebookLoginManager.logInWithReadPermissions(activityNavigator.getActivity(), permissions);
}
项目:RxLogin    文件:FacebookSubscriber.java   
@Override public void subscribe(FlowableEmitter<LoginResult> emitter) throws Exception {
    mCallback = new FacebookCallback<LoginResult>() {
        @Override public void onSuccess(LoginResult result) {
            if (!emitter.isCancelled()) {
                emitter.onNext(result);
                emitter.onComplete();
            }
        }

        @Override public void onCancel() {
            if (!emitter.isCancelled()) {
                emitter.onError(new LoginException(LoginException.LOGIN_CANCELED));
            }
        }

        @Override public void onError(FacebookException error) {
            if (!emitter.isCancelled()) {
                emitter.onError(new LoginException(LoginException.FACEBOOK_ERROR, error));
            }
        }
    };
    mRxLogin.registerCallback(mCallback);
}
项目:SplitApp    文件:LoginActivity.java   
private void addLoginButton() {
    LoginButton loginButton = (LoginButton) this.findViewById(R.id.login_button);
    loginButton.setReadPermissions(Arrays.asList("email", "user_friends",
            "public_profile", "user_birthday"));
    loginButton.registerCallback(fbCallbackManager, new FacebookCallback<LoginResult>() {

        private ProfileTracker mProfileTracker;

        @Override
        public void onSuccess(LoginResult loginResult) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
项目:zum-android    文件:SignUpActivity.java   
private void registerCallback() {
    LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            getUserEmail(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Snackbar.make(mRootView, R.string.facebook_cancel, Snackbar.LENGTH_SHORT).show();
        }

        @Override
        public void onError(FacebookException error) {
            Snackbar.make(mRootView, error.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show();
        }
    });
}
项目:FastFoodFinder    文件:LoginActivity.java   
private CallbackManager setupFacebookSignIn() {
    CallbackManager callbackManager = CallbackManager.Factory.create();
    fbSignInButton.setReadPermissions("email", "public_profile");

    fbSignInButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d("MAPP", "facebook:onSuccess: " + loginResult);
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Log.d("MAPP", "facebook:onCancel");
            // ...
        }

        @Override
        public void onError(FacebookException error) {
            Log.d("MAPP", "facebook:onError", error);
            // ...
        }
    });

    return callbackManager;
}
项目:FirebaseAuthExample    文件:LoginActivity.java   
@Override
public void initFbLoginButton() {
    mCallbackManager = CallbackManager.Factory.create();
    mLoginFbButton.setReadPermissions("email", "public_profile");
    mLoginFbButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Timber.d("facebook:onSuccess:" + loginResult);
            mPresenter.handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Timber.d("facebook:onCancel");
        }

        @Override
        public void onError(FacebookException error) {
            Timber.d("facebook:onError", error);
        }
    });
}
项目:Focus-Android-App    文件:LoginActivity.java   
protected void getLoginDetails(LoginButton login_button) {

        // Callback registration
        login_button.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult login_result) {
                getUserInfo(login_result);
            }

            @Override
            public void onCancel() {
                // code for cancellation
            }

            @Override
            public void onError(FacebookException exception) {
                //  code to handle error
            }
        });
    }
项目:Komica    文件:ThirdPartyManager.java   
private void registerFacebookCallback() {
    LoginManager.getInstance().registerCallback(FacebookManager.getInstance().getCallbackManager(), new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            fetchProfile();
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
        }
    });
}
项目:bachamada    文件:FacebookShare.java   
private void initFB() {
    FacebookSdk.sdkInitialize(mContext);
    callbackManager = CallbackManager.Factory.create();
    mShareDialog = new ShareDialog(mContext);
    // this part is optional
    mShareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:Move-Alarm_ORCA    文件: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();
    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(),
            "/me/feed",
            parameters,
            HttpMethod.POST,
            requestCallback).executeAsync();
}
项目:Move-Alarm_ORCA    文件:JoinAppGroupDialog.java   
@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);
}
项目:Move-Alarm_ORCA    文件:CreateAppGroupDialog.java   
@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);
}
项目:Move-Alarm_ORCA    文件:LoginManager.java   
/**
 * Registers a login callback to the given callback manager.
 * @param callbackManager The callback manager that will encapsulate the callback.
 * @param callback The login callback that will be called on login completion.
 */
public void registerCallback(
        final CallbackManager callbackManager,
        final FacebookCallback<LoginResult> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }
    ((CallbackManagerImpl) callbackManager).registerCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(
                            resultCode,
                            data,
                            callback);
                }
            }
    );
}