Java Code Examples for com.android.resources.Density#getEnum()
The following examples show how to use
com.android.resources.Density#getEnum() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Project.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds in the resConfig values specified by the given flavor container, assuming * it's in one of the relevant variantFlavors, into the given set */ private static void addResConfigsFromFlavor(@NonNull Set<String> relevantDensities, @Nullable List<String> variantFlavors, @NonNull ProductFlavorContainer container) { ProductFlavor flavor = container.getProductFlavor(); if (variantFlavors == null || variantFlavors.contains(flavor.getName())) { if (!flavor.getResourceConfigurations().isEmpty()) { for (String densityName : flavor.getResourceConfigurations()) { Density density = Density.getEnum(densityName); if (density != null && density.isRecommended() && density != Density.NODPI && density != Density.ANYDPI) { relevantDensities.add(densityName); } } } } }
Example 2
Source File: IconDetector.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds in the resConfig values specified by the given flavor container, assuming * it's in one of the relevant variantFlavors, into the given set */ private static void addResConfigsFromFlavor(@NonNull Set<String> relevantDensities, @Nullable List<String> variantFlavors, @NonNull ProductFlavorContainer container) { ProductFlavor flavor = container.getProductFlavor(); if (variantFlavors == null || variantFlavors.contains(flavor.getName())) { if (!flavor.getResourceConfigurations().isEmpty()) { for (String densityName : flavor.getResourceConfigurations()) { Density density = Density.getEnum(densityName); if (density != null && density.isRecommended() && density != Density.NODPI && density != Density.ANYDPI) { relevantDensities.add(densityName); } } } } }
Example 3
Source File: DensityQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { Density density = Density.getEnum(value); if (density == null) { // attempt to read a legacy value. Matcher m = sDensityLegacyPattern.matcher(value); if (m.matches()) { String v = m.group(1); try { density = Density.getEnum(Integer.parseInt(v)); } catch (NumberFormatException e) { // looks like the string we extracted wasn't a valid number // which really shouldn't happen since the regexp would have failed. } } } if (density != null) { DensityQualifier qualifier = new DensityQualifier(); qualifier.mValue = density; config.setDensityQualifier(qualifier); return true; } return false; }
Example 4
Source File: PreprocessingOptions.java From javaide with GNU General Public License v3.0 | 5 votes |
public void setDensities(Set<String> densities) { EnumSet<Density> newValue = EnumSet.noneOf(Density.class); for (String density : densities) { Density typedValue = Density.getEnum(density); checkArgument(typedValue != null, "Unrecognized density %s", density); newValue.add(typedValue); } this.densities = newValue; }
Example 5
Source File: DensityQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { Density density = Density.getEnum(value); if (density == null) { // attempt to read a legacy value. Matcher m = sDensityLegacyPattern.matcher(value); if (m.matches()) { String v = m.group(1); try { density = Density.getEnum(Integer.parseInt(v)); } catch (NumberFormatException e) { // looks like the string we extracted wasn't a valid number // which really shouldn't happen since the regexp would have failed. } } } if (density != null) { DensityQualifier qualifier = new DensityQualifier(); qualifier.mValue = density; config.setDensityQualifier(qualifier); return true; } return false; }