use of io.reactivex.functions.Action in project Conductor by bluelinelabs.
the class RxLifecycle2Controller method onAttach.
@Override
protected void onAttach(@NonNull View view) {
super.onAttach(view);
Log.i(TAG, "onAttach() called");
(((ActionBarProvider) getActivity()).getSupportActionBar()).setTitle("RxLifecycle2 Demo");
Observable.interval(1, TimeUnit.SECONDS).doOnDispose(new Action() {
@Override
public void run() {
Log.i(TAG, "Disposing from onAttach()");
}
}).compose(this.<Long>bindUntilEvent(ControllerEvent.DETACH)).subscribe(new Consumer<Long>() {
@Override
public void accept(Long num) {
Log.i(TAG, "Started in onAttach(), running until onDetach(): " + num);
}
});
}
use of io.reactivex.functions.Action in project nhglib by VoidZombie.
the class SceneManager method unloadScene.
public void unloadScene(final Scene scene) {
Observable.fromIterable(scene.sceneGraph.getEntities()).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer entity) throws Exception {
return modelMapper.has(entity);
}
}).doFinally(new Action() {
@Override
public void run() throws Exception {
int rootEntity = scene.sceneGraph.getRootEntity();
NodeComponent nodeComponent = nodeMapper.get(rootEntity);
nodeComponent.setTranslation(0, 0, 0);
nodeComponent.setRotation(0, 0, 0);
nodeComponent.setScale(1, 1, 1);
nodeComponent.applyTransforms();
}
}).subscribe(new Consumer<Integer>() {
@Override
public void accept(Integer integer) throws Exception {
ModelComponent modelComponent = modelMapper.get(integer);
assets.unloadAsset(modelComponent.asset);
}
});
}
use of io.reactivex.functions.Action in project simple-stack by Zhuinden.
the class MortarDemoActivity method handleStateChange.
@Override
public void handleStateChange(StateChange stateChange, Callback completionCallback) {
BaseKey newScreen = stateChange.topNewState();
String title = newScreen.title();
ActionBarOwner.MenuAction menu = new ActionBarOwner.MenuAction("Friends", new Action() {
@Override
public void run() throws Exception {
Navigator.getBackstack(MortarDemoActivity.this).goTo(FriendListScreen.create());
}
});
actionBarOwner.setConfig(new ActionBarOwner.Config(false, !(newScreen instanceof ChatListScreen), title, menu));
completionCallback.stateChangeComplete();
}
use of io.reactivex.functions.Action in project RxJava by ReactiveX.
the class CompletableTimeoutTest method timeoutContinueOther.
@Test
public void timeoutContinueOther() throws Exception {
final int[] call = { 0 };
Completable other = Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
call[0]++;
}
});
Completable.never().timeout(100, TimeUnit.MILLISECONDS, Schedulers.io(), other).test().awaitDone(5, TimeUnit.SECONDS).assertResult();
assertEquals(1, call[0]);
}
use of io.reactivex.functions.Action in project RxJava by ReactiveX.
the class CompletableFromActionTest method fromActionInvokesLazy.
@Test
public void fromActionInvokesLazy() {
final AtomicInteger atomicInteger = new AtomicInteger();
Completable completable = Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
atomicInteger.incrementAndGet();
}
});
assertEquals(0, atomicInteger.get());
completable.test().assertResult();
assertEquals(1, atomicInteger.get());
}
Aggregations