8000 Simplify and improve `previousBackStackEntry` in `NavController` by ShreckYe · Pull Request #742 · androidx/androidx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Simplify and improve previousBackStackEntry in NavController #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: androidx-main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2963,14 +2963,10 @@ public open class NavController(
* two visible entries
*/
public open val previousBackStackEntry: NavBackStackEntry?
get() {
val iterator = backQueue.reversed().iterator()
get() = backQueue.asReversed().asSequence()
// throw the topmost destination away.
if (iterator.hasNext()) {
iterator.next()
}
return iterator.asSequence().firstOrNull { entry -> entry.destination !is NavGraph }
}
.drop(1)
.firstOrNull { entry -> entry.destination !is NavGraph }

public companion object {
private const val TAG = "NavController"
Expand Down
0