Java 类com.facebook.Session.Builder 实例源码

项目:QuizUpWinner    文件:FacebookFragment.java   
private void openSession(String paramString, List<String> paramList, SessionLoginBehavior paramSessionLoginBehavior, int paramInt, SessionAuthorizationType paramSessionAuthorizationType)
{
  if (this.sessionTracker != null)
  {
    Session localSession1 = this.sessionTracker.getSession();
    Object localObject = localSession1;
    if ((localSession1 == null) || (((Session)localObject).getState().isClosed()))
    {
      Session localSession2 = new Session.Builder(getActivity()).setApplicationId(paramString).build();
      Session.setActiveSession(localSession2);
      localObject = localSession2;
    }
    if (!((Session)localObject).isOpened())
    {
      Session.OpenRequest localOpenRequest = new Session.OpenRequest(this).setPermissions(paramList).setLoginBehavior(paramSessionLoginBehavior).setRequestCode(paramInt);
      if (SessionAuthorizationType.PUBLISH.equals(paramSessionAuthorizationType))
      {
        ((Session)localObject).openForPublish(localOpenRequest);
        return;
      }
      ((Session)localObject).openForRead(localOpenRequest);
    }
  }
}
项目:DualRunner    文件:FBLogin.java   
public static void init(String appID) {
    Session session;
    if (FB.isLoggedIn()) {
        session = Session.getActiveSession();
        // this shouldn't be an issue for most people: the app id in the session not matching the one provided
        // instead it can probably happen if a developer wants to switch app ids at run time.
        if (appID != session.getApplicationId()) {
            Log.w(FB.TAG, "App Id in active session ("+ session.getApplicationId() +") doesn't match App Id passed in: " + appID);
            session = new Builder(FB.getUnityActivity()).setApplicationId(appID).build();
        }
    } else {
        session = new Builder(FB.getUnityActivity()).setApplicationId(appID).build();
    }
    Session.setActiveSession(session);

    final UnityMessage unityMessage = new UnityMessage("OnInitComplete");
    unityMessage.put("key_hash", FB.getKeyHash());

    // if there is an existing session, reopen it
    if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState())) {
        Session.StatusCallback finalCallback = getFinalCallback(unityMessage, null);
        sessionOpenRequest(session, finalCallback, FB.getUnityActivity(), null, false);
    } else {
        unityMessage.send();
    }
}
项目:QuizUpWinner    文件:Facebook.java   
private void authorize(Activity paramActivity, String[] paramArrayOfString, int paramInt, SessionLoginBehavior paramSessionLoginBehavior, final DialogListener paramDialogListener)
{
  checkUserSession("authorize");
  this.pendingOpeningSession = new Session.Builder(paramActivity).setApplicationId(this.mAppId).setTokenCachingStrategy(getTokenCache()).build();
  this.pendingAuthorizationActivity = paramActivity;
  String[] arrayOfString;
  if (paramArrayOfString != null)
    arrayOfString = paramArrayOfString;
  else
    arrayOfString = new String[0];
  this.pendingAuthorizationPermissions = arrayOfString;
  Session.StatusCallback local1 = new Session.StatusCallback()
  {
    public void call(Session paramAnonymousSession, SessionState paramAnonymousSessionState, Exception paramAnonymousException)
    {
      Facebook.this.onSessionCallback(paramAnonymousSession, paramAnonymousSessionState, paramAnonymousException, paramDialogListener);
    }
  };
  Session.OpenRequest localOpenRequest = new Session.OpenRequest(paramActivity).setCallback(local1).setLoginBehavior(paramSessionLoginBehavior).setRequestCode(paramInt).setPermissions(Arrays.asList(this.pendingAuthorizationPermissions));
  Session localSession = this.pendingOpeningSession;
  boolean bool;
  if (this.pendingAuthorizationPermissions.length > 0)
    bool = true;
  else
    bool = false;
  openSession(localSession, localOpenRequest, bool);
}
项目:QuizUpWinner    文件:Facebook.java   
@Deprecated
public final Session getSession()
{
  while (true)
  {
    String str;
    Session localSession2;
    synchronized (this.lock)
    {
      if (this.userSetSession != null)
      {
        Session localSession7 = this.userSetSession;
        return localSession7;
      }
      if ((this.session != null) || (!this.sessionInvalidated))
      {
        Session localSession1 = this.session;
        return localSession1;
      }
      str = this.accessToken;
      localSession2 = this.session;
    }
    if (str == null)
      return null;
    List localList;
    if (localSession2 != null)
      localList = localSession2.getPermissions();
    else if (this.pendingAuthorizationPermissions != null)
      localList = Arrays.asList(this.pendingAuthorizationPermissions);
    else
      localList = Collections.emptyList();
    Session localSession3 = new Session.Builder(this.pendingAuthorizationActivity).setApplicationId(this.mAppId).setTokenCachingStrategy(getTokenCache()).build();
    if (localSession3.getState() != SessionState.CREATED_TOKEN_LOADED)
      return null;
    Session.OpenRequest localOpenRequest = new Session.OpenRequest(this.pendingAuthorizationActivity).setPermissions(localList);
    boolean bool;
    if (!localList.isEmpty())
      bool = true;
    else
      bool = false;
    openSession(localSession3, localOpenRequest, bool);
    Session localSession4;
    Session localSession5;
    synchronized (this.lock)
    {
      if (!this.sessionInvalidated)
      {
        Session localSession6 = this.session;
        localSession4 = null;
        localSession5 = null;
        if (localSession6 != null);
      }
      else
      {
        localSession4 = this.session;
        this.session = localSession3;
        localSession5 = localSession3;
        this.sessionInvalidated = false;
      }
    }
    if (localSession4 != null)
      localSession4.close();
    if (localSession5 != null)
      return localSession5;
  }
}
项目:DualRunner    文件:FBLogin.java   
public static void login(String params, final Activity activity) {
    Session session = Session.getActiveSession();
    if (session == null) {
        Log.w(FB.TAG, "Session not found. Call init() before calling login()");
        return;
    }
    // if the old session is closed (or login was cancelled), create new one
    if (session.isClosed()) {
        session = new Builder(FB.getUnityActivity()).setApplicationId(session.getApplicationId()).build();
        Session.setActiveSession(session);
    }
    final UnityMessage unityMessage = new UnityMessage("OnLoginComplete");

    unityMessage.put("key_hash", FB.getKeyHash());

    // parse and separate the permissions into read and publish permissions
    List<String> permissions = new ArrayList<String>();
    UnityParams unity_params = UnityParams.parse(params, "couldn't parse login params: " + params);
    if (unity_params.hasString("scope")) {
        permissions = new ArrayList<String>(Arrays.asList(unity_params.getString("scope").split(",")));
    }
    List<String> publishPermissions = new ArrayList<String>();
    List<String> readPermissions = new ArrayList<String>();
    if(permissions.size() > 0) {
        for(String s:permissions) {
            if(s.length() == 0) {
                continue;
            }
            if(Session.isPublishPermission(s)) {
                publishPermissions.add(s);
            } else {
                readPermissions.add((s));
            }
        }
    }
    boolean hasPublishPermissions = !publishPermissions.isEmpty();

    // check to see if the readPermissions have been TOSed already
    // we don't need to show the readPermissions dialog if they have all been TOSed even though it's a mix
    // of permissions
    boolean showMixedPermissionsFlow = hasPublishPermissions && !session.getPermissions().containsAll(readPermissions);

    // if we're logging in and showing a mix of publish and read permission, we need to split up the dialogs
    // first just show the read permissions, after they are accepted show publish permissions
    if (showMixedPermissionsFlow) {
        Session.StatusCallback afterReadPermissionCallback = getAfterReadPermissionLoginCallback(unityMessage, publishPermissions, activity);
        sessionOpenRequest(session, afterReadPermissionCallback, activity, readPermissions, false);
    } else {
        Session.StatusCallback finalCallback = getFinalCallback(unityMessage, activity);
        sessionOpenRequest(session, finalCallback, activity, permissions, hasPublishPermissions);
    }
}