Class ResourceFilters


  • public class ResourceFilters
    extends Object
    • Field Detail

      • SUPPORTED_RESOURCE_DIRECTORIES

        public static final com.google.common.collect.ImmutableSet<String> SUPPORTED_RESOURCE_DIRECTORIES
        The set of supported directories in resource folders. This is defined in http://developer.android.com/guide/topics/resources/providing-resources.html#table1
    • Method Detail

      • createImageDensityFilter

        public static java.util.function.Predicate<Path> createImageDensityFilter​(Collection<Path> candidates,
                                                                                  Set<ResourceFilters.Density> targetDensities,
                                                                                  boolean canDownscale)
        Given a list of paths of available drawables, and a target screen density, returns a Predicate that fails for drawables of a different density, whenever they can be safely removed.
        Parameters:
        candidates - list of available drawables
        targetDensities - set of e.g. "mdpi", "ldpi" etc.
        canDownscale - if no exact match is available, retain the highest quality
        Returns:
        a predicate as above
      • createDensityFilter

        public static java.util.function.Predicate<Path> createDensityFilter​(ProjectFilesystem filesystem,
                                                                             Set<ResourceFilters.Density> targetDensities)
        Given a set of target densities, returns a Predicate that fails for any non-drawable resource of a different density. Special consideration exists for the default density (ResourceFilters.Density.NO_QUALIFIER when the target does not exists.