Search in sources :

Example 6 with Session

use of com.facebook.Session in project openkit-android by OpenKit.

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 7 with Session

use of com.facebook.Session in project Klyph by jonathangerbaud.

the class ImageFragment 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;
}
Also used : KlyphSession(com.abewy.android.apps.klyph.core.KlyphSession) Session(com.facebook.Session)

Example 8 with Session

use of com.facebook.Session in project Klyph by jonathangerbaud.

the class PostPhotosActivity method handlePublishPost.

private void handlePublishPost() {
    pendingAnnounce = false;
    Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingAnnounce = true;
        requestPublishPermissions(this, PERMISSIONS);
        return;
    }
    publishPhotos();
}
Also used : Session(com.facebook.Session)

Example 9 with Session

use of com.facebook.Session in project Klyph by jonathangerbaud.

the class PreferencesActivity method handleSetNotifications.

private void handleSetNotifications() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    @SuppressWarnings("deprecation") CheckBoxPreference cpref = (CheckBoxPreference) findPreference("preference_notifications");
    pendingAnnounce = false;
    final Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingAnnounce = true;
        editor.putBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS, false);
        editor.commit();
        cpref.setChecked(false);
        AlertUtil.showAlert(this, R.string.preferences_notifications_permissions_title, R.string.preferences_notifications_permissions_message, R.string.ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                requestPublishPermissions(session);
            }
        }, R.string.cancel, null);
        return;
    }
    editor.putBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS, true);
    editor.commit();
    cpref.setChecked(true);
    startOrStopNotificationsServices();
    if (sharedPreferences.getBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS_BIRTHDAY, false) == true)
        KlyphService.startBirthdayService();
}
Also used : SharedPreferences(android.content.SharedPreferences) CheckBoxPreference(android.preference.CheckBoxPreference) DialogInterface(android.content.DialogInterface) Session(com.facebook.Session)

Example 10 with Session

use of com.facebook.Session in project Klyph by jonathangerbaud.

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)

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