Create an app-wide Disposable
to be used for app-wide actions
#7942
Labels
codequality
Improvements to the codebase to improve the code quality
wontfix
This issue will not be fixed
Checklist
Affected version
After (but also before) #7570
The problem
In the NewPipe codebase there are many methods that use RxJava to perform resource/time/io-heavy actions in the background. When these actions finally result in a change in the activity/fragment/dialog that originally triggered them, then an RxJava
Disposable
should be passed to those functions, so that if the activity/fragment/dialog is dismissed before the action can complete, the action can bedispose()
d. This is what is correctly being done in the text linkifier class: they take a text view and set its text once it has been linkified, but if in the meantime the activity/fragment/dialog associated to the text view was destroyed, the linkification of the text will stop (otherwise it would result in callingsetText()
on a non-existing text view).Sometimes, though, an action is not really associated with the activity/fragment/dialog that triggered it. If the user want to start playing something in a popup, he may tap on the popup button in the long-press menu of the feed fragment, and then maybe he instantly (i.e. before the popup player had a chance to load) closes the feed fragment to switch to another app. If the disposable for playing in popup was added to the
Disposable
s associated with the feed fragment, the loading of the popup player would stop. So currently what is being done instead is basically just not saving disposables anywhere so they are never disposed, for example checkout this. Though this behavior mostly works fine, I don't think it is a good practice and may lead to problems, so I think we should create an app-wideDisposable
to which all disposables related to app-wide actions can be added.The text was updated successfully, but these errors were encountered: