Search in sources :

Example 21 with Implementation

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

the class ShadowSimpleCursorAdapter method bindView.

@Implementation
public void bindView(View view, Context context, Cursor cursor) {
    final ViewBinder binder = mViewBinder;
    final int count = mTo.length;
    final int[] from = mFrom;
    final int[] to = mTo;
    for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }
            if (!bound) {
                String text = cursor.getString(from[i]);
                if (text == null) {
                    text = "";
                }
                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a " + " view that can be bounds by this SimpleCursorAdapter");
                }
            }
        }
    }
}
Also used : TextView(android.widget.TextView) ViewBinder(android.widget.SimpleCursorAdapter.ViewBinder) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Implementation(org.robolectric.annotation.Implementation)

Example 22 with Implementation

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

the class ShadowSimpleCursorAdapter method getDropDownView.

@Implementation
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    if (mDataValid) {
        mCursor.moveToPosition(position);
        View v;
        if (convertView == null) {
            v = newDropDownView(mContext, mCursor, parent);
        } else {
            v = convertView;
        }
        bindView(v, mContext, mCursor);
        return v;
    } else {
        return null;
    }
}
Also used : ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Implementation(org.robolectric.annotation.Implementation)

Example 23 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 24 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 25 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)

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