diff --git a/conductor/src/main/java/com/bluelinelabs/conductor/Backstack.kt b/conductor/src/main/java/com/bluelinelabs/conductor/Backstack.kt index 34158303..9d397499 100644 --- a/conductor/src/main/java/com/bluelinelabs/conductor/Backstack.kt +++ b/conductor/src/main/java/com/bluelinelabs/conductor/Backstack.kt @@ -16,11 +16,11 @@ internal class Backstack : Iterable { fun root(): RouterTransaction? = backstack.lastOrNull() - override fun iterator(): MutableIterator { - return backstack.iterator() - } + override fun iterator(): Iterator = backstack.toTypedArray().iterator() + + fun reverseIterator(): Iterator = backstack.reversed().iterator() - fun reverseIterator(): Iterator = backstack.descendingIterator() + fun remove(transaction: RouterTransaction) = backstack.remove(transaction) fun popTo(transaction: RouterTransaction): List { if (transaction in backstack) { @@ -99,4 +99,4 @@ internal class Backstack : Iterable { companion object { private const val KEY_ENTRIES = "Backstack.entries" } -} \ No newline at end of file +} diff --git a/conductor/src/main/java/com/bluelinelabs/conductor/Router.java b/conductor/src/main/java/com/bluelinelabs/conductor/Router.java index 7c4f5ac6..1f913e7d 100644 --- a/conductor/src/main/java/com/bluelinelabs/conductor/Router.java +++ b/conductor/src/main/java/com/bluelinelabs/conductor/Router.java @@ -193,7 +193,7 @@ public boolean popController(@NonNull Controller controller) { RouterTransaction transaction = iterator.next(); if (transaction.controller() == controller) { trackDestroyingController(transaction); - iterator.remove(); + backstack.remove(transaction); removedTransaction = transaction; } else if (removedTransaction != null) { if (needsNextTransactionAttach && !transaction.controller().isAttached()) {