当前位置: 首页>>代码示例>>Java>>正文


Java ResourceSet.loadFromFiles方法代码示例

本文整理汇总了Java中com.android.ide.common.res2.ResourceSet.loadFromFiles方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceSet.loadFromFiles方法的具体用法?Java ResourceSet.loadFromFiles怎么用?Java ResourceSet.loadFromFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.ide.common.res2.ResourceSet的用法示例。


在下文中一共展示了ResourceSet.loadFromFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.android.ide.common.res2.ResourceSet; //导入方法依赖的package包/类
@Override
public StepExecutionResult execute(ExecutionContext context)
    throws IOException, InterruptedException {
  ResourceMerger merger = new ResourceMerger(1);
  try {
    for (Path resPath : getResPaths()) {
      ResourceSet set = new ResourceSet(resPath.toString(), true);
      set.setDontNormalizeQualifiers(true);
      set.addSource(resPath.toFile());
      set.loadFromFiles(new ResourcesSetLoadLogger(context.getBuckEventBus()));
      merger.addDataSet(set);
    }
    MergedResourceWriter writer =
        MergedResourceWriter.createWriterWithoutPngCruncher(
            getOutFolderPath().toFile(),
            null /*publicFile*/,
            null /*blameLogFolder*/,
            new NoOpResourcePreprocessor(),
            getTmpFolderPath().toFile());
    merger.mergeData(writer, /* cleanUp */ false);
  } catch (MergingException e) {
    LOG.error(e, "Failed merging resources.");
    return StepExecutionResults.ERROR;
  }
  return StepExecutionResults.SUCCESS;
}
 
开发者ID:facebook,项目名称:buck,代码行数:27,代码来源:AbstractMergeAndroidResourceSourcesStep.java

示例2: doFullTaskAction

import com.android.ide.common.res2.ResourceSet; //导入方法依赖的package包/类
@Override
protected void doFullTaskAction() {
    // this is full run, clean the previous output
    File destinationDir = getOutputDir();
    emptyFolder(destinationDir);

    List<ResourceSet> resourceSets = getInputResourceSets();

    // create a new merger and populate it with the sets.
    ResourceMerger merger = new ResourceMerger();

    try {
        for (ResourceSet resourceSet : resourceSets) {
            resourceSet.setNormalizeResources(normalizeResources);
            // set needs to be loaded.
            resourceSet.loadFromFiles(getILogger());
            merger.addDataSet(resourceSet);
        }

        // get the merged set and write it down.
        MergedResourceWriter writer = new MergedResourceWriter(
                destinationDir, getCruncher(),
                getCrunchPng(), getProcess9Patch(), getPublicFile());
        writer.setInsertSourceMarkers(getInsertSourceMarkers());

        merger.mergeData(writer, false /*doCleanUp*/);

        // No exception? Write the known state.
        merger.writeBlobTo(getIncrementalFolder(), writer);
    } catch (MergingException e) {
        System.out.println(e.getMessage());
        merger.cleanBlob(getIncrementalFolder());
        throw new ResourceException(e.getMessage(), e);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:MergeResources.java

示例3: createRes2

import com.android.ide.common.res2.ResourceSet; //导入方法依赖的package包/类
/**
 * Creates a res2 resource repository for a resource folder whose contents is identified
 * by the pairs of relative paths and file contents
 *
 * @see #create(boolean, Object[])
 */
@SuppressWarnings("ResultOfMethodCallIgnored")
@NonNull
public static com.android.ide.common.res2.ResourceRepository createRes2(
        boolean isFramework, Object[] data)
        throws IOException, MergingException {
    File dir = Files.createTempDir();
    File res = new File(dir, FD_RES);
    res.mkdirs();

    assertTrue("Expected even number of items (path,contents)", data.length % 2 == 0);
    for (int i = 0; i < data.length; i += 2) {
        Object relativePathObject = data[i];
        assertTrue(relativePathObject instanceof String);
        String relativePath = (String) relativePathObject;
        relativePath = relativePath.replace('/', File.separatorChar);
        File file = new File(res, relativePath);
        File parent = file.getParentFile();
        parent.mkdirs();

        Object fileContents = data[i + 1];
        if (fileContents instanceof String) {
            String text = (String) fileContents;
            Files.write(text, file, Charsets.UTF_8);
        } else if (fileContents instanceof byte[]) {
            byte[] bytes = (byte[]) fileContents;
            Files.write(bytes, file);
        } else {
            fail("File contents must be Strings or byte[]'s");
        }
    }

    File resFolder = new File(dir, FD_RES);

    ResourceMerger merger = new ResourceMerger();
    ResourceSet resourceSet = new ResourceSet("main");
    resourceSet.addSource(resFolder);
    resourceSet.loadFromFiles(new RecordingLogger());
    merger.addDataSet(resourceSet);

    com.android.ide.common.res2.ResourceRepository repository;
    repository = new com.android.ide.common.res2.ResourceRepository(isFramework);
    merger.mergeData(repository.createMergeConsumer(), true /*doCleanUp*/);

    return repository;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:TestResourceRepository.java


注:本文中的com.android.ide.common.res2.ResourceSet.loadFromFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。