cloudstream icon indicating copy to clipboard operation
cloudstream copied to clipboard

Backbutton break on TV

Open fire-light42 opened this issue 1 year ago • 1 comments

Steps to reproduce

You can test this by pressing back on the mainpage on tv, then you will get a "do you want to exit dialog", however if you go into downloads then back this dialog wont appear. See #1258

Expected behavior

Shows "do you want to exit dialog"

Actual behavior

Quits the app.

Cloudstream version and commit hash

d67fc368fdf259f83b2324bc88aef3f7a960c163

Android version

All

Logcat

No response

Other details

No response

Acknowledgements

  • [X] I am sure my issue is related to the app and NOT some extension.
  • [X] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • [X] I have written a short but informative title.
  • [X] I have updated the app to pre-release version Latest.
  • [X] I will fill out all of the requested information in this form.

fire-light42 avatar Aug 16 '24 17:08 fire-light42

Checked the back handler, found this to be weird in DownloadFragment -

override fun onDestroyView() {
        activity?.detachBackPressedCallback()
        binding = null
        super.onDestroyView()
 }

We attach a back callback when the user comes to home wherein the dialog is triggered. The back callback is being detached in DownloadFragment's onDestroyView which is being called after the attaching of the callback for home {I think this is usual behaviour, onDestroyView is called after the next fragment resumes}.

For extra context, we use the backhandler in DownloadFragment to dismiss the multidelete function before navigating up on the following back action.

@Luna712 can you comment on this? Was there some reason you chose to detach on onDestroyView? I am assuming it to be some race condition but not too sure. Removing this detach call, fixes the issue.

zzjjaayy avatar Sep 24 '24 16:09 zzjjaayy

Sorry, I completely forgot about this... #1437 fixes this but not sure if that was a good way to do it at all. But it does seem work when testing anyway.

Luna712 avatar Dec 27 '24 18:12 Luna712