@Implementation public final boolean showDialog(int id, Bundle bundle) { Dialog dialog = null; this.lastShownDialogId = id; dialog = dialogForId.get(id); if (dialog == null) { final ActivityInvoker invoker = new ActivityInvoker(); dialog = (Dialog) invoker.call("onCreateDialog", Integer.TYPE).with(id); 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; }
public Object withNothing() { return with(); }
@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(); }
public void pauseAndThenResume() { final ActivityInvoker invoker = new ActivityInvoker(); invoker.call("onPause").withNothing(); invoker.call("onStop").withNothing(); invoker.call("onRestart").withNothing(); invoker.call("onStart").withNothing(); invoker.call("onResume").withNothing(); }
public void receiveResult(Intent requestIntent, int resultCode, Intent resultIntent) { Integer requestCode = intentRequestCodeMap.get(requestIntent); if (requestCode == null) { throw new RuntimeException("No intent matches " + requestIntent + " among " + intentRequestCodeMap.keySet()); } final ActivityInvoker invoker = new ActivityInvoker(); invoker.call("onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class) .with(requestCode, resultCode, resultIntent); }
public void create() { final ActivityInvoker invoker = new ActivityInvoker(); final Bundle noInstanceState = null; invoker.call("onCreate", Bundle.class).with(noInstanceState); invoker.call("onStart").withNothing(); invoker.call("onPostCreate", Bundle.class).with(noInstanceState); invoker.call("onResume").withNothing(); }