Closed angusholder closed 1 year ago
Oof, that's an oversight on my part. My mistake on using an enhanced for-loop while using remove
, instead of iterating backwards.
The solution to this sort of issue is always to iterate backwards by index.
Should be fixed by https://github.com/Zhuinden/simple-stack/commit/c7b937c7a5430ec3dc211d01e12158d95e430104 and released as 2.6.5
Please report back if it solved your issue
Yup that's solved it, thanks a lot for the fast fix!
glad to hear :)
Currently if you call
Backstack.removeStateChangeCompletionListener()
from within the completion listener, it throws a ConcurrentModificationException in NavigationCore's loop:https://github.com/Zhuinden/simple-stack/blob/8d37157aee38ad54d3471b6e064ce9bb37ab86a1/simple-stack/src/main/java/com/zhuinden/simplestack/NavigationCore.java#L707-L711
I believe this could be solved by changing the above code to
Does that sound okay to change?
For context, my view controller is using
addStateChangeCompletionListener
to listen to enable NFC whenever it's in the foreground, and I remove the CompletionListener when my view controller's is destroyed (key is no longer in the backstack), like so:I can work around this for now by
Handler.post
ing theremoveStateChangeCompletionListener
call so it happens outside the loop. (This foreground stuff would probably be better as a service that implementsScopedServices.Activated
, but this is how my code is currently structured)Thanks for the library, it's really nice to use, a big improvement over Jetpack ViewModel!