void findDrawableResources(ResourcePath resourcePath) throws IOException { Path[] files = Fs.listFiles(resourcePath.getResourceBase()); if (files != null) { for (Path f : files) { if (Files.isDirectory(f) && f.getFileName().toString().startsWith("drawable")) { listDrawableResources(f, "drawable"); } else if (Files.isDirectory(f) && f.getFileName().toString().startsWith("mipmap")) { listDrawableResources(f, "mipmap"); } } } }
public void load(String folderBaseName) throws IOException { for (Path dir : Fs.listFiles(resourceBase, new DirBaseNameFilter(folderBaseName))) { loadFile(dir); } }
private void loadFile(Path dir) throws IOException { if (!Files.exists(dir)) { throw new RuntimeException("no such directory " + dir); } if (!Files.isDirectory(dir)) { return; } Qualifiers qualifiers; try { qualifiers = Qualifiers.fromParentDir(dir); } catch (IllegalArgumentException e) { Logger.warn(dir + ": " + e.getMessage()); return; } for (Path file : Fs.listFiles(dir, path -> path.getFileName().toString().endsWith(".xml"))) { loadResourceXmlFile(new XmlContext(packageName, file, qualifiers)); } }
if (Files.isDirectory(libraryDir)) { Path[] libraryBaseDirFiles = Fs.listFiles(libraryDir); if (libraryBaseDirFiles != null && libraryBaseDirFiles.length > 0) { List<ManifestIdentifier> libraries =
@Implementation protected static Typeface createFromAsset(AssetManager mgr, String path) { ShadowAssetManager shadowAssetManager = Shadow.extract(mgr); Collection<Path> assetDirs = shadowAssetManager.getAllAssetDirs(); for (Path assetDir : assetDirs) { Path assetFile = assetDir.resolve(path); if (Files.exists(assetFile)) { return createUnderlyingTypeface(path, Typeface.NORMAL); } // maybe path is e.g. "myFont", but we should match "myFont.ttf" too? Path[] files; try { files = Fs.listFiles(assetDir, f -> f.getFileName().toString().startsWith(path)); } catch (IOException e) { throw new RuntimeException(e); } if (files.length != 0) { return createUnderlyingTypeface(path, Typeface.NORMAL); } } throw new RuntimeException("Font asset not found " + path); }
public void load(PackageResourceTable resourceTable, String folderBaseName) throws IOException { Path resourceBase = resourcePath.getResourceBase(); for (Path dir : Fs.listFiles(resourceBase, new DirBaseNameFilter(folderBaseName))) { loadRawFiles(resourceTable, folderBaseName, dir); } }
private void listDrawableResources(Path dir, String type) throws IOException { Path[] files = Fs.listFiles(dir); if (files != null) { Qualifiers qualifiers;
private void loadRawFiles(PackageResourceTable resourceTable, String resourceType, Path rawDir) throws IOException { Qualifiers qualifiers; try { qualifiers = Qualifiers.fromParentDir(rawDir); } catch (IllegalArgumentException e) { Logger.warn(rawDir + ": " + e.getMessage()); return; } for (Path file : Fs.listFiles(rawDir)) { String fileBaseName = Fs.baseNameFor(file); resourceTable.addResource( resourceType, fileBaseName, new FileTypedResource( file, ResType.FILE, new XmlContext(resourceTable.getPackageName(), file, qualifiers))); } } }