org.robolectric.res.Fs.listFiles()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.robolectric.res.Fs.listFiles()方法的一些代码示例,展示了Fs.listFiles()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fs.listFiles()方法的具体详情如下:
包路径:org.robolectric.res.Fs
类名称:Fs
方法名:listFiles

Fs.listFiles介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

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");
   }
  }
 }
}

代码示例来源:origin: robolectric/robolectric

public void load(String folderBaseName) throws IOException {
 for (Path dir : Fs.listFiles(resourceBase, new DirBaseNameFilter(folderBaseName))) {
  loadFile(dir);
 }
}

代码示例来源:origin: robolectric/robolectric

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));
 }
}

代码示例来源:origin: robolectric/robolectric

if (Files.isDirectory(libraryDir)) {
 Path[] libraryBaseDirFiles = Fs.listFiles(libraryDir);
 if (libraryBaseDirFiles != null && libraryBaseDirFiles.length > 0) {
  List<ManifestIdentifier> libraries =

代码示例来源:origin: robolectric/robolectric

@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);
}

代码示例来源:origin: robolectric/robolectric

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);
 }
}

代码示例来源:origin: robolectric/robolectric

private void listDrawableResources(Path dir, String type) throws IOException {
 Path[] files = Fs.listFiles(dir);
 if (files != null) {
  Qualifiers qualifiers;

代码示例来源:origin: robolectric/robolectric

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)));
  }
 }
}

相关文章