Java Code Examples for com.facebook.internal.Utility#isSubset()

The following examples show how to use com.facebook.internal.Utility#isSubset() . 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 Abelana-Android with Apache License 2.0 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: LoginButton.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 3
Source File: LoginButton.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 4
Source File: LoginButton.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 5
Source File: LoginButton.java    From KlyphMessenger with MIT License 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 6
Source File: LoginButton.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 7
Source File: LoginButton.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 8
Source File: LoginButton.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 9
Source File: LoginButton.java    From android-skeleton-project with MIT License 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 10
Source File: LoginButton.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 11
Source File: LoginButton.java    From Klyph with MIT License 5 votes vote down vote up
private boolean validatePermissions(List<String> permissions,
        SessionAuthorizationType authType, Session currentSession) {
    if (SessionAuthorizationType.PUBLISH.equals(authType)) {
        if (Utility.isNullOrEmpty(permissions)) {
            throw new IllegalArgumentException("Permissions for publish actions cannot be null or empty.");
        }
    }
    if (currentSession != null && currentSession.isOpened()) {
        if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
            Log.e(TAG, "Cannot set additional permissions when session is already open.");
            return false;
        }
    }
    return true;
}
 
Example 12
Source File: Session.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingRequest = openRequest;
                    }
                }
                if (pendingRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}
 
Example 13
Source File: Session.java    From Abelana-Android with Apache License 2.0 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingAuthorizationRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingAuthorizationRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingAuthorizationRequest = openRequest;
                    }
                }
                if (pendingAuthorizationRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}
 
Example 14
Source File: Session.java    From KlyphMessenger with MIT License 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingAuthorizationRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingAuthorizationRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingAuthorizationRequest = openRequest;
                    }
                }
                if (pendingAuthorizationRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}
 
Example 15
Source File: Session.java    From facebook-api-android-maven with Apache License 2.0 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingAuthorizationRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingAuthorizationRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingAuthorizationRequest = openRequest;
                    }
                }
                if (pendingAuthorizationRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}
 
Example 16
Source File: Session.java    From HypFacebook with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingRequest = openRequest;
                    }
                }
                if (pendingRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}
 
Example 17
Source File: Session.java    From FacebookNewsfeedSample-Android with Apache License 2.0 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingRequest = openRequest;
                    }
                }
                if (pendingRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}
 
Example 18
Source File: Session.java    From Klyph with MIT License 4 votes vote down vote up
private void open(OpenRequest openRequest, SessionAuthorizationType authType) {
    validatePermissions(openRequest, authType);
    validateLoginBehavior(openRequest);

    SessionState newState;
    synchronized (this.lock) {
        if (pendingAuthorizationRequest != null) {
            postStateChange(state, state, new UnsupportedOperationException(
                    "Session: an attempt was made to open a session that has a pending request."));
            return;
        }
        final SessionState oldState = this.state;

        switch (this.state) {
            case CREATED:
                this.state = newState = SessionState.OPENING;
                if (openRequest == null) {
                    throw new IllegalArgumentException("openRequest cannot be null when opening a new Session");
                }
                pendingAuthorizationRequest = openRequest;
                break;
            case CREATED_TOKEN_LOADED:
                if (openRequest != null && !Utility.isNullOrEmpty(openRequest.getPermissions())) {
                    if (!Utility.isSubset(openRequest.getPermissions(), getPermissions())) {
                        pendingAuthorizationRequest = openRequest;
                    }
                }
                if (pendingAuthorizationRequest == null) {
                    this.state = newState = SessionState.OPENED;
                } else {
                    this.state = newState = SessionState.OPENING;
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Session: an attempt was made to open an already opened session.");
        }
        if (openRequest != null) {
            addCallback(openRequest.getCallback());
        }
        this.postStateChange(oldState, newState, null);
    }

    if (newState == SessionState.OPENING) {
        authorize(openRequest);
    }
}