Search in sources :

Example 26 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowSimpleCursorAdapter method getView.

@Implementation
public View getView(int position, View convertView, ViewGroup parent) {
    if (!mDataValid) {
        throw new IllegalStateException("this should only be called when the cursor is valid");
    }
    if (!mCursor.moveToPosition(position)) {
        throw new IllegalStateException("couldn't move cursor to position " + position);
    }
    View v;
    if (convertView == null) {
        v = newView(mContext, mCursor, parent);
    } else {
        v = convertView;
    }
    bindView(v, mContext, mCursor);
    return v;
}
Also used : ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Implementation(org.robolectric.annotation.Implementation)

Example 27 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowViewAnimator method setDisplayedChild.

@Implementation
public void setDisplayedChild(int whichChild) {
    currentChild = whichChild;
    for (int i = ((ViewGroup) realView).getChildCount() - 1; i >= 0; i--) {
        View child = ((ViewGroup) realView).getChildAt(i);
        child.setVisibility(i == whichChild ? View.VISIBLE : View.GONE);
    }
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) Implementation(org.robolectric.annotation.Implementation)

Example 28 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowTabHost method newTabSpec.

@Implementation
public android.widget.TabHost.TabSpec newTabSpec(java.lang.String tag) {
    TabSpec realTabSpec = Shadow.newInstanceOf(TabHost.TabSpec.class);
    Shadows.shadowOf(realTabSpec).setTag(tag);
    return realTabSpec;
}
Also used : TabHost(android.widget.TabHost) TabSpec(android.widget.TabHost.TabSpec) Implementation(org.robolectric.annotation.Implementation)

Example 29 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowWebView method ensureProviderCreated.

@HiddenApi
@Implementation
public void ensureProviderCreated() {
    final ClassLoader classLoader = getClass().getClassLoader();
    Class<?> webViewProviderClass = getClassNamed("android.webkit.WebViewProvider");
    Field mProvider;
    try {
        mProvider = WebView.class.getDeclaredField("mProvider");
        mProvider.setAccessible(true);
        if (mProvider.get(realView) == null) {
            Object provider = Proxy.newProxyInstance(classLoader, new Class[] { webViewProviderClass }, new InvocationHandler() {

                @Override
                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    if (method.getName().equals("getViewDelegate") || method.getName().equals("getScrollDelegate")) {
                        return Proxy.newProxyInstance(classLoader, new Class[] { getClassNamed("android.webkit.WebViewProvider$ViewDelegate"), getClassNamed("android.webkit.WebViewProvider$ScrollDelegate") }, new InvocationHandler() {

                            @Override
                            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                                return nullish(method);
                            }
                        });
                    }
                    return nullish(method);
                }
            });
            mProvider.set(realView, provider);
        }
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
Also used : Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) Field(java.lang.reflect.Field) RealObject(org.robolectric.annotation.RealObject) WebView(android.webkit.WebView) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Example 30 with Implementation

use of org.robolectric.annotation.Implementation in project robolectric by robolectric.

the class ShadowOverlayItem method hashCode.

@Override
@Implementation
public int hashCode() {
    int result = 13;
    result = title == null ? result : 19 * result + title.hashCode();
    result = snippet == null ? result : 19 * result + snippet.hashCode();
    result = geoPoint == null ? result : 19 * result + geoPoint.hashCode();
    return result;
}
Also used : GeoPoint(com.google.android.maps.GeoPoint) 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