I try to use Conductor library but have a problem with backstack. I have an activity with 4 buttons in bottom navigation panel. Each of the buttons in ACTIVITY opens 1 of the 4 controllers: - today news (root controller) - trending news - market news - regulatory news
I need to add all controlers to backstack, and when i tap on the back button i must return to previous controller. For example: Today -> Market -> Trending If i tap on the back button in Trending controller, i must to return to Market e.t.c. But now activity is closing when i tap on the back in any controller. How can i implement this behavior? This is the code in my activity:
@Override
public void navigateToMarketHighlights() {
MarketHighlightsController marketHighlightsController = new MarketHighlightsController();
router.pushController(RouterTransaction.with(marketHighlightsController)
.popChangeHandler(new FadeChangeHandler())
.pushChangeHandler(new FadeChangeHandler()));
}
@Override
public void navigateToTrendingNow() {
TrendingNowController trendingNowController = new TrendingNowController();
router.pushController(RouterTransaction.with(trendingNowController)
.popChangeHandler(new FadeChangeHandler())
.pushChangeHandler(new FadeChangeHandler()));
}
@Override
public void navigateToTodayView() {
TodayController todayController = new TodayController();
router.pushController(RouterTransaction.with(todayController)
.popChangeHandler(new FadeChangeHandler())
.pushChangeHandler(new FadeChangeHandler()));
}
@Override
public void navigateToRegulatoryUpdatesView() {
RegulatoryUpdatesController regulatoryUpdatesController = new RegulatoryUpdatesController();
router.pushController(RouterTransaction.with(regulatoryUpdatesController)
.popChangeHandler(new FadeChangeHandler())
.pushChangeHandler(new FadeChangeHandler()));
}
I guess you just forget to handle
onBackPressed()
in yourActivity
router.handleBack()
dealing with backstack navigation, so router pops backstack if this method called and returnstrue
, othervise (e.g backstack is empty) it returnsfalse