com.android.ide.common.resources.configuration.FolderConfiguration Java Examples

The following examples show how to use com.android.ide.common.resources.configuration.FolderConfiguration. 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: ResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the {@link ResourceFile} matching the given name,
 * {@link ResourceFolderType} and configuration.
 * <p/>
 * This only works with files generating one resource named after the file
 * (for instance, layouts, bitmap based drawable, xml, anims).
 *
 * @param name the resource name or file name
 * @param type the folder type search for
 * @param config the folder configuration to match for
 * @return the matching file or <code>null</code> if no match was found.
 */
@Nullable
public ResourceFile getMatchingFile(
        @NonNull String name,
        @NonNull ResourceFolderType type,
        @NonNull FolderConfiguration config) {
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(type);
    for (ResourceType t : types) {
        if (t == ResourceType.ID) {
            continue;
        }
        ResourceFile match = getMatchingFile(name, t, config);
        if (match != null) {
            return match;
        }
    }

    return null;
}
 
Example #2
Source File: AbstractResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resources values matching a given {@link FolderConfiguration}.
 *
 * @param referenceConfig the configuration that each value must match.
 * @return a map with guaranteed to contain an entry for each {@link ResourceType}
 */
@NonNull
public Map<ResourceType, Map<String, ResourceValue>> getConfiguredResources(
        @NonNull FolderConfiguration referenceConfig) {
    Map<ResourceType, Map<String, ResourceValue>> map = Maps.newEnumMap(ResourceType.class);

    synchronized (ITEM_MAP_LOCK) {
        Map<ResourceType, ListMultimap<String, ResourceItem>> itemMap = getMap();
        for (ResourceType key : ResourceType.values()) {
            // get the local results and put them in the map
            map.put(key, getConfiguredResources(itemMap, key, referenceConfig));
        }
    }

    return map;
}
 
Example #3
Source File: ResourceRepository.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Processes a folder and adds it to the list of existing folders.
 * @param folder the folder to process
 * @return the ResourceFolder created from this folder, or null if the process failed.
 */
@Nullable
public ResourceFolder processFolder(@NonNull IAbstractFolder folder) {
    ensureInitialized();

    // split the name of the folder in segments.
    String[] folderSegments = folder.getName().split(SdkConstants.RES_QUALIFIER_SEP);

    // get the enum for the resource type.
    ResourceFolderType type = ResourceFolderType.getTypeByName(folderSegments[0]);

    if (type != null) {
        // get the folder configuration.
        FolderConfiguration config = FolderConfiguration.getConfig(folderSegments);

        if (config != null) {
            return add(type, config, folder);
        }
    }

    return null;
}
 
Example #4
Source File: AbstractResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the resources values matching a given {@link FolderConfiguration}.
 *
 * @param referenceConfig the configuration that each value must match.
 * @return a map with guaranteed to contain an entry for each {@link ResourceType}
 */
@NonNull
public Map<ResourceType, Map<String, ResourceValue>> getConfiguredResources(
        @NonNull FolderConfiguration referenceConfig) {
    Map<ResourceType, Map<String, ResourceValue>> map = Maps.newEnumMap(ResourceType.class);

    synchronized (ITEM_MAP_LOCK) {
        Map<ResourceType, ListMultimap<String, ResourceItem>> itemMap = getMap();
        for (ResourceType key : ResourceType.values()) {
            // get the local results and put them in the map
            map.put(key, getConfiguredResources(itemMap, key, referenceConfig));
        }
    }

    return map;
}
 
Example #5
Source File: ResourceRepository.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resources values matching a given {@link FolderConfiguration} for the current
 * project.
 *
 * @param referenceConfig the configuration that each value must match.
 * @return a map with guaranteed to contain an entry for each {@link ResourceType}
 */
@NonNull
protected final Map<ResourceType, ResourceValueMap> doGetConfiguredResources(
        @NonNull FolderConfiguration referenceConfig) {
    ensureInitialized();

    Map<ResourceType, ResourceValueMap> map =
        new EnumMap<ResourceType, ResourceValueMap>(ResourceType.class);

    for (ResourceType key : ResourceType.values()) {
        // get the local results and put them in the map
        map.put(key, getConfiguredResource(key, referenceConfig));
    }

    return map;
}
 
Example #6
Source File: ResourceRepository.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link ResourceFile} matching the given name,
 * {@link ResourceFolderType} and configuration.
 * <p>
 * This only works with files generating one resource named after the file
 * (for instance, layouts, bitmap based drawable, xml, anims).
 *
 * @param name the resource name or file name
 * @param type the folder type search for
 * @param config the folder configuration to match for
 * @return the matching file or <code>null</code> if no match was found.
 */
@Nullable
public ResourceFile getMatchingFile(
        @NonNull String name,
        @NonNull ResourceFolderType type,
        @NonNull FolderConfiguration config) {
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(type);
    for (ResourceType t : types) {
        if (t == ResourceType.ID) {
            continue;
        }
        ResourceFile match = getMatchingFile(name, t, config);
        if (match != null) {
            return match;
        }
    }

    return null;
}
 
Example #7
Source File: AbstractResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
public ResourceValue getConfiguredValue(
        @NonNull ResourceType type,
        @NonNull String name,
        @NonNull FolderConfiguration referenceConfig) {
    // get the resource item for the given type
    ListMultimap<String, ResourceItem> items = getMap(type, false);
    if (items == null) {
        return null;
    }

    List<ResourceItem> keyItems = items.get(name);
    if (keyItems == null) {
        return null;
    }

    // look for the best match for the given configuration
    // the match has to be of type ResourceFile since that's what the input list contains
    ResourceItem match = (ResourceItem) referenceConfig.findMatchingConfigurable(keyItems);
    return match != null ? match.getResourceValue(mFramework) : null;
}
 
Example #8
Source File: ResourceRepository.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a map of (resource name, resource value) for the given {@link ResourceType}.
 * <p>The values returned are taken from the resource files best matching a given
 * {@link FolderConfiguration}.
 *
 * @param type the type of the resources.
 * @param referenceConfig the configuration to best match.
 */
@NonNull
private ResourceValueMap getConfiguredResource(@NonNull ResourceType type,
        @NonNull FolderConfiguration referenceConfig) {
    // get the resource item for the given type
    Map<String, ResourceItem> items = mResourceMap.get(type);
    if (items == null) {
        return ResourceValueMap.create();
    }

    // create the map
    ResourceValueMap map = ResourceValueMap.createWithExpectedSize(items.size());

    for (ResourceItem item : items.values()) {
        ResourceValue value = item.getResourceValue(type, referenceConfig,
                isFrameworkRepository());
        if (value != null) {
            map.put(item.getName(), value);
        }
    }

    return map;
}
 
Example #9
Source File: ResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a map of (resource name, resource value) for the given {@link ResourceType}.
 * <p/>The values returned are taken from the resource files best matching a given
 * {@link FolderConfiguration}.
 * @param type the type of the resources.
 * @param referenceConfig the configuration to best match.
 */
@NonNull
private Map<String, ResourceValue> getConfiguredResource(@NonNull ResourceType type,
        @NonNull FolderConfiguration referenceConfig) {

    // get the resource item for the given type
    Map<String, ResourceItem> items = mResourceMap.get(type);
    if (items == null) {
        return new HashMap<String, ResourceValue>();
    }

    // create the map
    HashMap<String, ResourceValue> map = new HashMap<String, ResourceValue>(items.size());

    for (ResourceItem item : items.values()) {
        ResourceValue value = item.getResourceValue(type, referenceConfig,
                isFrameworkRepository());
        if (value != null) {
            map.put(item.getName(), value);
        }
    }

    return map;
}
 
Example #10
Source File: ResourceRepository.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the sorted list of languages used in the resources.
 */
@NonNull
public SortedSet<String> getLanguages() {
    ensureInitialized();

    SortedSet<String> set = new TreeSet<String>();

    Collection<List<ResourceFolder>> folderList = mFolderMap.values();
    for (List<ResourceFolder> folderSubList : folderList) {
        for (ResourceFolder folder : folderSubList) {
            FolderConfiguration config = folder.getConfiguration();
            LocaleQualifier locale = config.getLocaleQualifier();
            if (locale != null && locale.hasLanguage()) {
                set.add(locale.getLanguage());
            }
        }
    }

    return set;
}
 
Example #11
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Processes a folder and adds it to the list of existing folders.
 * @param folder the folder to process
 * @return the ResourceFolder created from this folder, or null if the process failed.
 */
@Nullable
public ResourceFolder processFolder(@NonNull IAbstractFolder folder) {
    ensureInitialized();

    // split the name of the folder in segments.
    String[] folderSegments = folder.getName().split(SdkConstants.RES_QUALIFIER_SEP);

    // get the enum for the resource type.
    ResourceFolderType type = ResourceFolderType.getTypeByName(folderSegments[0]);

    if (type != null) {
        // get the folder configuration.
        FolderConfiguration config = FolderConfiguration.getConfig(folderSegments);

        if (config != null) {
            return add(type, config, folder);
        }
    }

    return null;
}
 
Example #12
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link ResourceFile} matching the given name,
 * {@link ResourceFolderType} and configuration.
 * <p/>
 * This only works with files generating one resource named after the file
 * (for instance, layouts, bitmap based drawable, xml, anims).
 *
 * @param name the resource name or file name
 * @param type the folder type search for
 * @param config the folder configuration to match for
 * @return the matching file or <code>null</code> if no match was found.
 */
@Nullable
public ResourceFile getMatchingFile(
        @NonNull String name,
        @NonNull ResourceFolderType type,
        @NonNull FolderConfiguration config) {
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(type);
    for (ResourceType t : types) {
        if (t == ResourceType.ID) {
            continue;
        }
        ResourceFile match = getMatchingFile(name, t, config);
        if (match != null) {
            return match;
        }
    }

    return null;
}
 
Example #13
Source File: ResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the sorted list of languages used in the resources.
 */
@NonNull
public SortedSet<String> getLanguages() {
    ensureInitialized();

    SortedSet<String> set = new TreeSet<String>();

    Collection<List<ResourceFolder>> folderList = mFolderMap.values();
    for (List<ResourceFolder> folderSubList : folderList) {
        for (ResourceFolder folder : folderSubList) {
            FolderConfiguration config = folder.getConfiguration();
            LocaleQualifier locale = config.getLocaleQualifier();
            if (locale != null) {
                set.add(locale.getLanguage());
            }
        }
    }

    return set;
}
 
Example #14
Source File: BlazeNewResourceCreationHandler.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public CreateResourceFileDialogBase createNewResourceFileDialog(
    AndroidFacet facet,
    Collection<CreateTypedResourceFileAction> actions,
    @Nullable ResourceFolderType folderType,
    @Nullable String filename,
    @Nullable String rootElement,
    @Nullable FolderConfiguration folderConfiguration,
    boolean chooseFileName,
    boolean chooseModule,
    @Nullable PsiDirectory resDirectory,
    @Nullable DataContext dataContext,
    CreateResourceFileDialogBase.ValidatorFactory validatorFactory) {
  return new BlazeCreateResourceFileDialog(
      facet,
      actions,
      folderType,
      filename,
      rootElement,
      folderConfiguration,
      chooseFileName,
      chooseModule,
      resDirectory,
      dataContext,
      validatorFactory);
}
 
Example #15
Source File: ResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the sorted list of regions used in the resources with the given language.
 * @param currentLanguage the current language the region must be associated with.
 */
@NonNull
public SortedSet<String> getRegions(@NonNull String currentLanguage) {
    ensureInitialized();

    SortedSet<String> set = new TreeSet<String>();

    Collection<List<ResourceFolder>> folderList = mFolderMap.values();
    for (List<ResourceFolder> folderSubList : folderList) {
        for (ResourceFolder folder : folderSubList) {
            FolderConfiguration config = folder.getConfiguration();

            // get the language
            LocaleQualifier locale = config.getLocaleQualifier();
            if (locale != null && currentLanguage.equals(locale.getLanguage())
                    && locale.getRegion() != null) {
                set.add(locale.getRegion());
            }
        }
    }

    return set;
}
 
Example #16
Source File: ResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the list of source files for a given resource.
 * Optionally, if a {@link FolderConfiguration} is given, then only the best
 * match for this config is returned.
 *
 * @param type the type of the resource.
 * @param name the name of the resource.
 * @param referenceConfig an optional config for which only the best match will be returned.
 *
 * @return a list of files generating this resource or null if it was not found.
 */
@Nullable
public List<ResourceFile> getSourceFiles(@NonNull ResourceType type, @NonNull String name,
        @Nullable FolderConfiguration referenceConfig) {
    ensureInitialized();

    Collection<ResourceItem> items = getResourceItemsOfType(type);

    for (ResourceItem item : items) {
        if (name.equals(item.getName())) {
            if (referenceConfig != null) {
                Configurable match = referenceConfig.findMatchingConfigurable(
                        item.getSourceFileList());

                if (match instanceof ResourceFile) {
                    return Collections.singletonList((ResourceFile) match);
                }

                return null;
            }
            return item.getSourceFileList();
        }
    }

    return null;
}
 
Example #17
Source File: RenderServiceFactory.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a {@link ResourceResolver} for a given config and project resource.
 *
 * @param config
 * @param projectResources
 * @param themeName
 * @param isProjectTheme
 * @return
 */
public ResourceResolver createResourceResolver(
        FolderConfiguration config,
        ResourceRepository projectResources,
        String themeName,
        boolean isProjectTheme) {

    Map<ResourceType, Map<String, ResourceValue>> configedProjectRes =
            projectResources.getConfiguredResources(config);

    Map<ResourceType, Map<String, ResourceValue>> configedFrameworkRes =
            mResources.getConfiguredResources(config);

    return ResourceResolver.create(configedProjectRes, configedFrameworkRes,
            themeName, isProjectTheme);
}
 
Example #18
Source File: GeneratedResourceClassifier.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static boolean mayHaveNonStringTranslations(String dirName) {
  // String translations only sit in the values-xx-rYY directories, so we can rule out other
  // directories quickly.
  if (!dirName.contains(SdkConstants.RES_QUALIFIER_SEP)) {
    return true;
  }
  if (ResourceFolderType.getFolderType(dirName) != ResourceFolderType.VALUES) {
    return true;
  }
  FolderConfiguration config = FolderConfiguration.getConfigForFolder(dirName);
  // Conservatively say it's interesting if there is an unrecognized configuration.
  if (config == null) {
    return true;
  }
  // If this is a translation mixed with something else, consider it a translation directory.
  boolean hasTranslation = false;
  for (ResourceQualifier qualifier : config.getQualifiers()) {
    if (qualifier instanceof LocaleQualifier) {
      hasTranslation = true;
    }
  }
  return !hasTranslation;
}
 
Example #19
Source File: TranslationDetector.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/** Look up the language for the given folder name */
private static String getLanguageTag(String name) {
    if (FD_RES_VALUES.equals(name)) {
        return null;
    }

    FolderConfiguration configuration = FolderConfiguration.getConfigForFolder(name);
    if (configuration != null) {
      LocaleQualifier locale = configuration.getLocaleQualifier();
      if (locale != null && !locale.hasFakeValue()) {
          return locale.getTag();
      }
    }

    return null;
}
 
Example #20
Source File: ResourceRepository.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Processes a folder and adds it to the list of existing folders.
 * @param folder the folder to process
 * @return the ResourceFolder created from this folder, or null if the process failed.
 */
@Nullable
public ResourceFolder processFolder(@NonNull IAbstractFolder folder) {
    ensureInitialized();

    // split the name of the folder in segments.
    String[] folderSegments = folder.getName().split(SdkConstants.RES_QUALIFIER_SEP);

    // get the enum for the resource type.
    ResourceFolderType type = ResourceFolderType.getTypeByName(folderSegments[0]);

    if (type != null) {
        // get the folder configuration.
        FolderConfiguration config = FolderConfiguration.getConfig(folderSegments);

        if (config != null) {
            return add(type, config, folder);
        }
    }

    return null;
}
 
Example #21
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a map of (resource name, resource value) for the given {@link ResourceType}.
 * <p/>The values returned are taken from the resource files best matching a given
 * {@link FolderConfiguration}.
 * @param type the type of the resources.
 * @param referenceConfig the configuration to best match.
 */
@NonNull
private Map<String, ResourceValue> getConfiguredResource(@NonNull ResourceType type,
        @NonNull FolderConfiguration referenceConfig) {

    // get the resource item for the given type
    Map<String, ResourceItem> items = mResourceMap.get(type);
    if (items == null) {
        return new HashMap<String, ResourceValue>();
    }

    // create the map
    HashMap<String, ResourceValue> map = new HashMap<String, ResourceValue>(items.size());

    for (ResourceItem item : items.values()) {
        ResourceValue value = item.getResourceValue(type, referenceConfig,
                isFrameworkRepository());
        if (value != null) {
            map.put(item.getName(), value);
        }
    }

    return map;
}
 
Example #22
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the sorted list of regions used in the resources with the given language.
 * @param currentLanguage the current language the region must be associated with.
 */
@NonNull
public SortedSet<String> getRegions(@NonNull String currentLanguage) {
    ensureInitialized();

    SortedSet<String> set = new TreeSet<String>();

    Collection<List<ResourceFolder>> folderList = mFolderMap.values();
    for (List<ResourceFolder> folderSubList : folderList) {
        for (ResourceFolder folder : folderSubList) {
            FolderConfiguration config = folder.getConfiguration();

            // get the language
            LanguageQualifier lang = config.getLanguageQualifier();
            if (lang != null && lang.getShortDisplayValue().equals(currentLanguage)) {
                RegionQualifier region = config.getRegionQualifier();
                if (region != null) {
                    set.add(region.getShortDisplayValue());
                }
            }
        }
    }

    return set;
}
 
Example #23
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the sorted list of languages used in the resources.
 */
@NonNull
public SortedSet<String> getLanguages() {
    ensureInitialized();

    SortedSet<String> set = new TreeSet<String>();

    Collection<List<ResourceFolder>> folderList = mFolderMap.values();
    for (List<ResourceFolder> folderSubList : folderList) {
        for (ResourceFolder folder : folderSubList) {
            FolderConfiguration config = folder.getConfiguration();
            LanguageQualifier lang = config.getLanguageQualifier();
            if (lang != null) {
                set.add(lang.getShortDisplayValue());
            }
        }
    }

    return set;
}
 
Example #24
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resources values matching a given {@link FolderConfiguration} for the current
 * project.
 *
 * @param referenceConfig the configuration that each value must match.
 * @return a map with guaranteed to contain an entry for each {@link ResourceType}
 */
@NonNull
protected final Map<ResourceType, Map<String, ResourceValue>> doGetConfiguredResources(
        @NonNull FolderConfiguration referenceConfig) {
    ensureInitialized();

    Map<ResourceType, Map<String, ResourceValue>> map =
        new EnumMap<ResourceType, Map<String, ResourceValue>>(ResourceType.class);

    for (ResourceType key : ResourceType.values()) {
        // get the local results and put them in the map
        map.put(key, getConfiguredResource(key, referenceConfig));
    }

    return map;
}
 
Example #25
Source File: ResourceRepository.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the list of source files for a given resource.
 * Optionally, if a {@link FolderConfiguration} is given, then only the best
 * match for this config is returned.
 *
 * @param type the type of the resource.
 * @param name the name of the resource.
 * @param referenceConfig an optional config for which only the best match will be returned.
 *
 * @return a list of files generating this resource or null if it was not found.
 */
@Nullable
public List<ResourceFile> getSourceFiles(@NonNull ResourceType type, @NonNull String name,
        @Nullable FolderConfiguration referenceConfig) {
    ensureInitialized();

    Collection<ResourceItem> items = getResourceItemsOfType(type);

    for (ResourceItem item : items) {
        if (name.equals(item.getName())) {
            if (referenceConfig != null) {
                Configurable match = referenceConfig.findMatchingConfigurable(
                        item.getSourceFileList());

                if (match instanceof ResourceFile) {
                    return Collections.singletonList((ResourceFile) match);
                }

                return null;
            }
            return item.getSourceFileList();
        }
    }

    return null;
}
 
Example #26
Source File: AbstractResourceRepository.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the sorted list of languages used in the resources.
 */
@NonNull
public SortedSet<LocaleQualifier> getLocales() {
    SortedSet<LocaleQualifier> set = new TreeSet<LocaleQualifier>();

    // As an optimization we could just look for values since that's typically where
    // the languages are defined -- not on layouts, menus, etc -- especially if there
    // are no translations for it
    Set<String> qualifiers = Sets.newHashSet();

    synchronized (ITEM_MAP_LOCK) {
        for (ListMultimap<String, ResourceItem> map : getMap().values()) {
            for (ResourceItem item : map.values()) {
                qualifiers.add(item.getQualifiers());
            }
        }
    }

    for (String s : qualifiers) {
        FolderConfiguration configuration = FolderConfiguration.getConfigForQualifierString(s);
        if (configuration != null) {
            LocaleQualifier locale = configuration.getLocaleQualifier();
            if (locale != null) {
                set.add(locale);
            }
        }
    }

    return set;
}
 
Example #27
Source File: ResourceRepository.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the resources values matching a given {@link FolderConfiguration}.
 *
 * @param referenceConfig the configuration that each value must match.
 * @return a map with guaranteed to contain an entry for each {@link ResourceType}
 */
@NonNull
public Map<ResourceType, ResourceValueMap> getConfiguredResources(
        @NonNull FolderConfiguration referenceConfig) {
    ensureInitialized();

    return doGetConfiguredResources(referenceConfig);
}
 
Example #28
Source File: ResourceItem.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a {@link ResourceValue} for this item based on the given configuration.
 * If the ResourceItem has several source files, one will be selected based on the config.
 * @param type the type of the resource. This is necessary because ResourceItem doesn't embed
 *     its type, but ResourceValue does.
 * @param referenceConfig the config of the resource item.
 * @param isFramework whether the resource is a framework value. Same as the type.
 * @return a ResourceValue or null if none match the config.
 */
public ResourceValue getResourceValue(ResourceType type, FolderConfiguration referenceConfig,
        boolean isFramework) {
    // look for the best match for the given configuration
    // the match has to be of type ResourceFile since that's what the input list contains
    ResourceFile match = (ResourceFile) referenceConfig.findMatchingConfigurable(mFiles);

    if (match != null) {
        // get the value of this configured resource.
        return match.getValue(type, mName);
    }

    return null;
}
 
Example #29
Source File: InlineResourceItem.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ResourceValue getResourceValue(ResourceType type, FolderConfiguration referenceConfig,
        boolean isFramework) {
    assert type == ResourceType.ID;
    if (mValue == null) {
        mValue = new ResourceValue(type, getName(), isFramework);
    }

    return mValue;
}
 
Example #30
Source File: ResourceFolder.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link ResourceFolder}
 * @param type The type of the folder
 * @param config The configuration of the folder
 * @param folder The associated {@link IAbstractFolder} object.
 * @param repository The associated {@link ResourceRepository}
 */
protected ResourceFolder(ResourceFolderType type, FolderConfiguration config,
        IAbstractFolder folder, ResourceRepository repository) {
    mType = type;
    mConfiguration = config;
    mFolder = folder;
    mRepository = repository;
}