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;
}
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);
}
}
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;
}
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);
}
}
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;
}
Aggregations