Search in sources :

Example 76 with Implementation

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;
}
Also used : IOException(java.io.IOException) MediaPlayer(android.media.MediaPlayer) Implementation(org.robolectric.annotation.Implementation)

Example 77 with Implementation

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;
}
Also used : IOException(java.io.IOException) MediaPlayer(android.media.MediaPlayer) Implementation(org.robolectric.annotation.Implementation)

Example 78 with Implementation

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;
}
Also used : FileTypedResource(org.robolectric.res.FileTypedResource) TypedResource(org.robolectric.res.TypedResource) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Example 79 with Implementation

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;
}
Also used : FileTypedResource(org.robolectric.res.FileTypedResource) TypedResource(org.robolectric.res.TypedResource) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Example 80 with Implementation

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;
}
Also used : AttributeResource(org.robolectric.res.AttributeResource) ThemeStyleSet(org.robolectric.res.ThemeStyleSet) ResName(org.robolectric.res.ResName) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Aggregations

Implementation (org.robolectric.annotation.Implementation)114 Bitmap (android.graphics.Bitmap)17 HiddenApi (org.robolectric.annotation.HiddenApi)10 BitmapDrawable (android.graphics.drawable.BitmapDrawable)6 View (android.view.View)6 IOException (java.io.IOException)6 ContentProvider (android.content.ContentProvider)5 IContentProvider (android.content.IContentProvider)5 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)5 Rect (android.graphics.Rect)4 Message (android.os.Message)4 RealObject (org.robolectric.annotation.RealObject)4 FileTypedResource (org.robolectric.res.FileTypedResource)4 Point (android.graphics.Point)3 AccessibilityWindowInfo (android.view.accessibility.AccessibilityWindowInfo)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 LinkedList (java.util.LinkedList)3 Activity (android.app.Activity)2 Dialog (android.app.Dialog)2