Search in sources :

Example 1 with ResourceFolderRepository

use of com.android.tools.idea.res.ResourceFolderRepository in project android by JetBrains.

the class Parameter method existsResourceFile.

/**
   * @deprecated Replaced by {@link AssetStudioUtils#resourceExists(AndroidProjectPaths, ResourceFolderType, String)}
   * TODO: After Wizard migration, delete this
   */
public static boolean existsResourceFile(@Nullable SourceProvider sourceProvider, @Nullable Module module, @NotNull ResourceFolderType resourceFolderType, @NotNull ResourceType resourceType, @Nullable String name) {
    if (name == null || name.isEmpty() || sourceProvider == null) {
        return false;
    }
    AndroidFacet facet = module != null ? AndroidFacet.getInstance(module) : null;
    for (File resDir : sourceProvider.getResDirectories()) {
        if (facet != null) {
            VirtualFile virtualResDir = VfsUtil.findFileByIoFile(resDir, false);
            if (virtualResDir != null) {
                ResourceFolderRepository folderRepository = ResourceFolderRegistry.get(facet, virtualResDir);
                List<ResourceItem> resourceItemList = folderRepository.getResourceItem(resourceType, name);
                if (resourceItemList != null && !resourceItemList.isEmpty()) {
                    return true;
                }
            }
        } else if (existsResourceFile(resDir, resourceFolderType, name)) {
            return true;
        }
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ResourceFolderRepository(com.android.tools.idea.res.ResourceFolderRepository) ResourceItem(com.android.ide.common.res2.ResourceItem) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Aggregations

ResourceItem (com.android.ide.common.res2.ResourceItem)1 ResourceFolderRepository (com.android.tools.idea.res.ResourceFolderRepository)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1