com.facebook.internal.CallbackManagerImpl Java Examples

The following examples show how to use com.facebook.internal.CallbackManagerImpl. 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: ShareInternalUtility.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
public static void registerStaticShareCallback(
        final int requestCode) {
    CallbackManagerImpl.registerStaticCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(null));
                }
            }
    );
}
 
Example #2
Source File: ShareInternalUtility.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
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));
                }
            });
}
 
Example #3
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 #4
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 #5
Source File: LoginManager.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
                }
            }
    );
}
 
Example #6
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 #7
Source File: LikeActionController.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private synchronized static void performFirstInitialize() {
    if (isInitialized) {
        return;
    }

    handler = new Handler(Looper.getMainLooper());

    Context appContext = FacebookSdk.getApplicationContext();
    SharedPreferences sharedPreferences = appContext.getSharedPreferences(
            LIKE_ACTION_CONTROLLER_STORE,
            Context.MODE_PRIVATE);

    objectSuffix = sharedPreferences.getInt(LIKE_ACTION_CONTROLLER_STORE_OBJECT_SUFFIX_KEY, 1);
    controllerDiskCache = new FileLruCache(TAG, new FileLruCache.Limits());

    registerAccessTokenTracker();

    CallbackManagerImpl.registerStaticCallback(
            CallbackManagerImpl.RequestCodeOffset.Like.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleOnActivityResult(
                            CallbackManagerImpl.RequestCodeOffset.Like.toRequestCode(),
                            resultCode,
                            data);
                }
            });

    isInitialized = true;
}
 
Example #8
Source File: ShareDialog.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) {
    ShareInternalUtility.registerSharerCallback(
            getRequestCode(), callbackManager, callback);
}
 
Example #9
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 #10
Source File: LoginManager.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private void startLogin(
        StartActivityDelegate startActivityDelegate,
        LoginClient.Request request
) throws FacebookException {

    logStartLogin(startActivityDelegate.getActivityContext(), request);

    // Make sure the static handler for login is registered if there isn't an explicit callback
    CallbackManagerImpl.registerStaticCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(resultCode, data);
                }
            }
    );

    boolean started = tryFacebookActivity(startActivityDelegate, request);

    if (!started) {
        FacebookException exception = new FacebookException(
                "Log in attempt failed: FacebookActivity could not be started." +
                        " Please make sure you added FacebookActivity to the AndroidManifest.");
        boolean wasLoginActivityTried = false;
        logCompleteLogin(
                startActivityDelegate.getActivityContext(),
                LoginClient.Result.Code.ERROR,
                null,
                exception,
                wasLoginActivityTried,
                request);
        throw exception;
    }
}
 
Example #11
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Singleton @Provides CallbackManager provideCallbackManager() {
  return new CallbackManagerImpl();
}
 
Example #12
Source File: CallbackManager.java    From letv with Apache License 2.0 4 votes vote down vote up
public static CallbackManager create() {
    return new CallbackManagerImpl();
}
 
Example #13
Source File: LoginButton.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
@Override
protected int getDefaultRequestCode() {
    return CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode();
}
 
Example #14
Source File: LoginClient.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
public static int getLoginRequestCode() {
    return CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode();
}
 
Example #15
Source File: SendButton.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
@Override
protected int getDefaultRequestCode() {
    return CallbackManagerImpl.RequestCodeOffset.Message.toRequestCode();
}
 
Example #16
Source File: ShareButton.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
@Override
protected int getDefaultRequestCode() {
    return CallbackManagerImpl.RequestCodeOffset.Share.toRequestCode();
}
 
Example #17
Source File: MessageDialog.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
@Override
protected void registerCallbackImpl(
        final CallbackManagerImpl callbackManager,
        final FacebookCallback<Result> callback) {
    ShareInternalUtility.registerSharerCallback(getRequestCode(), callbackManager, callback);
}
 
Example #18
Source File: CallbackManager.java    From kognitivo with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an instance of {@link com.facebook.CallbackManager}.
 * @return an instance of {@link com.facebook.CallbackManager}.
 */
public static CallbackManager create() {
    return new CallbackManagerImpl();
}