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));
}
}
}
}
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));
}
Aggregations