Search in sources :

Example 11 with Session

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

the class LoginButton method fetchUserInfo.

private void fetchUserInfo() {
    if (fetchUserInfo) {
        final Session currentSession = sessionTracker.getOpenSession();
        if (currentSession != null) {
            if (currentSession != userInfoSession) {
                Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser me, Response response) {
                        if (currentSession == sessionTracker.getOpenSession()) {
                            user = me;
                            if (userInfoChangedCallback != null) {
                                userInfoChangedCallback.onUserInfoFetched(user);
                            }
                        }
                        if (response.getError() != null) {
                            handleError(response.getError().getException());
                        }
                    }
                });
                Request.executeBatchAsync(request);
                userInfoSession = currentSession;
            }
        } else {
            user = null;
            if (userInfoChangedCallback != null) {
                userInfoChangedCallback.onUserInfoFetched(user);
            }
        }
    }
}
Also used : Response(com.facebook.Response) GraphUser(com.facebook.model.GraphUser) Request(com.facebook.Request) Session(com.facebook.Session)

Example 12 with Session

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

the class LoginButton method initializeActiveSessionWithCachedToken.

private boolean initializeActiveSessionWithCachedToken(Context context) {
    if (context == null) {
        return false;
    }
    Session session = Session.getActiveSession();
    if (session != null) {
        return session.isOpened();
    }
    String applicationId = Utility.getMetadataApplicationId(context);
    if (applicationId == null) {
        return false;
    }
    return Session.openActiveSessionFromCache(context) != null;
}
Also used : Session(com.facebook.Session)

Example 13 with Session

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

the class UserTimeline method handleNewPostClick.

private void handleNewPostClick() {
    pendingAnnounce = false;
    Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingAnnounce = true;
        ((IFbPermissionWorker) getActivity()).requestPublishPermissions(this, PERMISSIONS);
        return;
    }
    if (getIntentParam() == KlyphBundleExtras.USER_ID) {
        if (getElementId().equals(KlyphSession.getSessionUserId())) {
            Intent intent = new Intent(getActivity(), PostActivity.class);
            intent.putExtra(getIntentParam(), getElementId());
            startActivityForResult(intent, POST_CODE);
        } else {
            publishFeedDialog();
        }
    } else {
        Intent intent = new Intent(getActivity(), PostActivity.class);
        intent.putExtra(getIntentParam(), getElementId());
        startActivityForResult(intent, POST_CODE);
    }
}
Also used : IFbPermissionWorker(com.abewy.android.apps.klyph.facebook.IFbPermissionWorker) Intent(android.content.Intent) KlyphSession(com.abewy.android.apps.klyph.core.KlyphSession) Session(com.facebook.Session)

Example 14 with Session

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

the class StreamFragment method handleDeleteCommentAction.

private void handleDeleteCommentAction(Comment comment) {
    pendingDeleteComment = false;
    pendingComment = comment;
    Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingDeleteComment = true;
        requestPublishPermissions(session);
        return;
    }
    askDeleteComment(comment);
    pendingComment = null;
}
Also used : KlyphSession(com.abewy.android.apps.klyph.core.KlyphSession) Session(com.facebook.Session)

Example 15 with Session

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

the class StreamFragment method handleDeleteAction.

private void handleDeleteAction() {
    pendingDelete = false;
    Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingDelete = true;
        requestPublishPermissions(session);
        return;
    }
    askDelete();
}
Also used : 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