use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowMediaPlayer method create.
@Implementation
public static MediaPlayer create(Context context, int resId) {
MediaPlayer mp = new MediaPlayer();
ShadowMediaPlayer shadow = shadowOf(mp);
shadow.sourceResId = resId;
try {
shadow.setState(INITIALIZED);
mp.prepare();
} catch (Exception e) {
return null;
}
return mp;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowMediaPlayer method create.
@Implementation
public static MediaPlayer create(Context context, Uri uri) {
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(context, uri);
mp.prepare();
} catch (Exception e) {
return null;
}
return mp;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowAssetManager method getArrayIntResource.
@HiddenApi
@Implementation
public int[] getArrayIntResource(int resId) {
TypedResource value = getAndResolve(resId, RuntimeEnvironment.getQualifiers(), true);
if (value == null)
return null;
TypedResource[] items = getConverter(value).getItems(value);
int[] ints = new int[items.length];
for (int i = 0; i < items.length; i++) {
TypedResource typedResource = resolve(items[i], RuntimeEnvironment.getQualifiers(), resId);
ints[i] = getConverter(typedResource).asInt(typedResource);
}
return ints;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowAssetManager method getResourceTextArray.
@HiddenApi
@Implementation
public CharSequence[] getResourceTextArray(int resId) {
TypedResource value = getAndResolve(resId, RuntimeEnvironment.getQualifiers(), true);
if (value == null)
return null;
TypedResource[] items = getConverter(value).getItems(value);
CharSequence[] charSequences = new CharSequence[items.length];
for (int i = 0; i < items.length; i++) {
TypedResource typedResource = resolve(items[i], RuntimeEnvironment.getQualifiers(), resId);
charSequences[i] = getConverter(typedResource).asCharSequence(typedResource);
}
return charSequences;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowAssetManager method getThemeValue.
@HiddenApi
@Implementation(minSdk = LOLLIPOP)
public boolean getThemeValue(long themePtr, int ident, TypedValue outValue, boolean resolveRefs) {
ResName resName = resourceTable.getResName(ident);
ThemeStyleSet themeStyleSet = getNativeTheme(themePtr).themeStyleSet;
AttributeResource attrValue = themeStyleSet.getAttrValue(resName);
while (attrValue != null && attrValue.isStyleReference()) {
ResName attrResName = attrValue.getStyleReference();
if (attrValue.resName.equals(attrResName)) {
Logger.info("huh... circular reference for %s?", attrResName.getFullyQualifiedName());
return false;
}
attrValue = themeStyleSet.getAttrValue(attrResName);
}
if (attrValue != null) {
convertAndFill(attrValue, outValue, RuntimeEnvironment.getQualifiers(), resolveRefs);
return true;
}
return false;
}
Aggregations