mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Fix issues with bottom navigation
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
bf71a90b8c
commit
baa317f6cf
@ -73,15 +73,4 @@ public class MagicBottomNavigationController extends BottomNavigationController
|
|||||||
}
|
}
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Supplied Controller must match a MenuItemId as defined in {@link BottomNavigationMenuItem} or
|
|
||||||
* an {@link IllegalArgumentException} will be thrown.
|
|
||||||
*
|
|
||||||
* @param controller
|
|
||||||
*/
|
|
||||||
public void navigateTo(Controller controller) {
|
|
||||||
BottomNavigationMenuItem item = BottomNavigationMenuItem.getEnum(controller.getClass());
|
|
||||||
navigateTo(item.getMenuResId(), controller);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,20 @@ public abstract class BottomNavigationController extends BaseController {
|
|||||||
/* Setup the BottomNavigationView with the constructor supplied Menu resource */
|
/* Setup the BottomNavigationView with the constructor supplied Menu resource */
|
||||||
bottomNavigationView.inflateMenu(getMenuResource());
|
bottomNavigationView.inflateMenu(getMenuResource());
|
||||||
|
|
||||||
|
bottomNavigationView.setOnNavigationItemSelectedListener(
|
||||||
|
new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
|
navigateTo(item.getItemId(), getControllerFor(item.getItemId()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttach(@NonNull View view) {
|
||||||
|
super.onAttach(view);
|
||||||
|
|
||||||
/* Fresh start, setup everything */
|
/* Fresh start, setup everything */
|
||||||
if (routerSavedStateBundles == null) {
|
if (routerSavedStateBundles == null) {
|
||||||
Menu menu = bottomNavigationView.getMenu();
|
Menu menu = bottomNavigationView.getMenu();
|
||||||
@ -154,21 +168,6 @@ public abstract class BottomNavigationController extends BaseController {
|
|||||||
childRouter.rebindIfNeeded();
|
childRouter.rebindIfNeeded();
|
||||||
lastActiveChildRouter = childRouter;
|
lastActiveChildRouter = childRouter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bottomNavigationView.setOnNavigationItemSelectedListener(
|
|
||||||
new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
||||||
if (currentlySelectedItemId != item.getItemId()) {
|
|
||||||
BottomNavigationController.this.destroyChildRouter(BottomNavigationController.this.getChildRouter(currentlySelectedItemId), currentlySelectedItemId);
|
|
||||||
currentlySelectedItemId = item.getItemId();
|
|
||||||
BottomNavigationController.this.configureRouter(BottomNavigationController.this.getChildRouter(currentlySelectedItemId), currentlySelectedItemId);
|
|
||||||
} else {
|
|
||||||
BottomNavigationController.this.resetCurrentBackstack();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,11 +218,9 @@ public abstract class BottomNavigationController extends BaseController {
|
|||||||
* BottomNavigationController#getControllerFor(int)}, using a {@link FadeChangeHandler}.
|
* BottomNavigationController#getControllerFor(int)}, using a {@link FadeChangeHandler}.
|
||||||
*/
|
*/
|
||||||
protected void resetCurrentBackstack() {
|
protected void resetCurrentBackstack() {
|
||||||
if (lastActiveChildRouter != null) {
|
lastActiveChildRouter.setRoot(RouterTransaction.with(this.getControllerFor(currentlySelectedItemId))
|
||||||
lastActiveChildRouter.setRoot(RouterTransaction.with(this.getControllerFor(currentlySelectedItemId))
|
.pushChangeHandler(new FadeChangeHandler())
|
||||||
.pushChangeHandler(new FadeChangeHandler())
|
.popChangeHandler(new FadeChangeHandler()));
|
||||||
.popChangeHandler(new FadeChangeHandler()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,7 +347,7 @@ public abstract class BottomNavigationController extends BaseController {
|
|||||||
* The childRouter should handleBack,
|
* The childRouter should handleBack,
|
||||||
* as this BottomNavigationController doesn't have a back step sensible to the user.
|
* as this BottomNavigationController doesn't have a back step sensible to the user.
|
||||||
*/
|
*/
|
||||||
return lastActiveChildRouter != null && lastActiveChildRouter.handleBack();
|
return lastActiveChildRouter.handleBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user