bluelinelabs / bluelinelabs/Conductor
I don't understand popController(Controller controller)
- Dominant language
- Java
- Stars
- 3.9k
- Forks
- 338
- PR merge metrics
- No merged PRs in 30d
Description
I was wondering what happens when I call `popController(Controller controller)` with a controller which is not the top one. A small test app confirmed what I initially saw in the sources: _The not-top-controller gets removed, all controllers above it stay untouched and the controller directly below the not-top-controller gets activated in addition to the one which was and still is the top controller._
Can someone tell me if this is desired? What is the use case? I just don't understand it. IMHO such an API should not be exposed. But maybe I'm overseeing something.
**Some details of my test program:**
1. I pushed 6 new instances of `TextController` to the router of my `testContainer` and kept a reference to the 3rd one (IID=728) stored in `mTextController3`
Debug output of the complete controller hierarchy is now:
```
------------------------------------------------------------
[IID] C V A R D B Controller @ Container # Tag
------------------------------------------------------------
[2c6] 0 x x _ _ 0 ParentController @ myContainer
[720] 1 x x _ _ 5 + TextController @ testContainer
[846] 1 _ _ _ _ 4 TextController @ testContainer
[8cc] 1 _ _ _ _ 3 TextController @ testContainer
[728] 1 _ _ _ _ 2 TextController @ testContainer
[a45] 1 _ _ _ _ 1 TextController @ testContainer
[e36] 1 _ _ _ _ 0 TextController @ testContainer
------------------------------------------------------------
```
2. Then I called `.popController(mTextController3)`
These are the only lifecycle methods which are now called in the whole system:
```
[a45] TextController.onCreateView()
[a45] TextController.onRestoreViewState()
[a45] TextController.onAttach()
```
Debug output of the complete controller hierarchy is finally:
```
------------------------------------------------------------
[IID] C V A R D B Controller @ Container # Tag
------------------------------------------------------------
[2c6] 0 x x _ _ 0 ParentController @ myContainer
[720] 1 x x _ _ 4 + TextController @ testContainer
[846] 1 _ _ _ _ 3 TextController @ testContainer
[8cc] 1 _ _ _ _ 2 TextController @ testContainer
[a45] 1 x x _ _ 1 TextController @ testContainer
[e36] 1 _ _ _ _ 0 TextController @ testContainer
------------------------------------------------------------
```
**The views of controller 720 and a45 are now attached and visible at the same time !!!**
Legend:
```
IID = Controller.getInstanceId() // first 3 chars only
C = Controller.getArgs().size() // constructor params
V = Controller.getView() != null
A = Controller.isAttached()
R = Controller.getRetainViewMode() == RETAIN_DETACH
D = Controller.isDestroyed() / .isBeingDestroyed()
B = Index of the controller in its router's backstack
```
Contributor guide
Research direction
Start by reproducing the reported popController(mTextController3) scenario with six TextController instances and inspect the router's backstack and lifecycle handling. Compare the observed hierarchy and lifecycle callbacks with the intended behavior; done means the behavior is either corrected with a regression test or clearly documented as intentional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100