Java Code Examples for com.android.ide.common.rendering.api.ResourceValue

The following examples show how to use com.android.ide.common.rendering.api.ResourceValue. These examples are extracted from open source projects. 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 Project: NBANDROID-V2   Source File: ResourceRepository.java    License: 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 2
Source Project: javaide   Source File: ResourceResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public ResourceValue findResValue(String reference, boolean forceFrameworkOnly) {
    if (!mLookupChain.isEmpty() && reference.startsWith(PREFIX_RESOURCE_REF)) {
        ResourceValue prev = mLookupChain.get(mLookupChain.size() - 1);
        if (!reference.equals(prev.getValue())) {
            ResourceValue next = new ResourceValue(prev.getResourceType(), prev.getName(),
                    prev.isFramework());
            next.setValue(reference);
            mLookupChain.add(next);
        }
    }

    ResourceValue resValue = super.findResValue(reference, forceFrameworkOnly);

    if (resValue != null) {
        mLookupChain.add(resValue);
    }

    return resValue;
}
 
Example 3
@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 4
Source Project: java-n-IDE-for-Android   Source File: MultiResourceFile.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Adds a resource item to the list
 * @param value The value of the resource.
 */
@Override
public void addResourceValue(ResourceValue value) {
    ResourceType resType = value.getResourceType();

    Map<String, ResourceValue> list = mResourceItems.get(resType);

    // if the list does not exist, create it.
    if (list == null) {
        list = new HashMap<String, ResourceValue>();
        mResourceItems.put(resType, list);
    } else {
        // look for a possible value already existing.
        ResourceValue oldValue = list.get(value.getName());

        if (oldValue != null) {
            oldValue.replaceWith(value);
            return;
        }
    }

    // empty list or no match found? add the given resource
    list.put(value.getName(), value);
}
 
Example 5
/**
 * 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 6
Source Project: NBANDROID-V2   Source File: IdGeneratingResourceFile.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resource value associated with this whole file as a layout resource
 * @param file the file handler that represents this file
 * @param folder the folder this file is under
 * @return a resource value associated with this layout
 */
private ResourceValue getFileValue(IAbstractFile file, ResourceFolder folder) {
    // test if there's a density qualifier associated with the resource
    DensityQualifier qualifier = folder.getConfiguration().getDensityQualifier();

    ResourceValue value;
    if (!ResourceQualifier.isValid(qualifier)) {
        value =
                new ResourceValueImpl(
                        new ResourceReference(mFileType, mFileName, isFramework()),
                        file.getOsLocation());
    } else {
        value =
                new DensityBasedResourceValueImpl(
                        new ResourceReference(mFileType, mFileName, isFramework()),
                        file.getOsLocation(),
                        qualifier.getValue());
    }
    return value;
}
 
Example 7
Source Project: javaide   Source File: ResourceResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public StyleResourceValue getTheme(String name, boolean frameworkTheme) {
    ResourceValue theme;

    if (frameworkTheme) {
        Map<String, ResourceValue> frameworkStyleMap = mFrameworkResources.get(
                ResourceType.STYLE);
        theme = frameworkStyleMap.get(name);
    } else {
        Map<String, ResourceValue> projectStyleMap = mProjectResources.get(ResourceType.STYLE);
        theme = projectStyleMap.get(name);
    }

    if (theme instanceof StyleResourceValue) {
        return (StyleResourceValue) theme;
    }

    return null;
}
 
Example 8
Source Project: javaide   Source File: ResourceResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Search for the style in the given map and log an error if the obtained resource is not
 * {@link StyleResourceValue}.
 *
 * @return The {@link ResourceValue} found in the map.
 */
@Nullable
private ResourceValue getStyleFromMap(@NonNull Map<String, ResourceValue> styleMap,
        @NonNull String styleName) {
    ResourceValue res;
    res = styleMap.get(styleName);
    if (res != null) {
        if (!(res instanceof StyleResourceValue) && mLogger != null) {
            mLogger.error(null, String.format(
                            "Style %1$s is not of type STYLE (instead %2$s)",
                            styleName, res.getResourceType().toString()),
                    null);
        }
    }
    return res;
}
 
Example 9
Source Project: javaide   Source File: SingleResourceFile.java    License: GNU General Public License v3.0 6 votes vote down vote up
public SingleResourceFile(IAbstractFile file, ResourceFolder folder) {
    super(file, folder);

    // we need to infer the type of the resource from the folder type.
    // This is easy since this is a single Resource file.
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(folder.getType());
    mType = types.get(0);

    // compute the resource name
    mResourceName = getResourceName(mType);

    // test if there's a density qualifier associated with the resource
    DensityQualifier qualifier = folder.getConfiguration().getDensityQualifier();

    if (qualifier == null) {
        mValue = new ResourceValue(mType, getResourceName(mType),
                file.getOsLocation(), isFramework());
    } else {
        mValue = new DensityBasedResourceValue(
                mType,
                getResourceName(mType),
                file.getOsLocation(),
                qualifier.getValue(),
                isFramework());
    }
}
 
Example 10
Source Project: javaide   Source File: ResourceResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public ResourceValue resolveValue(ResourceType type, String name, String value,
        boolean isFrameworkValue) {
    if (value == null) {
        return null;
    }

    // get the ResourceValue referenced by this value
    ResourceValue resValue = findResValue(value, isFrameworkValue);

    // if resValue is null, but value is not null, this means it was not a reference.
    // we return the name/value wrapper in a ResourceValue. the isFramework flag doesn't
    // matter.
    if (resValue == null) {
        return new ResourceValue(type, name, value, isFrameworkValue);
    }

    // we resolved a first reference, but we need to make sure this isn't a reference also.
    return resolveResValue(resValue);
}
 
Example 11
Source Project: java-n-IDE-for-Android   Source File: ResourceResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Search for the style in the given map and log an error if the obtained resource is not
 * {@link StyleResourceValue}.
 *
 * @return The {@link ResourceValue} found in the map.
 */
@Nullable
private ResourceValue getStyleFromMap(@NonNull Map<String, ResourceValue> styleMap,
        @NonNull String styleName) {
    ResourceValue res;
    res = styleMap.get(styleName);
    if (res != null) {
        if (!(res instanceof StyleResourceValue) && mLogger != null) {
            mLogger.error(null, String.format(
                            "Style %1$s is not of type STYLE (instead %2$s)",
                            styleName, res.getResourceType().toString()),
                    null);
        }
    }
    return res;
}
 
Example 12
Source Project: java-n-IDE-for-Android   Source File: ResourceResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns true if the given {@code themeStyle} extends the theme given by
 * {@code parentStyle}
 */
public boolean themeExtends(@NonNull String parentStyle, @NonNull String themeStyle) {
    ResourceValue parentValue = findResValue(parentStyle,
            parentStyle.startsWith(ANDROID_STYLE_RESOURCE_PREFIX));
    if (parentValue instanceof StyleResourceValue) {
        ResourceValue themeValue = findResValue(themeStyle,
                themeStyle.startsWith(ANDROID_STYLE_RESOURCE_PREFIX));
        if (themeValue == parentValue) {
            return true;
        }
        if (themeValue instanceof StyleResourceValue) {
            return themeIsParentOf((StyleResourceValue) parentValue,
                    (StyleResourceValue) themeValue);
        }
    }

    return false;
}
 
Example 13
Source Project: NBANDROID-V2   Source File: IdGeneratingResourceFile.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ResourceValue getValue(ResourceType type, String name) {
    // Check to see if they're asking for one of the right types:
    if (type != mFileType && type != ResourceType.ID) {
        return null;
    }

    // If they're looking for a resource of this type with this name give them the whole file
    if (type == mFileType && name.equals(mFileName)) {
        return mFileValue;
    } else {
        // Otherwise try to return them an ID
        // the map will return null if it's not found
        return mIdResources.get(name);
    }
}
 
Example 14
Source Project: java-n-IDE-for-Android   Source File: ResourceResolver.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ResourceValue findResValue(String reference, boolean forceFrameworkOnly) {
    if (!mLookupChain.isEmpty() && reference.startsWith(PREFIX_RESOURCE_REF)) {
        ResourceValue prev = mLookupChain.get(mLookupChain.size() - 1);
        if (!reference.equals(prev.getValue())) {
            ResourceValue next = new ResourceValue(prev.getResourceType(), prev.getName(),
                    prev.isFramework());
            next.setValue(reference);
            mLookupChain.add(next);
        }
    }

    ResourceValue resValue = super.findResValue(reference, forceFrameworkOnly);

    if (resValue != null) {
        mLookupChain.add(resValue);
    }

    return resValue;
}
 
Example 15
Source Project: javaide   Source File: ResourceItem.java    License: GNU General Public License v3.0 6 votes vote down vote up
private ResourceValue parsePluralsValue(PluralsResourceValue value) {
    NodeList children = mValue.getChildNodes();
    for (int i = 0, n = children.getLength(); i < n; i++) {
        Node child = children.item(i);

        if (child.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap attributes = child.getAttributes();
            String quantity = getAttributeValue(attributes, ATTR_QUANTITY);
            if (quantity != null) {
                String text = getTextNode(child.getChildNodes());
                text = ValueXmlHelper.unescapeResourceString(text, false, true);
                value.addPlural(quantity, text);
            }
        }
    }

    return value;
}
 
Example 16
Source Project: java-n-IDE-for-Android   Source File: SingleResourceFile.java    License: Apache License 2.0 6 votes vote down vote up
public SingleResourceFile(IAbstractFile file, ResourceFolder folder) {
    super(file, folder);

    // we need to infer the type of the resource from the folder type.
    // This is easy since this is a single Resource file.
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(folder.getType());
    mType = types.get(0);

    // compute the resource name
    mResourceName = getResourceName(mType);

    // test if there's a density qualifier associated with the resource
    DensityQualifier qualifier = folder.getConfiguration().getDensityQualifier();

    if (qualifier == null) {
        mValue = new ResourceValue(mType, getResourceName(mType),
                file.getOsLocation(), isFramework());
    } else {
        mValue = new DensityBasedResourceValue(
                mType,
                getResourceName(mType),
                file.getOsLocation(),
                qualifier.getValue(),
                isFramework());
    }
}
 
Example 17
private static String replaceUrlWithValue(@NonNull XmlContext context,
        @NonNull String str) {
    Project project = context.getProject();
    LintClient client = context.getClient();
    if (!client.supportsProjectResources()) {
        return str;
    }
    ResourceUrl style = ResourceUrl.parse(str);
    if (style == null || style.type != ResourceType.STRING || style.framework) {
        return str;
    }
    AbstractResourceRepository resources = client.getProjectResources(project, true);
    if (resources == null) {
        return str;
    }
    List<ResourceItem> items = resources.getResourceItem(ResourceType.STRING, style.name);
    if (items == null || items.isEmpty()) {
        return str;
    }
    ResourceValue resourceValue = items.get(0).getResourceValue(false);
    if (resourceValue == null) {
        return str;
    }
    return resourceValue.getValue() == null ? str : resourceValue.getValue();
}
 
Example 18
Source Project: javaide   Source File: RenderServiceFactory.java    License: 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 19
Source Project: javaide   Source File: RenderService.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Renders the given resource value (which should refer to a drawable) and returns it
 * as an image
 *
 * @param drawableResourceValue the drawable resource value to be rendered, or null
 * @return the image, or null if something went wrong
 */
public BufferedImage renderDrawable(ResourceValue drawableResourceValue) {
    if (drawableResourceValue == null) {
        return null;
    }

    finishConfiguration();

    figureSomeValuesOut();

    DrawableParams params = new DrawableParams(drawableResourceValue, this, mWidth, mHeight,
            mConfig.getDensityQualifier().getValue(),
            mXdpi, mYdpi, mResourceResolver, mProjectCallback, mMinSdkVersion,
            mTargetSdkVersion, mLogger);
    params.setForceNoDecor();
    Result result = mLayoutLib.renderDrawable(params);
    if (result != null && result.isSuccess()) {
        Object data = result.getData();
        if (data instanceof BufferedImage) {
            return (BufferedImage) data;
        }
    }

    return null;
}
 
Example 20
Source Project: javaide   Source File: ResourceRepository.java    License: GNU General Public License v3.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 21
Source Project: java-n-IDE-for-Android   Source File: ResourceItem.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
private ResourceValue parseStyleValue(@NonNull StyleResourceValue styleValue) {
    NodeList children = mValue.getChildNodes();
    for (int i = 0, n = children.getLength(); i < n; i++) {
        Node child = children.item(i);

        if (child.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap attributes = child.getAttributes();
            String name = getAttributeValue(attributes, ATTR_NAME);
            if (name != null) {

                // is the attribute in the android namespace?
                boolean isFrameworkAttr = styleValue.isFramework();
                if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
                    name = name.substring(ANDROID_NS_NAME_PREFIX_LEN);
                    isFrameworkAttr = true;
                }

                ItemResourceValue resValue = new ItemResourceValue(name, isFrameworkAttr,
                        styleValue.isFramework());
                String text = getTextNode(child.getChildNodes());
                resValue.setValue(ValueXmlHelper.unescapeResourceString(text, false, true));
                styleValue.addItem(resValue);
            }
        }
    }

    return styleValue;
}
 
Example 22
Source Project: java-n-IDE-for-Android   Source File: ResourceItem.java    License: Apache License 2.0 5 votes vote down vote up
private ResourceValue parseArrayValue(ArrayResourceValue arrayValue) {
    NodeList children = mValue.getChildNodes();
    for (int i = 0, n = children.getLength(); i < n; i++) {
        Node child = children.item(i);

        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String text = getTextNode(child.getChildNodes());
            text = ValueXmlHelper.unescapeResourceString(text, false, true);
            arrayValue.addElement(text);
        }
    }

    return arrayValue;
}
 
Example 23
Source Project: javaide   Source File: ResourceResolver.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Compute style information from the given list of style for the project and framework.
 */
private void computeStyleMaps() {
    Map<String, ResourceValue> projectStyleMap = mProjectResources.get(ResourceType.STYLE);
    Map<String, ResourceValue> frameworkStyleMap = mFrameworkResources.get(ResourceType.STYLE);

    // first, get the theme
    ResourceValue theme = null;

    // project theme names have been prepended with a *
    if (mIsProjectTheme) {
        if (projectStyleMap != null) {
            theme = projectStyleMap.get(mThemeName);
        }
    } else {
        if (frameworkStyleMap != null) {
            theme = frameworkStyleMap.get(mThemeName);
        }
    }

    if (theme instanceof StyleResourceValue) {
        // compute the inheritance map for both the project and framework styles
        computeStyleInheritance(projectStyleMap.values(), projectStyleMap,
                frameworkStyleMap);

        // Compute the style inheritance for the framework styles/themes.
        // Since, for those, the style parent values do not contain 'android:'
        // we want to force looking in the framework style only to avoid using
        // similarly named styles from the project.
        // To do this, we pass null in lieu of the project style map.
        if (frameworkStyleMap != null) {
            computeStyleInheritance(frameworkStyleMap.values(), null /*inProjectStyleMap */,
                    frameworkStyleMap);
        }

        mDefaultTheme = (StyleResourceValue) theme;
        mThemes.clear();
        mThemes.add(mDefaultTheme);
    }
}
 
Example 24
Source Project: java-n-IDE-for-Android   Source File: ResourceItem.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation") // support for deprecated (but supported) API
@NonNull
private ResourceValue parseDeclareStyleable(
        @NonNull DeclareStyleableResourceValue declareStyleable) {
    NodeList children = mValue.getChildNodes();
    for (int i = 0, n = children.getLength(); i < n; i++) {
        Node child = children.item(i);

        if (child.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap attributes = child.getAttributes();
            String name = getAttributeValue(attributes, ATTR_NAME);
            if (name != null) {
                // is the attribute in the android namespace?
                boolean isFrameworkAttr = declareStyleable.isFramework();
                if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
                    name = name.substring(ANDROID_NS_NAME_PREFIX_LEN);
                    isFrameworkAttr = true;
                }

                AttrResourceValue attr = parseAttrValue(child,
                        new AttrResourceValue(ResourceType.ATTR, name, isFrameworkAttr));
                declareStyleable.addValue(attr);
            }
        }
    }

    return declareStyleable;
}
 
Example 25
Source Project: java-n-IDE-for-Android   Source File: ResourceItem.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
private ResourceValue parseValue(@NonNull ResourceValue value) {
    String text = getTextNode(mValue.getChildNodes());
    value.setValue(ValueXmlHelper.unescapeResourceString(text, false, true));

    return value;
}
 
Example 26
Source Project: NBANDROID-V2   Source File: ResourceItem.java    License: Apache License 2.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 27
Source Project: javaide   Source File: ResourceResolver.java    License: GNU General Public License v3.0 5 votes vote down vote up
private RecordingResourceResolver(
        @NonNull List<ResourceValue> lookupChain,
        @NonNull Map<ResourceType, Map<String, ResourceValue>> projectResources,
        @NonNull Map<ResourceType, Map<String, ResourceValue>> frameworkResources,
        @NonNull String themeName, boolean isProjectTheme) {
    super(projectResources, frameworkResources, themeName, isProjectTheme);
    mLookupChain = lookupChain;
}
 
Example 28
Source Project: java-n-IDE-for-Android   Source File: ResourceResolver.java    License: Apache License 2.0 5 votes vote down vote up
private ResourceResolver(
        Map<ResourceType, Map<String, ResourceValue>> projectResources,
        Map<ResourceType, Map<String, ResourceValue>> frameworkResources,
        String themeName, boolean isProjectTheme) {
    mProjectResources = projectResources;
    mFrameworkResources = frameworkResources;
    mThemeName = themeName;
    mIsProjectTheme = isProjectTheme;
    mThemes = new LinkedList<StyleResourceValue>();
}
 
Example 29
Source Project: java-n-IDE-for-Android   Source File: ResourceResolver.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link ResourceResolver} object.
 *
 * @param projectResources the project resources.
 * @param frameworkResources the framework resources.
 * @param themeName the name of the current theme.
 * @param isProjectTheme Is this a project theme?
 * @return a new {@link ResourceResolver}
 */
public static ResourceResolver create(
        Map<ResourceType, Map<String, ResourceValue>> projectResources,
        Map<ResourceType, Map<String, ResourceValue>> frameworkResources,
        String themeName, boolean isProjectTheme) {

    ResourceResolver resolver = new ResourceResolver(projectResources, frameworkResources,
            themeName, isProjectTheme);
    resolver.computeStyleMaps();

    return resolver;
}
 
Example 30
Source Project: java-n-IDE-for-Android   Source File: ResourceResolver.java    License: Apache License 2.0 5 votes vote down vote up
private boolean replace(String fromStyleName, String toStyleName) {
    Map<String, ResourceValue> map = mFrameworkResources.get(ResourceType.STYLE);
    if (map != null) {
        ResourceValue from = map.get(fromStyleName);
        if (from instanceof StyleResourceValue) {
            ResourceValue to = map.get(toStyleName);
            if (to instanceof StyleResourceValue) {
                mStyleInheritanceMap.put((StyleResourceValue)from, (StyleResourceValue)to);
                return true;
            }
        }
    }
    return false;
}