use of com.hannesdorfmann.mosby3.sample.mvi.view.search.SearchFragment in project mosby by sockeqwe.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
unbinder = ButterKnife.bind(this);
toolbar.setTitle("Mosby MVI");
toolbar.inflateMenu(R.menu.activity_main_toolbar);
toolbar.setOnMenuItemClickListener(item -> {
getSupportFragmentManager().beginTransaction().setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out, android.R.anim.fade_in, android.R.anim.fade_out).add(R.id.drawerLayout, new SearchFragment()).addToBackStack("Search").commit();
return true;
});
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
if (savedInstanceState == null) {
showCategoryItems(MainMenuItem.HOME);
} else {
title = savedInstanceState.getString(KEY_TOOLBAR_TITLE);
toolbar.setTitle(title);
}
// TODO Create a Presenter & ViewState for this Activity
DependencyInjection dependencyInjection = SampleApplication.getDependencyInjection(this);
disposable = dependencyInjection.getMainMenuPresenter().getViewStateObservable().filter(state -> state instanceof MenuViewState.DataState).cast(MenuViewState.DataState.class).map(this::findSelectedMenuItem).subscribe(this::showCategoryItems);
clearSelectionRelay = dependencyInjection.getClearSelectionRelay();
}
Aggregations