use of com.facebook.Session in project Klyph by jonathangerbaud.
the class StreamFragment method handleLikeCommentAction.
private void handleLikeCommentAction(final Comment comment) {
pendingLikeComment = false;
pendingCommentLike = comment;
Session session = Session.getActiveSession();
List<String> permissions = session.getPermissions();
if (!permissions.containsAll(PERMISSIONS)) {
pendingLikeComment = true;
requestPublishPermissions(session);
return;
}
doLikeCommentAction(comment);
pendingLikeComment = false;
}
use of com.facebook.Session 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.Session in project phonegap-facebook-plugin by Wizcorp.
the class FacebookFragment method openSession.
private void openSession(String applicationId, List<String> permissions, SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) {
if (sessionTracker != null) {
Session currentSession = sessionTracker.getSession();
if (currentSession == null || currentSession.getState().isClosed()) {
Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build();
Session.setActiveSession(session);
currentSession = session;
}
if (!currentSession.isOpened()) {
Session.OpenRequest openRequest = new Session.OpenRequest(this).setPermissions(permissions).setLoginBehavior(behavior).setRequestCode(activityCode);
if (SessionAuthorizationType.PUBLISH.equals(authType)) {
currentSession.openForPublish(openRequest);
} else {
currentSession.openForRead(openRequest);
}
}
}
}
use of com.facebook.Session in project phonegap-facebook-plugin by Wizcorp.
the class SessionTracker method stopTracking.
/**
* Stop tracking the Session and remove any callbacks attached
* to those sessions.
*/
public void stopTracking() {
if (!isTracking) {
return;
}
Session session = getSession();
if (session != null) {
session.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
isTracking = false;
}
use of com.facebook.Session in project phonegap-facebook-plugin by Wizcorp.
the class PickerFragment method onActivityCreated.
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
sessionTracker = new SessionTracker(getActivity(), new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (!session.isOpened()) {
// When a session is closed, we want to clear out our data so it is not visible to subsequent users
clearResults();
}
}
});
setSettingsFromBundle(savedInstanceState);
loadingStrategy = createLoadingStrategy();
loadingStrategy.attach(adapter);
selectionStrategy = createSelectionStrategy();
selectionStrategy.readSelectionFromBundle(savedInstanceState, SELECTION_BUNDLE_KEY);
// Should we display a title bar? (We need to do this after we've retrieved our bundle settings.)
if (showTitleBar) {
inflateTitleBar((ViewGroup) getView());
}
if (activityCircle != null && savedInstanceState != null) {
boolean shown = savedInstanceState.getBoolean(ACTIVITY_CIRCLE_SHOW_KEY, false);
if (shown) {
displayActivityCircle();
} else {
// Should be hidden already, but just to be sure.
hideActivityCircle();
}
}
}
Aggregations