Search in sources :

Example 1 with ScreenDensitySelector

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));
}
Also used : ScreenDensitySelector(com.android.tools.build.bundletool.model.targeting.ScreenDensitySelector) ScreenDensity(com.android.bundle.Targeting.ScreenDensity)

Aggregations

ScreenDensity (com.android.bundle.Targeting.ScreenDensity)1 ScreenDensitySelector (com.android.tools.build.bundletool.model.targeting.ScreenDensitySelector)1