• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ResourceType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.resources.ResourceType的典型用法代码示例。如果您正苦于以下问题:Java ResourceType类的具体用法?Java ResourceType怎么用?Java ResourceType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ResourceType类属于com.android.resources包,在下文中一共展示了ResourceType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkDuplicate

import com.android.resources.ResourceType; //导入依赖的package包/类
private static void checkDuplicate(@NonNull ResourceItem resource,
                                   @Nullable Map<ResourceType, Set<String>> map)
        throws MergingException {
    if (map == null) {
        return;
    }

    String name = resource.getName();
    Set<String> set = map.get(resource.getType());
    if (set == null) {
        set = Sets.newHashSet(name);
        map.put(resource.getType(), set);
    } else {
        if (set.contains(name)) {
            throw new MergingException(String.format(
                    "Found item %s/%s more than one time",
                    resource.getType().getDisplayName(), name));
        }

        set.add(name);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:ValueResourceParser2.java


示例2: getSourceFiles

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:37,代码来源:ResourceRepository.java


示例3: getConfiguredResources

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:AbstractResourceRepository.java


示例4: updateResourceItems

import com.android.resources.ResourceType; //导入依赖的package包/类
private void updateResourceItems(ScanningContext context) {
    ResourceRepository repository = getRepository();

    // remove this file from all existing ResourceItem.
    repository.removeFile(mResourceTypeList, this);

    for (ResourceType type : mResourceTypeList) {
        Map<String, ResourceValue> list = mResourceItems.get(type);

        if (list != null) {
            Collection<ResourceValue> values = list.values();
            for (ResourceValue res : values) {
                ResourceItem item = repository.getResourceItem(type, res.getName());

                // add this file to the list of files generating this resource item.
                item.add(this);
            }
        }
    }

    // If we need an ID refresh, ask the repository for that now
    if (mNeedIdRefresh) {
        context.requestFullAapt();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:26,代码来源:MultiResourceFile.java


示例5: addResourceValue

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:28,代码来源:MultiResourceFile.java


示例6: getResourceItemsOfType

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Returns a list of {@link ResourceItem} matching a given {@link ResourceType}.
 * @param type the type of the resource items to return
 * @return a non null collection of resource items
 */
@NonNull
public Collection<ResourceItem> getResourceItemsOfType(@NonNull ResourceType type) {
    ensureInitialized();

    Map<String, ResourceItem> map = mResourceMap.get(type);

    if (map == null) {
        return Collections.emptyList();
    }

    Collection<ResourceItem> roList = mReadOnlyListMap.get(map);
    if (roList == null) {
        roList = Collections.unmodifiableCollection(map.values());
        mReadOnlyListMap.put(map, roList);
    }

    return roList;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:ResourceRepository.java


示例7: getConfiguredResource

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:31,代码来源:ResourceRepository.java


示例8: getTheme

import com.android.resources.ResourceType; //导入依赖的package包/类
@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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:ResourceResolver.java


示例9: resolveValue

import com.android.resources.ResourceType; //导入依赖的package包/类
@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);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:21,代码来源:ResourceResolver.java


示例10: getValue

import com.android.resources.ResourceType; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:IdGeneratingResourceFile.java


示例11: updateResourceItems

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Add the resources represented by this file to the repository
 */
private void updateResourceItems(ScanningContext context) {
    ResourceRepository repository = getRepository();

    // remove this file from all existing ResourceItem.
    repository.removeFile(mResourceTypeList, this);

    // First add this as a layout file
    ResourceItem item = repository.getResourceItem(mFileType, mFileName);
    item.add(this);

    // Now iterate through our IDs and add
    for (String idName : mIdResources.keySet()) {
        item = repository.getResourceItem(ResourceType.ID, idName);
        // add this file to the list of files generating ID resources.
        item.add(this);
    }

    //  Ask the repository for an ID refresh
    context.requestFullAapt();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:IdGeneratingResourceFile.java


示例12: doGetConfiguredResources

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:ResourceRepository.java


示例13: createResourceFile

import com.android.resources.ResourceType; //导入依赖的package包/类
private ResourceFile createResourceFile(IAbstractFile file) {
    // check if that's a single or multi resource type folder. For now we define this by
    // the number of possible resource type output by files in the folder.
    // We have a special case for layout/menu folders which can also generate IDs.
    // This does
    // not make the difference between several resource types from a single file or
    // the ability to have 2 files in the same folder generating 2 different types of
    // resource. The former is handled by MultiResourceFile properly while we don't
    // handle the latter. If we were to add this behavior we'd have to change this call.
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(mType);

    ResourceFile resFile = null;
    if (types.size() == 1) {
        resFile = new SingleResourceFile(file, this);
    } else if (types.contains(ResourceType.LAYOUT)) {
        resFile = new IdGeneratingResourceFile(file, this, ResourceType.LAYOUT);
    } else if (types.contains(ResourceType.MENU)) {
        resFile = new IdGeneratingResourceFile(file, this, ResourceType.MENU);
    } else {
        resFile = new MultiResourceFile(file, this);
    }
    return resFile;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:ResourceFolder.java


示例14: getResourceTypes

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Returns the list of {@link ResourceType}s generated by the files inside this folder.
 */
public Collection<ResourceType> getResourceTypes() {
    ArrayList<ResourceType> list = new ArrayList<ResourceType>();

    if (mFiles != null) {
        for (ResourceFile file : mFiles) {
            Collection<ResourceType> types = file.getResourceTypes();

            // loop through those and add them to the main list,
            // if they are not already present
            for (ResourceType resType : types) {
                if (list.indexOf(resType) == -1) {
                    list.add(resType);
                }
            }
        }
    }

    return list;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:ResourceFolder.java


示例15: hasResources

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Returns whether a file in the folder is generating a resource of a specified type.
 * @param type The {@link ResourceType} being looked up.
 */
public boolean hasResources(ResourceType type) {
    // Check if the folder type is able to generate resource of the type that was asked.
    // this is a first check to avoid going through the files.
    List<ResourceFolderType> folderTypes = FolderTypeRelationship.getRelatedFolders(type);

    boolean valid = false;
    for (ResourceFolderType rft : folderTypes) {
        if (rft == mType) {
            valid = true;
            break;
        }
    }

    if (valid) {
        if (mFiles != null) {
            for (ResourceFile f : mFiles) {
                if (f.hasResources(type)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:29,代码来源:ResourceFolder.java


示例16: hasResourceItem

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Returns true if this resource repository contains a resource of the given
 * name.
 *
 * @param type the type of resource to look up
 * @param name the name of the resource
 * @return true if the resource is known
 */
public boolean hasResourceItem(@NonNull ResourceType type, @NonNull String name) {
    ensureInitialized();

    Map<String, ResourceItem> map = mResourceMap.get(type);

    if (map != null) {

        ResourceItem resourceItem = map.get(name);
        if (resourceItem != null) {
            return true;
        }
    }

    return false;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:ResourceRepository.java


示例17: getXmlString

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
 *
 * @param system Whether this is a system resource or a project resource.
 * @return a string in the format @[type]/[name]
 */
public String getXmlString(ResourceType type, boolean system) {
    if (type == ResourceType.ID /* && isDeclaredInline()*/) {
        return (system ? ANDROID_NEW_ID_PREFIX : NEW_ID_PREFIX) + "/" + getName();
    }

    return (system ? ANDROID_PREFIX : PREFIX_RESOURCE_REF) + type.getName() + "/" + getName();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:ResourceItem.java


示例18: getType

import com.android.resources.ResourceType; //导入依赖的package包/类
@Nullable
private ResourceType getType(String qName, NamedNodeMap attributes) {
    String typeValue;

    // if the node is <item>, we get the type from the attribute "type"
    if (SdkConstants.TAG_ITEM.equals(qName)) {
        typeValue = getAttributeValue(attributes, ATTR_TYPE);
    } else {
        // the type is the name of the node.
        typeValue = qName;
    }

    return ResourceType.getEnum(typeValue);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:ResourceItem.java


示例19: getConfiguredResources

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * 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) {
    ensureInitialized();

    return doGetConfiguredResources(referenceConfig);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:ResourceRepository.java


示例20: getResource

import com.android.resources.ResourceType; //导入依赖的package包/类
/**
 * Returns a new ResourceItem object for a given node.
 * @param node the node representing the resource.
 * @return a ResourceItem object or null.
 */
static ResourceItem getResource(@NonNull Node node, @Nullable File from) {
    ResourceType type = getType(node, from);
    String name = getName(node);

    if (name != null) {
        if (type != null) {
            return new ResourceItem(name, type, node);
        }
    }

    return null;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:18,代码来源:ValueResourceParser2.java



注:本文中的com.android.resources.ResourceType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Kind类代码示例发布时间:2022-05-23
下一篇:
Java SingleColumnType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap