Skip to content
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

Use custom logic for fragment back stack #3958

Merged

Conversation

nielsvanvelzen
Copy link
Member

@nielsvanvelzen nielsvanvelzen commented Sep 2, 2024

This is a custom implementation of the back stack for our destinations. Previously, we used the back stack from the fragment manager but this didn't really work for us.

The problem was that we had to work around some shortcomings in the fragment manager due to how our destinations work. Specifically the "replace" action, mostly used when going from video player -> next up -> video player.

The way we made the replace action work was to pop the last item from the back stack, and then add a new item. This would result in the fragment before the video player (often the details page) to be resumed to then be replaced with the video player immediately after, because popping cannot be done in a transaction.

By replacing the back stack with our own implementation we have more control over this behavior and we can directly replace the fragment instead. Most of this logic is implemented in a custom view.

Changes

  • Refactor navigation logic to create our own backstack instead of relying on the fragment manager to allow proper destination replacement

Issues

Fixes #3950
Fixes #3926
Fixes #2800
Fixes #3931


// Restore history
@Suppress("UNCHECKED_CAST")
val savedHistory = BundleCompat.getParcelableArray(state, BUNDLE_HISTORY, HistoryEntry::class.java) as Array<HistoryEntry>?

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.
@nielsvanvelzen nielsvanvelzen added this to the v0.18.0 milestone Sep 3, 2024
@nielsvanvelzen nielsvanvelzen added enhancement New feature or request backportable Change may be backported to a point release (remove label once cherrypicked) labels Sep 3, 2024
@nielsvanvelzen nielsvanvelzen marked this pull request as ready for review September 3, 2024 11:41
@nielsvanvelzen nielsvanvelzen merged commit e460c6e into jellyfin:master Sep 3, 2024
6 checks passed
@nielsvanvelzen nielsvanvelzen deleted the navigation-custom-history branch September 3, 2024 14:38
@nielsvanvelzen nielsvanvelzen modified the milestones: v0.18.0, v0.17.5 Sep 8, 2024
@nielsvanvelzen nielsvanvelzen removed the backportable Change may be backported to a point release (remove label once cherrypicked) label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants