本文整理汇总了Java中com.android.resources.ResourceFolderType.getTypeByName方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceFolderType.getTypeByName方法的具体用法?Java ResourceFolderType.getTypeByName怎么用?Java ResourceFolderType.getTypeByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.resources.ResourceFolderType
的用法示例。
在下文中一共展示了ResourceFolderType.getTypeByName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFolder
import com.android.resources.ResourceFolderType; //导入方法依赖的package包/类
/**
* 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;
}
示例2: getResourceSubdirs
import com.android.resources.ResourceFolderType; //导入方法依赖的package包/类
@NotNull
public static List<VirtualFile> getResourceSubdirs(@Nullable String resourceType, @NotNull VirtualFile[] resourceDirs) {
if (resourceType != null && ResourceFolderType.getTypeByName(resourceType) == null) {
return Collections.emptyList();
}
final List<VirtualFile> dirs = new ArrayList<VirtualFile>();
for (VirtualFile resourcesDir : resourceDirs) {
if (resourcesDir == null) {
return dirs;
}
if (resourceType == null) {
ContainerUtil.addAll(dirs, resourcesDir.getChildren());
}
else {
for (VirtualFile child : resourcesDir.getChildren()) {
String type = AndroidCommonUtils.getResourceTypeByDirName(child.getName());
if (resourceType.equals(type)) dirs.add(child);
}
}
}
return dirs;
}
示例3: findResourceFile
import com.android.resources.ResourceFolderType; //导入方法依赖的package包/类
@Nullable
private PsiResourceFile findResourceFile(String dirName, String fileName) {
int index = dirName.indexOf('-');
String qualifiers;
String folderTypeName;
if (index == -1) {
qualifiers = "";
folderTypeName = dirName;
} else {
qualifiers = dirName.substring(index + 1);
folderTypeName = dirName.substring(0, index);
}
ResourceFolderType folderType = ResourceFolderType.getTypeByName(folderTypeName);
for (PsiResourceFile file : myResourceFiles.values()) {
String name = file.getName();
if (folderType == file.getFolderType() && fileName.equals(name) && qualifiers.equals(file.getQualifiers())) {
return file;
}
}
return null;
}
示例4: getFolderData
import com.android.resources.ResourceFolderType; //导入方法依赖的package包/类
/**
* Returns a FolderData for the given folder
* @param folder the folder.
* @return the FolderData object.
*/
@Nullable
private static FolderData getFolderData(File folder) {
FolderData fd = new FolderData();
String folderName = folder.getName();
int pos = folderName.indexOf(ResourceConstants.RES_QUALIFIER_SEP);
if (pos != -1) {
fd.folderType = ResourceFolderType.getTypeByName(folderName.substring(0, pos));
if (fd.folderType == null) {
return null;
}
FolderConfiguration folderConfiguration = FolderConfiguration.getConfigForFolder(folderName);
if (folderConfiguration == null) {
return null;
}
// normalize it
folderConfiguration.normalize();
// get the qualifier portion from the folder config.
// the returned string starts with "-" so we remove that.
fd.qualifiers = folderConfiguration.getUniqueKey().substring(1);
} else {
fd.folderType = ResourceFolderType.getTypeByName(folderName);
}
if (fd.folderType != null && fd.folderType != ResourceFolderType.VALUES) {
fd.type = FolderTypeRelationship.getRelatedResourceTypes(fd.folderType).get(0);
}
return fd;
}
示例5: getFolderData
import com.android.resources.ResourceFolderType; //导入方法依赖的package包/类
/**
* Returns a FolderData for the given folder
* @param folder the folder.
* @return the FolderData object.
*/
@Nullable
private FolderData getFolderData(File folder) throws MergingException {
FolderData fd = new FolderData();
String folderName = folder.getName();
int pos = folderName.indexOf(ResourceConstants.RES_QUALIFIER_SEP);
if (pos != -1) {
fd.folderType = ResourceFolderType.getTypeByName(folderName.substring(0, pos));
if (fd.folderType == null) {
return null;
}
FolderConfiguration folderConfiguration = FolderConfiguration.getConfigForFolder(folderName);
if (folderConfiguration == null) {
throw MergingException.withMessage("Invalid resource directory name")
.withFile(folder).build();
}
if (mNormalizeResources) {
// normalize it
folderConfiguration.normalize();
}
// get the qualifier portion from the folder config.
// the returned string starts with "-" so we remove that.
fd.qualifiers = folderConfiguration.getUniqueKey().substring(1);
} else {
fd.folderType = ResourceFolderType.getTypeByName(folderName);
}
if (fd.folderType != null && fd.folderType != ResourceFolderType.VALUES) {
fd.type = FolderTypeRelationship.getRelatedResourceTypes(fd.folderType).get(0);
}
return fd;
}