com.bluelinelabs.conductor.RouterTransaction Java Examples
The following examples show how to use
com.bluelinelabs.conductor.RouterTransaction.
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 |
@Override public void onChangeCompleted(@Nullable Controller to, @Nullable Controller from, boolean isPush, @NonNull ViewGroup container, @NonNull ControllerChangeHandler handler) { List<RouterTransaction> newState = router.getBackstack(); Log.d("MainActivity", Arrays.toString(previousState.toArray()) + " :: " + Arrays.toString(newState.toArray())); for(RouterTransaction previousKey : previousState) { if(!newState.contains(previousKey)) { serviceTree.removeNodeAndChildren(serviceTree.getNode(previousKey)); Log.d("MainActivity", "Destroying [" + previousKey + "]"); } } for(RouterTransaction newKey : newState) { if(!serviceTree.hasNodeWithKey(newKey)) { ((BaseController) newKey.controller()).bindServices(serviceTree.createChildNode(serviceTree.getNode( TAG), newKey)); Log.d("MainActivity", "Bind service to [" + newKey + "]"); } } previousState = router.getBackstack(); }
Example #2
Source File: DetailController.java From klingar with Apache License 2.0 | 6 votes |
private void observePlayback() { disposables.add(musicController.state() .compose(bindUntilEvent(DETACH)) .compose(rx.flowableSchedulers()) .subscribe(state -> { switch (state) { case PlaybackStateCompat.STATE_ERROR: case PlaybackStateCompat.STATE_NONE: case PlaybackStateCompat.STATE_STOPPED: for (Router router : getChildRouters()) { removeChildRouter(router); } break; default: Router miniplayerRouter = getChildRouter(miniplayerContainer); if (!miniplayerRouter.hasRootController()) { miniplayerRouter.setRoot(RouterTransaction.with(new MiniPlayerController(null))); } } }, Rx::onError)); }
Example #3
Source File: BrowserController.java From klingar with Apache License 2.0 | 6 votes |
private void observePlayback() { disposables.add(musicController.state() .compose(bindUntilEvent(DETACH)) .compose(rx.flowableSchedulers()) .subscribe(state -> { switch (state) { case PlaybackStateCompat.STATE_ERROR: case PlaybackStateCompat.STATE_NONE: case PlaybackStateCompat.STATE_STOPPED: for (Router router : getChildRouters()) { removeChildRouter(router); } break; default: Router miniplayerRouter = getChildRouter(miniplayerContainer); if (!miniplayerRouter.hasRootController()) { miniplayerRouter.setRoot(RouterTransaction.with(new MiniPlayerController(null))); } } }, Rx::onError)); }
Example #4
Source File: ActivityMain.java From AndroidStarterAlt with Apache License 2.0 | 6 votes |
@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 #5
Source File: MainActivity.java From conductor-dagger with Apache License 2.0 | 6 votes |
@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 #6
Source File: MainActivity.java From service-tree with Apache License 2.0 | 6 votes |
@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 #7
Source File: MainActivity.java From mosby-conductor with Apache License 2.0 | 5 votes |
@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 #8
Source File: ConductorActivity.java From EasyMVP with Apache License 2.0 | 5 votes |
@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 #9
Source File: ControllerRepoList.java From AndroidStarterAlt with Apache License 2.0 | 5 votes |
@DebugLog @Override public void onViewEvent(final int piActionID, final Repo poRepo, final int piPosition, final View poView) { if (piActionID == CellRepo.ROW_PRESSED) { final ControllerRepoDetail loVC = new ControllerRepoDetail(poRepo.getBaseId()); final ControllerChangeHandler loChangeHandler = new CircularRevealChangeHandlerCompat(poView, mRecyclerView); final RouterTransaction loTransaction = RouterTransaction.with(loVC) .pushChangeHandler(loChangeHandler) .popChangeHandler(loChangeHandler); getRouter().pushController(loTransaction); } }
Example #10
Source File: KlingarActivity.java From klingar with Apache License 2.0 | 5 votes |
@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))); } } }
Example #11
Source File: LoginController.java From klingar with Apache License 2.0 | 5 votes |
private void login() { disableInput(); String username = usernameEdit.getText().toString(); String password = passwordEdit.getText().toString(); if (Strings.isBlank(username)) { usernameEdit.setError(invalidUsername); enableInput(); return; } if (Strings.isBlank(password) || password.length() < 8) { passwordEdit.setError(invalidPassword); enableInput(); return; } hideInputMethod(); invisible(loginForm); contentLoading.show(); disposables.add(plex.signIn(Credentials.basic(username, password)) .compose(bindUntilEvent(DETACH)) .compose(rx.singleSchedulers()) .subscribe(user -> { loginManager.login(user.authenticationToken); if (getActivity() != null) { getActivity().invalidateOptionsMenu(); } getRouter().setRoot(RouterTransaction.with(new BrowserController(null))); }, e -> { Rx.onError(e); loginManager.logout(); contentLoading.hide(); visible(loginForm); Toast.makeText(getActivity(), R.string.sign_in_failed, Toast.LENGTH_SHORT).show(); enableInput(); })); }
Example #12
Source File: BrowserController.java From klingar with Apache License 2.0 | 4 votes |
@OnClick(R.id.miniplayer_container) void onMiniplayerClicked() { getRouter().pushController(RouterTransaction.with(new PlayerController(null))); }
Example #13
Source File: BrowserController.java From klingar with Apache License 2.0 | 4 votes |
private void goToMediaType(MediaType mediaType) { Bundle args = new Bundle(); args.putParcelable(PLEX_ITEM, mediaType); getRouter().pushController(RouterTransaction.with(new BrowserController(args))); }
Example #14
Source File: BrowserController.java From klingar with Apache License 2.0 | 4 votes |
private void goToDetails(PlexItem plexItem) { Bundle args = new Bundle(); args.putParcelable(PLEX_ITEM, plexItem); getRouter().pushController(RouterTransaction.with(new DetailController(args))); }
Example #15
Source File: KlingarActivity.java From klingar with Apache License 2.0 | 4 votes |
private void logout() { musicController.stop(); loginManager.logout(); router.setRoot(RouterTransaction.with(new LoginController(null))); }
Example #16
Source File: DetailController.java From klingar with Apache License 2.0 | 4 votes |
@OnClick(R.id.miniplayer_container) void onMiniplayerClicked() { getRouter().pushController(RouterTransaction.with(new PlayerController(null))); }
Example #17
Source File: FirstController.java From service-tree with Apache License 2.0 | 4 votes |
@OnClick(R.id.first_button) public void clickFirst(View view) { getRouter().pushController(RouterTransaction.with(new SecondController())); }
Example #18
Source File: DetailController.java From klingar with Apache License 2.0 | 4 votes |
private void goToDetails(PlexItem plexItem) { Bundle args = new Bundle(); args.putParcelable(PLEX_ITEM, plexItem); getRouter().pushController(RouterTransaction.with(new DetailController(args))); }