use of com.zhuinden.simplestack.navigator.DefaultStateChanger in project simple-stack by Zhuinden.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
defaultStateChanger = DefaultStateChanger.create(this, root);
Backstack backstack = Navigator.configure().setStateChanger(new NoOpStateChanger()).setDeferredInitialization(true).install(this, root, HistoryBuilder.single(FirstKey.create()));
disposable = RxStackObservable.create(backstack).subscribe(stateChange -> {
if (stateChange.topNewState().equals(stateChange.topPreviousState())) {
return;
}
defaultStateChanger.performViewChange(stateChange.topPreviousState(), stateChange.topNewState(), stateChange, () -> {
});
});
Navigator.executeDeferredInitialization(this);
}
use of com.zhuinden.simplestack.navigator.DefaultStateChanger in project simple-stack by Zhuinden.
the class BackstackDelegateActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
backstackDelegate = new BackstackDelegate(null);
//
backstackDelegate.onCreate(//
savedInstanceState, //
getLastCustomNonConfigurationInstance(), HistoryBuilder.single(FirstKey.create()));
defaultStateChanger = DefaultStateChanger.configure().setStatePersistenceStrategy(new DefaultStateChanger.StatePersistenceStrategy() {
@Override
public void persistViewToState(@NonNull Object previousKey, @NonNull View previousView) {
backstackDelegate.persistViewToState(previousView);
}
@Override
public void restoreViewFromState(@NonNull Object newKey, @NonNull View newView) {
backstackDelegate.restoreViewFromState(newView);
}
}).create(this, root);
backstackDelegate.setStateChanger(defaultStateChanger);
}
Aggregations