Thank you for your main hint that I have to first load the theme and then to precess to style menu.
After uncountable hours of debugging I got the solution:
themesDir = new File(getExternalFilesDir(null), "Elevate");
themeFile = new File(themesDir, THEME_ELEVATE_FILE);
try {
xmlRenderTheme = new ExternalRenderTheme(themeFile, new XmlRenderThemeMenuCallback() {
@Override
public Set<String> getCategories(XmlRenderThemeStyleMenu style) {
renderThemeStyleId = sharedPreferences.getString(style.getId(),
style.getDefaultValue());
XmlRenderThemeStyleLayer baseLayer = style.getLayer(renderThemeStyleId);
if (baseLayer == null) {
Log.w("L", "Invalid style " + renderThemeStyleId);
return null;
}
Set<String> result = baseLayer.getCategories();
// add the categories from overlays that are enabled
for (XmlRenderThemeStyleLayer overlay : baseLayer.getOverlays()) {
if (sharedPreferences.getBoolean(overlay.getId(), overlay.isEnabled())) {
result.addAll(overlay.getCategories());
}
}
return result;
}
});
RenderThemeHandler.getRenderTheme(AndroidGraphicFactory.INSTANCE, new DisplayModel(), xmlRenderTheme);
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return;