Search in sources :

Example 26 with Session

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();
        }
    }
}
Also used : SessionState(com.facebook.SessionState) SessionTracker(com.facebook.internal.SessionTracker) FacebookException(com.facebook.FacebookException) Session(com.facebook.Session)

Example 27 with Session

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);
            }
        }
    }
}
Also used : Session(com.facebook.Session)

Example 28 with Session

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);
    }
}
Also used : Session(com.facebook.Session)

Example 29 with Session

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;
}
Also used : Session(com.facebook.Session)

Example 30 with Session

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;
        }
    }
}
Also used : List(java.util.List) SpannableString(android.text.SpannableString) KlyphSession(com.abewy.android.apps.klyph.core.KlyphSession) Session(com.facebook.Session)

Aggregations

Session (com.facebook.Session)47 KlyphSession (com.abewy.android.apps.klyph.core.KlyphSession)16 Response (com.facebook.Response)6 FacebookException (com.facebook.FacebookException)5 Request (com.facebook.Request)5 GraphUser (com.facebook.model.GraphUser)5 FacebookAuthorizationException (com.facebook.FacebookAuthorizationException)4 FacebookOperationCanceledException (com.facebook.FacebookOperationCanceledException)4 SessionState (com.facebook.SessionState)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 JSONException (org.json.JSONException)4 Bundle (android.os.Bundle)3 SpannableString (android.text.SpannableString)3 FacebookDialogException (com.facebook.FacebookDialogException)3 FacebookServiceException (com.facebook.FacebookServiceException)3 GraphUserCallback (com.facebook.Request.GraphUserCallback)3 FacebookRequestError (com.facebook.FacebookRequestError)2 GraphUserListCallback (com.facebook.Request.GraphUserListCallback)2 SessionTracker (com.facebook.internal.SessionTracker)2 GraphObject (com.facebook.model.GraphObject)2