com.facebook.internal.SessionTracker Java Examples

The following examples show how to use com.facebook.internal.SessionTracker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginButton.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #2
Source File: PickerFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example #3
Source File: LoginButton.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #4
Source File: PickerFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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();
        }
    }
}
 
Example #5
Source File: LoginButton.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #6
Source File: PickerFragment.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example #7
Source File: LoginButton.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
private void finishInit() {
    super.setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #8
Source File: PickerFragment.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@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();
        }
    }
}
 
Example #9
Source File: LoginButton.java    From KlyphMessenger with MIT License 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #10
Source File: PickerFragment.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example #11
Source File: LoginButton.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
private void finishInit() {
    super.setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #12
Source File: PickerFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example #13
Source File: LoginButton.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #14
Source File: SessionTrackerTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@SmallTest
@MediumTest
@LargeTest
// Tests the SessionDelegate while tracking a passed in session from the constructor
public void testDelegateWithSessionInConstructor() throws Exception {
    final SessionStatusCallbackRecorder statusRecorder =
            new SessionStatusCallbackRecorder();
    final MockTokenCachingStrategy cache = new MockTokenCachingStrategy(null, 0);
    final ScriptedSession session =
            createScriptedSessionOnBlockerThread(cache);

    session.addAuthorizeResult(TOKEN_STR, Collections.<String>emptyList(), AccessTokenSource.TEST_USER);

    SessionTracker tracker = new SessionTracker(getActivity(), statusRecorder, session);

    session.openForRead(new Session.OpenRequest(getActivity()));

    statusRecorder.waitForCall(session, SessionState.OPENING, null);
    statusRecorder.waitForCall(session, SessionState.OPENED, null);
    assertNotNull("Session should be open", tracker.getOpenSession());
    assertEquals("Access Token check", TOKEN_STR, tracker.getOpenSession().getAccessToken());
    tracker.getOpenSession().close();
    statusRecorder.waitForCall(session, SessionState.CLOSED, null);

    stall(STRAY_CALLBACK_WAIT_MILLISECONDS);
    tracker.stopTracking();
    statusRecorder.close();
}
 
Example #15
Source File: SessionTrackerTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@SmallTest
@MediumTest
@LargeTest
// Tests the SessionDelegate while tracking the active session
public void testDelegateWithActiveSession() throws Exception {
    Session.setActiveSession(null);
    final SessionStatusCallbackRecorder statusRecorder =
            new SessionStatusCallbackRecorder();
    final MockTokenCachingStrategy cache = new MockTokenCachingStrategy(null, 0);
    final ScriptedSession session =
            createScriptedSessionOnBlockerThread(cache);

    session.addAuthorizeResult(TOKEN_STR, Collections.<String>emptyList(), AccessTokenSource.TEST_USER);

    final SessionTracker tracker = new SessionTracker(getActivity(), statusRecorder);
    Session.setActiveSession(session);

    session.openForRead(new Session.OpenRequest(getActivity()));

    statusRecorder.waitForCall(session, SessionState.OPENING, null);
    statusRecorder.waitForCall(session, SessionState.OPENED, null);
    assertNotNull("Session should be open", tracker.getOpenSession());
    assertEquals("Access Token check", TOKEN_STR, tracker.getOpenSession().getAccessToken());
    tracker.getOpenSession().close();
    statusRecorder.waitForCall(session, SessionState.CLOSED, null);

    stall(STRAY_CALLBACK_WAIT_MILLISECONDS);
    tracker.stopTracking();
    statusRecorder.close();
}
 
Example #16
Source File: LoginButton.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private void finishInit() {
    super.setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #17
Source File: PickerFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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();
        }
    }
}
 
Example #18
Source File: LoginButton.java    From Klyph with MIT License 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #19
Source File: PickerFragment.java    From Klyph with MIT License 5 votes vote down vote up
@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();
        }
    }
}
 
Example #20
Source File: LoginButton.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
private void finishInit() {
    setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #21
Source File: PickerFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example #22
Source File: LoginButton.java    From android-skeleton-project with MIT License 5 votes vote down vote up
private void finishInit() {
    super.setOnClickListener(new LoginClickListener());
    setButtonText();
    if (!isInEditMode()) {
        sessionTracker = new SessionTracker(getContext(), new LoginButtonCallback(), null, false);
        fetchUserInfo();
    }
}
 
Example #23
Source File: PickerFragment.java    From android-skeleton-project with MIT License 5 votes vote down vote up
@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();
        }
    }
}
 
Example #24
Source File: PickerFragment.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@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();
        }
    }
}
 
Example #25
Source File: FacebookFragment.java    From Abelana-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    sessionTracker = new SessionTracker(getActivity(), new DefaultSessionStatusCallback());
}
 
Example #26
Source File: FacebookFragment.java    From android-skeleton-project with MIT License 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    sessionTracker = new SessionTracker(getActivity(), new DefaultSessionStatusCallback());
}
 
Example #27
Source File: FacebookFragment.java    From KlyphMessenger with MIT License 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    sessionTracker = new SessionTracker(getActivity(), new DefaultSessionStatusCallback());
}
 
Example #28
Source File: FacebookFragment.java    From FacebookImageShareIntent with MIT License 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    sessionTracker = new SessionTracker(getActivity(), new DefaultSessionStatusCallback());
}
 
Example #29
Source File: FacebookFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    sessionTracker = new SessionTracker(getActivity(), new DefaultSessionStatusCallback());
}
 
Example #30
Source File: FacebookFragment.java    From facebook-api-android-maven with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    sessionTracker = new SessionTracker(getActivity(), new DefaultSessionStatusCallback());
}