Skip to content

Fixobserveorder#2766

Merged
fire-light42 merged 7 commits intomasterfrom
fixobserveorder
May 6, 2026
Merged

Fixobserveorder#2766
fire-light42 merged 7 commits intomasterfrom
fixobserveorder

Conversation

@fire-light42
Copy link
Copy Markdown
Collaborator

The problem with the old system was that observe might say that the link loading is finished when the viewModel.state disagrees, and this fixes that by dropping livedata

  1. This should fix some issues with Refactor: Player, Generator and ViewModel #2764 by dropping observe calls made with the wrong instance number.
  2. I also moved the loadLinks state change to not race the observe by having the state change immediately.
  3. The player also quits if it is fully recreated without showing a "no links found" if the generator does not exists. We need to serialize the generator if we want full relaunch capability, do note that this is not possible inside a bundle due to size limit.
  4. And finally when the fragment is recreated it restarts the player from the same link to properly resync the UI.

I tested with:

adb shell am kill com.lagradost.cloudstream3.prerelease.debug
adb shell am force-stop com.lagradost.cloudstream3.prerelease.debug
playerGoBack.setOnClickListener {
    requireFragmentManager()
        .beginTransaction()
        .detach(this@FullScreenPlayer).commit()
    requireFragmentManager()
        .beginTransaction()
        .attach(this@FullScreenPlayer).commit()
}
playerGoBack.setOnClickListener {
    activity?.recreate()
}

Background process limit -> No background processes.

@Luna712

This should give:
Fragment recreated -> Reloads player
Activity recreated -> Reloads links (may use link cache)
Process killed -> Exists player

There might be some other possibility I am unaware of given some weird recreation order, but now the view-model should be in-sync at all times.

@Luna712
Copy link
Copy Markdown
Contributor

Luna712 commented May 6, 2026

Nice! Thanks for this!

@fire-light42 fire-light42 merged commit bfc9268 into master May 6, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants