use of com.android.tools.build.bundletool.model.utils.ResourcesUtils in project bundletool by google.
the class DumpManager method printResources.
void printResources(Predicate<ResourceTableEntry> resourcePredicate, boolean printValues) {
ImmutableList<ResourceTable> resourceTables;
try (ZipFile zipFile = new ZipFile(bundlePath.toFile())) {
resourceTables = ZipUtils.allFileEntriesPaths(zipFile).filter(path -> path.endsWith(SpecialModuleEntry.RESOURCE_TABLE.getPath())).map(path -> extractAndParse(zipFile, path, ResourceTable::parseFrom)).collect(toImmutableList());
} catch (IOException e) {
throw new UncheckedIOException("Error occurred when reading the bundle.", e);
}
ImmutableListMultimap<String, ResourceTableEntry> entriesByPackageName = resourceTables.stream().flatMap(ResourcesUtils::entries).filter(resourcePredicate).collect(groupingBySortedKeys(entry -> entry.getPackage().getPackageName()));
for (String packageName : entriesByPackageName.keySet()) {
printStream.printf("Package '%s':%n", packageName);
entriesByPackageName.get(packageName).forEach(entry -> printEntry(entry, printValues));
printStream.println();
}
}
Aggregations