use of org.jetbrains.android.dom.resources.ResourceElement in project android by JetBrains.
the class ThemeAttributeResolverTest method createNewStyle.
public boolean createNewStyle(@NotNull final VirtualFile resourceDir, @NotNull final String newStyleName, @NotNull final String parentStyleName, @Nullable final String colorPrimaryValue, @NotNull final List<String> folders) {
return new WriteCommandAction<Boolean>(getProject(), "Create new style " + newStyleName) {
@Override
protected void run(@NotNull Result<Boolean> result) {
result.setResult(AndroidResourceUtil.createValueResource(getProject(), resourceDir, newStyleName, null, ResourceType.STYLE, "styles.xml", folders, new Processor<ResourceElement>() {
@Override
public boolean process(ResourceElement element) {
assert element instanceof Style;
final Style style = (Style) element;
style.getParentStyle().setStringValue(parentStyleName);
if (colorPrimaryValue != null) {
StyleItem styleItem = style.addItem();
styleItem.getName().setStringValue("colorPrimary");
styleItem.setStringValue(colorPrimaryValue);
}
return true;
}
}));
}
}.execute().getResultObject();
}
Aggregations