com.bluelinelabs.conductor.Conductor Java Examples

The following examples show how to use com.bluelinelabs.conductor.Conductor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From service-tree with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    serviceTree = Services.getTree();
    if(!serviceTree.hasNodeWithKey(TAG)) {
        ServiceTree.Node node = serviceTree.createRootNode(TAG);
        ApplicationComponent applicationComponent = node.getService(Services.DAGGER_COMPONENT);
        mainComponent = DaggerMainComponent.builder().applicationComponent(applicationComponent).build();
        node.bindService(Services.DAGGER_COMPONENT, mainComponent);
    } else {
        mainComponent = Services.getNode(TAG).getService(Services.DAGGER_COMPONENT);
    }
    mainComponent.inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    router = Conductor.attachRouter(this, root, savedInstanceState);
    router.addChangeListener(controllerChangeListener);
    if(!router.hasRootController()) {
        Log.d("MainActivity", "Set root [FirstController]");
        router.setRoot(RouterTransaction.with(new FirstController()));
    }
    previousState = router.getBackstack();
}
 
Example #2
Source File: MainActivity.java    From conductor-dagger with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  ViewGroup container = (ViewGroup) findViewById(R.id.controller_container);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  getSupportActionBar().setTitle("Conductor-Dagger Sample");

  router = Conductor.attachRouter(this, container, savedInstanceState);
  if (!router.hasRootController()) {
    router.setRoot(RouterTransaction.with(new MainController()));
  }
}
 
Example #3
Source File: ActivityMain.java    From AndroidStarterAlt with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle poSavedInstanceState) {
    super.onCreate(poSavedInstanceState);
    setContentView(R.layout.activity_main);

    ApplicationAndroidStarter.sharedApplication().componentApplication().inject(this);

    ButterKnife.bind(this);

    if (mEnvironment.isDebugDrawerEnabled()) {
        mDebugDrawer = new DebugDrawer.Builder(this).modules(
                new FpsModule(Takt.stock(getApplication())),
                new ScalpelModule(this),
                new PicassoModule(mPicasso),
                new DeviceModule(this),
                new BuildModule(this),
                new NetworkModule(this),
                new SettingsModule(this)
        ).build();
    }

    mRouter = Conductor.attachRouter(this, mViewGroupContainer, poSavedInstanceState);
    if (!mRouter.hasRootController()) {
        mRouter.setRoot(RouterTransaction.with(new ControllerRepoList()));
    }
}
 
Example #4
Source File: MainActivity.java    From simple-stack with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    if(getLastCustomNonConfigurationInstance() != null) {
        backstack = (Backstack) getLastCustomNonConfigurationInstance();
    } else {
        backstack = new Backstack();
        backstack.setup(History.of(HomeKey.create()));
        if(savedInstanceState != null) {
            backstack.fromBundle(savedInstanceState.getParcelable("backstack"));
        }
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    navigation.setOnNavigationItemSelectedListener(item -> {
        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;
    });
    router = Conductor.attachRouter(this, root, savedInstanceState);
    controllerStateChanger = new ControllerStateChanger(router);
    backstack.setStateChanger(this);
}
 
Example #5
Source File: MainActivity.java    From mosby-conductor with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);

    mRouter = Conductor.attachRouter(this, mBinding.container, savedInstanceState);
    if (!mRouter.hasRootController())
    {
        mMainController = new MainController();
        mRouter.setRoot(RouterTransaction
                .with(mMainController));
    }
}
 
Example #6
Source File: ConductorActivity.java    From EasyMVP with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    assertNotNull(view);

    router = Conductor.attachRouter(this, (ViewGroup) findViewById(R.id.container),
            savedInstanceState);
    if (!router.hasRootController()) {
        router.setRoot(RouterTransaction.with(new TestController()));
    }
}
 
Example #7
Source File: KlingarActivity.java    From klingar with Apache License 2.0 5 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  KlingarApp.get(this).component().inject(this);
  setContentView(R.layout.activity_klingar);
  ButterKnife.bind(this);

  router = Conductor.attachRouter(this, container, savedInstanceState);
  if (savedInstanceState == null) {
    if (loginManager.isLoggedOut()) {
      router.setRoot(RouterTransaction.with(new LoginController(null)));
    } else {
      router.setRoot(RouterTransaction.with(new BrowserController(null)));
    }
  }
}