use of com.android.ide.common.rendering.api.StyleResourceValue in project android_frameworks_base by ResurrectionRemix.
the class AppCompatActionBar method getInflater.
@Override
protected LayoutInflater getInflater(BridgeContext context) {
// Other than the resource resolution part, the code has been taken from the support
// library. see code from line 269 onwards in
// https://android.googlesource.com/platform/frameworks/support/+/android-5.1.0_r1/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateBase.java
Context themedContext = context;
RenderResources resources = context.getRenderResources();
ResourceValue actionBarTheme = resources.findItemInTheme("actionBarTheme", false);
if (actionBarTheme != null) {
// resolve it, if needed.
actionBarTheme = resources.resolveResValue(actionBarTheme);
}
if (actionBarTheme instanceof StyleResourceValue) {
int styleId = context.getDynamicIdByStyle(((StyleResourceValue) actionBarTheme));
if (styleId != 0) {
themedContext = new ContextThemeWrapper(context, styleId);
}
}
return LayoutInflater.from(themedContext);
}
use of com.android.ide.common.rendering.api.StyleResourceValue in project android_frameworks_base by ResurrectionRemix.
the class BridgeContext method resolveThemeAttribute.
public boolean resolveThemeAttribute(int resId, TypedValue outValue, boolean resolveRefs) {
Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(resId);
boolean isFrameworkRes = true;
if (resourceInfo == null) {
resourceInfo = mLayoutlibCallback.resolveResourceId(resId);
isFrameworkRes = false;
}
if (resourceInfo == null) {
return false;
}
ResourceValue value = mRenderResources.findItemInTheme(resourceInfo.getSecond(), isFrameworkRes);
if (resolveRefs) {
value = mRenderResources.resolveResValue(value);
}
if (value == null) {
// unable to find the attribute.
return false;
}
// check if this is a style resource
if (value instanceof StyleResourceValue) {
// get the id that will represent this style.
outValue.resourceId = getDynamicIdByStyle((StyleResourceValue) value);
return true;
}
int a;
// if this is a framework value.
if (value.isFramework()) {
// look for idName in the android R classes.
// use 0 a default res value as it's not a valid id value.
a = getFrameworkResourceValue(value.getResourceType(), value.getName(), 0);
} else {
// look for idName in the project R class.
// use 0 a default res value as it's not a valid id value.
a = getProjectResourceValue(value.getResourceType(), value.getName(), 0);
}
if (a != 0) {
outValue.resourceId = a;
return true;
}
return false;
}
use of com.android.ide.common.rendering.api.StyleResourceValue in project android_frameworks_base by ResurrectionRemix.
the class Resources_Theme_Delegate method resolveStyle.
@Nullable
private static StyleResourceValue resolveStyle(int nativeResid) {
if (nativeResid == 0) {
return null;
}
BridgeContext context = RenderSessionImpl.getCurrentContext();
ResourceReference theme = context.resolveId(nativeResid);
if (theme.isFramework()) {
return (StyleResourceValue) context.getRenderResources().getFrameworkResource(ResourceType.STYLE, theme.getName());
} else {
return (StyleResourceValue) context.getRenderResources().getProjectResource(ResourceType.STYLE, theme.getName());
}
}
use of com.android.ide.common.rendering.api.StyleResourceValue in project android_frameworks_base by crdroidandroid.
the class Resources_Theme_Delegate method resolveStyle.
@Nullable
private static StyleResourceValue resolveStyle(int nativeResid) {
if (nativeResid == 0) {
return null;
}
BridgeContext context = RenderSessionImpl.getCurrentContext();
ResourceReference theme = context.resolveId(nativeResid);
if (theme.isFramework()) {
return (StyleResourceValue) context.getRenderResources().getFrameworkResource(ResourceType.STYLE, theme.getName());
} else {
return (StyleResourceValue) context.getRenderResources().getProjectResource(ResourceType.STYLE, theme.getName());
}
}
use of com.android.ide.common.rendering.api.StyleResourceValue in project android_frameworks_base by crdroidandroid.
the class Resources_Theme_Delegate method setupResources.
// ---- private helper methods ----
private static boolean setupResources(Theme thisTheme) {
// Key is a space-separated list of theme ids applied that have been merged into the
// BridgeContext's theme to make thisTheme.
final ThemeKey key = thisTheme.getKey();
final int[] resId = key.mResId;
final boolean[] force = key.mForce;
boolean changed = false;
for (int i = 0, N = key.mCount; i < N; i++) {
StyleResourceValue style = resolveStyle(resId[i]);
if (style != null) {
RenderSessionImpl.getCurrentContext().getRenderResources().applyStyle(style, force[i]);
changed = true;
}
}
return changed;
}
Aggregations