Zhuinden / simple-stack

[ACTIVE] Simple Stack, a backstack library / navigation framework for simpler navigation and state management (for fragments, views, or whatevers).
Apache License 2.0
1.36k stars 76 forks source link

Multistack stack change with history #236

Closed uvaysss closed 3 years ago

uvaysss commented 3 years ago

Hi, I'm using your multistack implementation from sample, but having trouble by implementing some tricky navigation behavior. The case is that I need to navigate to a fragment that is in another stack. I'm trying to accomplish this by first selecting the stack and then setting history:

Multistack.setSelectedStack(identifier) Multistack.getSelectedStack().setHistory()

But I'm getting an incorrect behavior, all the fragments from the history are shown at the same time. I tried to call

Multistack.executePendingStateChange()

before setting the history, but the result is the same.

Zhuinden commented 3 years ago

But I'm getting an incorrect behavior, all the fragments from the history are shown at the same time.

That shouldn't happen as long as the keys are each data class (and therefore have a stable equals/hashCode/toString). 🤔

Are all of your keys data class?

uvaysss commented 3 years ago

Yes, they are data class.

uvaysss commented 3 years ago

But I've noticed that if I make a delay before history change like Handler.post {} than it works correct.

Zhuinden commented 3 years ago

Oh, I should be calling fragmentManager.executePendingTransactions() on the first line, and then probably apply the safety measures which is basically Handler.post {} that I also ended up adding to simple-stack-extensions

Valid find, I'll update it accordingly.

Zhuinden commented 3 years ago

Thanks!

uvaysss commented 3 years ago

Thank you for your quick response!