Java Code Examples for com.android.resources.ResourceType#ID
The following examples show how to use
com.android.resources.ResourceType#ID .
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 NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * 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: IdGeneratingResourceFile.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
@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 3
Source File: ResourceRepository.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * 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 4
Source File: IdGeneratingResourceFile.java From javaide with GNU General Public License v3.0 | 6 votes |
@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 5
Source File: ResourceRepository.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
/** * 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 6
Source File: IdGeneratingResourceFile.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@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 7
Source File: ResourceItem.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * 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:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
Example 8
Source File: LintUtils.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Determine if the given type corresponds to a resource that has a unique * file * * @param type the resource type to check * @return true if the given type corresponds to a file-type resource */ public static boolean isFileBasedResourceType(@NonNull ResourceType type) { List<ResourceFolderType> folderTypes = FolderTypeRelationship.getRelatedFolders(type); for (ResourceFolderType folderType : folderTypes) { if (folderType != ResourceFolderType.VALUES) { return type != ResourceType.ID; } } return false; }
Example 9
Source File: ResourceUsageAnalyzer.java From javaide with GNU General Public License v3.0 | 5 votes |
@Nullable private Resource getResourceByJarPath(String path) { // Jars use forward slash paths, not File.separator if (path.startsWith("res/")) { int folderStart = 4; // "res/".length int folderEnd = path.indexOf('/', folderStart); if (folderEnd != -1) { String folderName = path.substring(folderStart, folderEnd); ResourceFolderType folderType = ResourceFolderType.getFolderType(folderName); if (folderType != null) { int nameStart = folderEnd + 1; int nameEnd = path.indexOf('.', nameStart); if (nameEnd != -1) { String name = path.substring(nameStart, nameEnd); List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(folderType); for (ResourceType type : types) { if (type != ResourceType.ID) { Resource resource = getResource(type, name); if (resource != null) { return resource; } } } } } } } return null; }
Example 10
Source File: ResourceItem.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * 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(); }
Example 11
Source File: ResourceItem.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * 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(); }
Example 12
Source File: IdGeneratingResourceFile.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean hasResourceValue(ResourceType type, String name) { if (type == ResourceType.ID) { return mIdResources.containsKey(name); } return false; }
Example 13
Source File: IdGeneratingResourceFile.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean hasResourceValue(ResourceType type, String name) { if (type == ResourceType.ID) { return mIdResources.containsKey(name); } return false; }
Example 14
Source File: ResourceItem.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * 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:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
Example 15
Source File: ResourceItem.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
/** * 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:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
Example 16
Source File: IdGeneratingResourceFile.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public boolean hasResources(ResourceType type) { return (type == mFileType) || (type == ResourceType.ID && !mIdResources.isEmpty()); }
Example 17
Source File: FullyQualifiedName.java From bazel with Apache License 2.0 | 4 votes |
@Override public boolean isOverwritable(FullyQualifiedName fqn) { return !(resourceType == ResourceType.ID || resourceType == ResourceType.PUBLIC || resourceType == ResourceType.STYLEABLE); }
Example 18
Source File: IdGeneratingResourceFile.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
@Override public boolean hasResources(ResourceType type) { return (type == mFileType) || (type == ResourceType.ID && !mIdResources.isEmpty()); }
Example 19
Source File: ResourceUsageAnalyzer.java From javaide with GNU General Public License v3.0 | 4 votes |
public boolean isRelevantType() { return type != ResourceType.ID; // && getFolderType() != ResourceFolderType.VALUES; }
Example 20
Source File: IdGeneratingResourceFile.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override public boolean hasResources(ResourceType type) { return (type == mFileType) || (type == ResourceType.ID && !mIdResources.isEmpty()); }