Search in sources :

Example 1 with SimpleStateChanger

use of com.zhuinden.simplestack.SimpleStateChanger in project simple-stack by Zhuinden.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivityMainBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    binding.navigation.setOnNavigationItemSelectedListener(item -> {
        Backstack backstack = Navigator.getBackstack(this);
        switch(item.getItemId()) {
            case R.id.navigation_home:
                backstack.setHistory(History.of(HomeKey.create()), StateChange.REPLACE);
                return true;
            case R.id.navigation_dashboard:
                backstack.setHistory(History.of(DashboardKey.create()), StateChange.REPLACE);
                return true;
            case R.id.navigation_notifications:
                backstack.setHistory(History.of(NotificationKey.create()), StateChange.REPLACE);
                return true;
        }
        return false;
    });
    fragmentStateChanger = new DefaultFragmentStateChanger(getSupportFragmentManager(), R.id.container);
    Navigator.configure().setStateChanger(new SimpleStateChanger(this)).install(this, binding.container, History.single(HomeKey.create()));
}
Also used : DefaultFragmentStateChanger(com.zhuinden.simplestackextensions.fragments.DefaultFragmentStateChanger) Backstack(com.zhuinden.simplestack.Backstack) SimpleStateChanger(com.zhuinden.simplestack.SimpleStateChanger)

Example 2 with SimpleStateChanger

use of com.zhuinden.simplestack.SimpleStateChanger 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);
    fragmentStateChanger = new SharedElementFragmentStateChanger(getSupportFragmentManager(), R.id.container);
    Navigator.configure().setStateChanger(new SimpleStateChanger(this)).install(this, findViewById(R.id.container), History.of(KittenGridKey.create()));
}
Also used : SharedElementFragmentStateChanger(com.example.fragmenttransitions.core.navigation.SharedElementFragmentStateChanger) SimpleStateChanger(com.zhuinden.simplestack.SimpleStateChanger)

Example 3 with SimpleStateChanger

use of com.zhuinden.simplestack.SimpleStateChanger in project simple-stack by Zhuinden.

the class MainActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    fragmentStateChanger = new DefaultFragmentStateChanger(getSupportFragmentManager(), R.id.container);
    Navigator.configure().setStateChanger(new SimpleStateChanger(this)).setScopedServices(new DefaultServiceProvider()).install(this, findViewById(R.id.container), History.of(WordListKey.create()));
}
Also used : DefaultFragmentStateChanger(com.zhuinden.simplestackextensions.fragments.DefaultFragmentStateChanger) SimpleStateChanger(com.zhuinden.simplestack.SimpleStateChanger) DefaultServiceProvider(com.zhuinden.simplestackextensions.services.DefaultServiceProvider)

Aggregations

SimpleStateChanger (com.zhuinden.simplestack.SimpleStateChanger)3 DefaultFragmentStateChanger (com.zhuinden.simplestackextensions.fragments.DefaultFragmentStateChanger)2 SharedElementFragmentStateChanger (com.example.fragmenttransitions.core.navigation.SharedElementFragmentStateChanger)1 Backstack (com.zhuinden.simplestack.Backstack)1 DefaultServiceProvider (com.zhuinden.simplestackextensions.services.DefaultServiceProvider)1