use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowAccessibilityWindowInfo method obtain.
@Implementation
public static AccessibilityWindowInfo obtain() {
final AccessibilityWindowInfo obtainedInstance = ReflectionHelpers.callConstructor(AccessibilityWindowInfo.class);
StrictEqualityWindowWrapper wrapper = new StrictEqualityWindowWrapper(obtainedInstance);
obtainedInstances.put(wrapper, Thread.currentThread().getStackTrace());
return obtainedInstance;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowAccessibilityWindowInfo method equals.
@Override
@Implementation
public boolean equals(Object object) {
if (!(object instanceof AccessibilityWindowInfo)) {
return false;
}
final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object;
final ShadowAccessibilityWindowInfo otherShadow = (ShadowAccessibilityWindowInfo) ShadowExtractor.extract(window);
boolean areEqual = (type == otherShadow.getType());
areEqual &= (parent == otherShadow.getParent());
areEqual &= (rootNode == otherShadow.getRoot());
areEqual &= (layer == otherShadow.getLayer());
areEqual &= (id == otherShadow.getId());
areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused());
areEqual &= (isActive == otherShadow.isActive());
areEqual &= (isFocused == otherShadow.isFocused());
Rect anotherBounds = new Rect();
otherShadow.getBoundsInScreen(anotherBounds);
areEqual &= (boundsInScreen.equals(anotherBounds));
return areEqual;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowActivity method recreate.
@Implementation
public void recreate() {
Bundle outState = new Bundle();
final ActivityInvoker invoker = new ActivityInvoker();
invoker.call("onSaveInstanceState", Bundle.class).with(outState);
invoker.call("onPause").withNothing();
invoker.call("onStop").withNothing();
Object nonConfigInstance = invoker.call("onRetainNonConfigurationInstance").withNothing();
setLastNonConfigurationInstance(nonConfigInstance);
invoker.call("onDestroy").withNothing();
invoker.call("onCreate", Bundle.class).with(outState);
invoker.call("onStart").withNothing();
invoker.call("onRestoreInstanceState", Bundle.class).with(outState);
invoker.call("onResume").withNothing();
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowActivity method getWindow.
/**
* Constructs a new Window (a {@link com.android.internal.policy.impl.PhoneWindow}) if no window has previously been
* set.
*
* @return the window associated with this Activity
*/
@Implementation
public Window getWindow() {
Window window = directlyOn(realActivity, Activity.class).getWindow();
if (window == null) {
try {
window = ShadowWindow.create(realActivity);
setWindow(window);
} catch (Exception e) {
throw new RuntimeException("Window creation failed!", e);
}
}
return window;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowActivity method showDialog.
@Implementation
public final boolean showDialog(int id, Bundle bundle) {
this.lastShownDialogId = id;
Dialog dialog = dialogForId.get(id);
if (dialog == null) {
final ActivityInvoker invoker = new ActivityInvoker();
dialog = (Dialog) invoker.call("onCreateDialog", Integer.TYPE).with(id);
if (dialog == null) {
return false;
}
if (bundle == null) {
invoker.call("onPrepareDialog", Integer.TYPE, Dialog.class).with(id, dialog);
} else {
invoker.call("onPrepareDialog", Integer.TYPE, Dialog.class, Bundle.class).with(id, dialog, bundle);
}
dialogForId.put(id, dialog);
}
dialog.show();
return true;
}
Aggregations