Search in sources :

Example 1 with ResourceQualifier

use of com.android.ide.common.resources.configuration.ResourceQualifier in project android by JetBrains.

the class RestrictedEnum method setRestrictions.

@Override
public void setRestrictions(@Nullable ResourceQualifier compatible, @NotNull Collection<ResourceQualifier> incompatibles) {
    if (ResourceQualifier.isValid(compatible)) {
        myPossibleValues.clear();
        //noinspection unchecked
        myPossibleValues.addAll((Collection) Collections.singletonList(getValue(compatible)));
    } else {
        for (ResourceQualifier qualifier : incompatibles) {
            if (qualifier.isValid()) {
                myPossibleValues.remove(getValue(qualifier));
            }
        }
    }
}
Also used : ResourceQualifier(com.android.ide.common.resources.configuration.ResourceQualifier)

Example 2 with ResourceQualifier

use of com.android.ide.common.resources.configuration.ResourceQualifier in project android by JetBrains.

the class RestrictedEnumTest method testIntersect.

/**
   * Tests {@link RestrictedEnum#intersect(RestrictedQualifier)}
   */
public void testIntersect() {
    RestrictedEnum first = new RestrictedEnum(KeyboardState.class);
    RestrictedEnum second = new RestrictedEnum(KeyboardState.class);
    ResourceQualifier exposed = new KeyboardStateQualifier(KeyboardState.EXPOSED);
    ResourceQualifier hidden = new KeyboardStateQualifier(KeyboardState.HIDDEN);
    ResourceQualifier soft = new KeyboardStateQualifier(KeyboardState.SOFT);
    first.setRestrictions(null, ImmutableList.of(exposed));
    second.setRestrictions(null, ImmutableList.of(hidden));
    RestrictedEnum result = (RestrictedEnum) first.intersect(second);
    assertNotNull(result);
    assert result.isMatchFor(soft);
    assert !result.isMatchFor(exposed);
    assert !result.isMatchFor(hidden);
    first = new RestrictedEnum(KeyboardState.class);
    second = new RestrictedEnum(KeyboardState.class);
    first.setRestrictions(null, ImmutableList.of(exposed, hidden));
    second.setRestrictions(null, ImmutableList.of(soft));
    assertNull(first.intersect(second));
}
Also used : ResourceQualifier(com.android.ide.common.resources.configuration.ResourceQualifier) KeyboardState(com.android.resources.KeyboardState) KeyboardStateQualifier(com.android.ide.common.resources.configuration.KeyboardStateQualifier)

Aggregations

ResourceQualifier (com.android.ide.common.resources.configuration.ResourceQualifier)2 KeyboardStateQualifier (com.android.ide.common.resources.configuration.KeyboardStateQualifier)1 KeyboardState (com.android.resources.KeyboardState)1