@Test public void shouldFindDrawableResources() throws Exception { Path testBaseDir = temporaryFolder.newFolder("res").toPath(); temporaryFolder.newFolder("res", "drawable"); temporaryFolder.newFile("res/drawable/foo.png"); ResourcePath resourcePath = new ResourcePath(null, testBaseDir, null); DrawableResourceLoader testLoader = new DrawableResourceLoader(resourceTable); testLoader.findDrawableResources(resourcePath); assertThat(resourceTable.getValue(new ResName("org.robolectric", "drawable", "foo"), new ResTable_config()).isFile()).isTrue(); } }
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"); } } } }
private TypedResource getAndResolve(int resId, String qualifiers, boolean resolveRefs) { TypedResource value = resourceLoader.getValue(resId, qualifiers); if (resolveRefs) { value = resolve(value, qualifiers, resId); } // todo: make the drawable loader put stuff into the normal spot... String resourceTypeName = getResourceTypeName(resId); if (value == null && DrawableResourceLoader.isStillHandledHere(resourceTypeName)) { FileTypedResource typedResource = (FileTypedResource) resourceLoader.getValue(resId, qualifiers); return new TypedResource<>(typedResource.getFsFile(), ResType.FILE); } // todo: gross. this is so resources.getString(R.layout.foo) works for ABS. if (value == null && "layout".equals(resourceTypeName)) { throw new UnsupportedOperationException("ugh, this doesn't work still?"); } return value; }
} else if (resName.type.equals("raw")) { return; } else if (DrawableResourceLoader.isStillHandledHere(resName.type)) {
loadOpaque(resourcePath, resourceTable, "interpolator", ResType.LAYOUT); new DrawableResourceLoader(resourceTable).findDrawableResources(resourcePath); new RawResourceLoader(resourcePath).loadTo(resourceTable); } catch (Exception e) {
/** * Returns a collection of resource IDs for all nine-patch drawables in the project. * * @param resourcePath Resource path. */ void findDrawableResources(ResourcePath resourcePath) { FsFile[] files = resourcePath.getResourceBase().listFiles(); if (files != null) { for (FsFile f : files) { if (f.isDirectory() && f.getName().startsWith("drawable")) { listDrawableResources(f, "drawable"); } else if (f.isDirectory() && f.getName().startsWith("mipmap")) { listDrawableResources(f, "mipmap"); } } } }
} else if (resName.type.equals("raw")) { return; } else if (DrawableResourceLoader.isStillHandledHere(resName.type)) {
loadOpaque(resourcePath, resourceTable, "interpolator", ResType.LAYOUT); new DrawableResourceLoader(resourceTable).findDrawableResources(resourcePath); new RawResourceLoader(resourcePath).loadTo(resourceTable); } catch (Exception e) {
/** * Returns a collection of resource IDs for all nine-patch drawables in the project. * * @param resourcePath Resource path. */ void findDrawableResources(ResourcePath resourcePath) { FsFile[] files = resourcePath.getResourceBase().listFiles(); if (files != null) { for (FsFile f : files) { if (f.isDirectory() && f.getName().startsWith("drawable")) { listDrawableResources(f, "drawable"); } else if (f.isDirectory() && f.getName().startsWith("mipmap")) { listDrawableResources(f, "mipmap"); } } } }
loadOpaque(resourcePath, resourceTable, "interpolator", ResType.LAYOUT); new DrawableResourceLoader(resourceTable).findDrawableResources(resourcePath); new RawResourceLoader(resourcePath).loadTo(resourceTable); } catch (Exception e) {