use of com.facebook.Session in project facebook-api-android-maven by avianey.
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();
}
}
}
use of com.facebook.Session in project facebook-api-android-maven by avianey.
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 facebook-api-android-maven by avianey.
the class SessionTracker method setSession.
/**
* Set the Session object to track.
*
* @param newSession the new Session object to track
*/
public void setSession(Session newSession) {
if (newSession == null) {
if (session != null) {
// We're current tracking a Session. Remove the callback
// and start tracking the active Session.
session.removeCallback(callback);
session = null;
addBroadcastReceiver();
if (getSession() != null) {
getSession().addCallback(callback);
}
}
} else {
if (session == null) {
// We're currently tracking the active Session, but will be
// switching to tracking a different Session object.
Session activeSession = Session.getActiveSession();
if (activeSession != null) {
activeSession.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
} else {
// We're currently tracking a Session, but are now switching
// to a new Session, so we remove the callback from the old
// Session, and add it to the new one.
session.removeCallback(callback);
}
session = newSession;
session.addCallback(callback);
}
}
use of com.facebook.Session in project Klyph by jonathangerbaud.
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 Klyph by jonathangerbaud.
the class StreamButtonBar method onPermissionsChange.
@Override
public void onPermissionsChange() {
if (pendingLike == true) {
pendingLike = false;
Session session = Session.getActiveSession();
List<String> permissions = session.getPermissions();
if (permissions.containsAll(PERMISSIONS)) {
handleLikeAction(pendingHolder, pendingStream, pendingSubStream);
pendingHolder = null;
pendingStream = null;
pendingSubStream = null;
}
} else if (pendingDelete == true) {
pendingDelete = false;
Session session = Session.getActiveSession();
List<String> permissions = session.getPermissions();
if (permissions.containsAll(PERMISSIONS)) {
handleDeleteAction(pendingHolder, pendingStream);
pendingHolder = null;
pendingStream = null;
pendingSubStream = null;
}
}
}
Aggregations