Repository navigation
feat(android): Nav3 support for multi-Activity and multi-Fragment applications #6301
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c464ea3
collection: Sentry NavEffect lifecycle
0xadam-brown f3025c6
ref(android): Add NavLeaseCoordinator (JAVA-785) (#6302)
0xadam-brown b67f3bf
ref(android): Add NavScopes (JAVA-785) (#6304)
0xadam-brown 723b40a
feat(android): Coordinate SentryNavEffect access to current IScope (J…
0xadam-brown 9523053
test(android): Integration tests for SentryNavEffect lifecycle handof…
0xadam-brown e495908
feat(sample): Add Nav3 lifecycle scenarios to sample app (JAVA-785) (…
0xadam-brown ca08edb
build(android): Publish lifecycle runtime dependency
0xadam-brown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...navigation3/src/main/kotlin/io/sentry/compose/navigation3/CoordinatedBackStackObserver.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package io.sentry.compose.navigation3 | ||
|
|
||
| import androidx.lifecycle.Lifecycle | ||
| import androidx.lifecycle.LifecycleEventObserver | ||
| import io.sentry.IScope | ||
| import io.sentry.IScopes | ||
| import io.sentry.compose.navigation3.lifecycle.NavLeaseCoordinator | ||
| import io.sentry.compose.navigation3.lifecycle.NavScopes | ||
|
|
||
| /** | ||
| * A [BackStackObserver] whose updates to a shared mutable [IScope] are coordinated with other | ||
| * `BackStackObserver`s. | ||
| * | ||
| * Coordination is achieved via [NavScopes]. | ||
| * | ||
| * **Usage** | ||
| * | ||
| * Call [attach] before the first [onBackStackChanged], and call [dispose] when observation ends. | ||
| * | ||
| * Instances targeting the same [IScope] must be created with the same [NavLeaseCoordinator]. | ||
| * | ||
| * **Thread safety** | ||
| * | ||
| * This class is ***not*** thread-safe. Invocations should be confined to the same thread as the | ||
| * [LifecycleEventObserver] callbacks implemented by [NavScopes]. | ||
| */ | ||
| internal class CoordinatedBackStackObserver<T : Any>( | ||
| scopes: IScopes, | ||
| options: SentryNavOptions, | ||
| entryMapper: ForwardingBackStackEntryMapper<T>, | ||
| coordinator: NavLeaseCoordinator, | ||
| ) { | ||
|
|
||
| private val navScopes = NavScopes(scopes, coordinator) | ||
| private val observer = BackStackObserver(navScopes, options, entryMapper) | ||
|
|
||
| fun attach(lifecycle: Lifecycle) { | ||
| navScopes.attach(lifecycle) | ||
| } | ||
|
|
||
| fun onBackStackChanged(backStack: List<T>) { | ||
| navScopes.onBackStackUpdate() | ||
| observer.onBackStackChanged(backStack) | ||
| } | ||
|
|
||
| fun dispose() { | ||
| // Call disposal on both the observer and navScopes in case their (currently overlapping) | ||
| // implementations drift over time. | ||
| observer.dispose() | ||
| navScopes.dispose() | ||
| } | ||
| } | ||
|
|
||
| /** The [NavLeaseCoordinator] shared by default by all [SentryNavEffect]s. */ | ||
| internal val defaultNavLeaseCoordinator: NavLeaseCoordinator = NavLeaseCoordinator() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.