use of org.robolectric.res.android.ResTableTheme in project robolectric by robolectric.
the class ShadowArscAssetManager method resolveAttrs.
@Implementation
@HiddenApi
protected static boolean resolveAttrs(long themeToken, int defStyleAttr, int defStyleRes, int[] inValues, int[] attrs, int[] outValues, int[] outIndices) {
if (themeToken == 0) {
throw new NullPointerException("theme token");
}
if (attrs == null) {
throw new NullPointerException("attrs");
}
if (outValues == null) {
throw new NullPointerException("out values");
}
final int NI = attrs.length;
final int NV = outValues.length;
if (NV < (NI * STYLE_NUM_ENTRIES)) {
throw new IndexOutOfBoundsException("out values too small");
}
int[] src = attrs;
// if (src == null) {
// return JNI_FALSE;
// }
int[] srcValues = inValues;
final int NSV = srcValues == null ? 0 : inValues.length;
int[] baseDest = outValues;
int destOffset = 0;
if (baseDest == null) {
return false;
}
int[] indices = null;
if (outIndices != null) {
if (outIndices.length > NI) {
indices = outIndices;
}
}
ResTableTheme theme = Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeToken);
boolean result = AttributeResolution.ResolveAttrs(theme, defStyleAttr, defStyleRes, srcValues, NSV, src, NI, baseDest, indices);
if (indices != null) {
// env.ReleasePrimitiveArrayCritical(outIndices, indices, 0);
}
return result;
}
use of org.robolectric.res.android.ResTableTheme in project robolectric by robolectric.
the class ShadowArscAssetManager method copyTheme.
@HiddenApi
@Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1)
public static void copyTheme(long destPtr, long sourcePtr) {
ResTableTheme dest = Registries.NATIVE_THEME_REGISTRY.getNativeObject(destPtr);
ResTableTheme src = Registries.NATIVE_THEME_REGISTRY.getNativeObject(sourcePtr);
dest.setTo(src);
}
use of org.robolectric.res.android.ResTableTheme in project robolectric by robolectric.
the class ShadowArscAssetManager method applyStyle.
@HiddenApi
@Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1)
protected static void applyStyle(long themeToken, int defStyleAttr, int defStyleRes, long xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) {
ResTableTheme theme = Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeToken);
ResXMLParser xmlParser = xmlParserToken == 0 ? null : Registries.NATIVE_RES_XML_PARSERS.getNativeObject(xmlParserToken);
AttributeResolution.ApplyStyle(theme, xmlParser, defStyleAttr, defStyleRes, attrs, attrs.length, outValues, outIndices);
}
use of org.robolectric.res.android.ResTableTheme in project robolectric by robolectric.
the class ShadowArscAssetManager method loadThemeAttributeValue.
@HiddenApi
@Implementation(minSdk = LOLLIPOP)
protected static int loadThemeAttributeValue(long themeHandle, int ident, TypedValue outValue, boolean resolve) {
ResTableTheme theme = Preconditions.checkNotNull(Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeHandle));
ResTable res = theme.getResTable();
final Ref<Res_value> value = new Ref<>(null);
// XXX value could be different in different configs!
final Ref<Integer> typeSpecFlags = new Ref<>(0);
int block = theme.GetAttribute(ident, value, typeSpecFlags);
final Ref<Integer> ref = new Ref<>(0);
if (resolve) {
block = res.resolveReference(value, block, ref, typeSpecFlags);
if (kThrowOnBadId) {
if (block == BAD_INDEX) {
throw new IllegalStateException("Bad resource!");
}
}
}
return block >= 0 ? copyValue(outValue, res, value.get(), ref.get(), block, typeSpecFlags.get(), null) : block;
}
use of org.robolectric.res.android.ResTableTheme in project robolectric by robolectric.
the class ShadowArscAssetManager method newTheme.
@HiddenApi
@Implementation
protected final Number newTheme() {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return RuntimeEnvironment.castNativePtr(0);
}
ResTableTheme theme = new ResTableTheme(am.getResources());
return RuntimeEnvironment.castNativePtr(Registries.NATIVE_THEME_REGISTRY.register(theme));
}
Aggregations