use of com.android.tools.build.bundletool.model.targeting.ScreenDensitySelector in project bundletool by google.
the class ScreenDensityMatcher method matchesTargeting.
@Override
public boolean matchesTargeting(ScreenDensityTargeting targeting) {
ImmutableList<ScreenDensity> allDensities = ImmutableList.<ScreenDensity>builder().addAll(targeting.getValueList()).addAll(targeting.getAlternativesList()).build();
if (allDensities.isEmpty()) {
return true;
}
int bestMatchingDensity = new ScreenDensitySelector().selectBestDensity(Iterables.transform(allDensities, ResourcesUtils::convertToDpi), getDeviceSpec().getScreenDensity());
return targeting.getValueList().stream().map(ResourcesUtils::convertToDpi).anyMatch(isEqual(bestMatchingDensity));
}
Aggregations