Search in sources :

Example 1 with SearchFragment

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();
}
Also used : MenuViewState(com.hannesdorfmann.mosby3.sample.mvi.view.menu.MenuViewState) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) SearchFragment(com.hannesdorfmann.mosby3.sample.mvi.view.search.SearchFragment) DependencyInjection(com.hannesdorfmann.mosby3.sample.mvi.dependencyinjection.DependencyInjection)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 DependencyInjection (com.hannesdorfmann.mosby3.sample.mvi.dependencyinjection.DependencyInjection)1 MenuViewState (com.hannesdorfmann.mosby3.sample.mvi.view.menu.MenuViewState)1 SearchFragment (com.hannesdorfmann.mosby3.sample.mvi.view.search.SearchFragment)1