diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index a8484c491a5..262567e4b22 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -87,6 +87,7 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.core.Single; import io.reactivex.rxjava3.disposables.CompositeDisposable; +import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.schedulers.Schedulers; import us.shandian.giga.get.MissionRecoveryInfo; import us.shandian.giga.postprocessing.Postprocessing; @@ -153,6 +154,8 @@ public class DownloadDialog extends DialogFragment private final ActivityResultLauncher requestDownloadPickVideoFolderLauncher = registerForActivityResult( new StartActivityForResult(), this::requestDownloadPickVideoFolderResult); + @NonNull + private Disposable youtubeVideoSegmentsDisposable; /*////////////////////////////////////////////////////////////////////////// @@ -254,8 +257,6 @@ public void onServiceConnected(final ComponentName cname, final IBinder service) downloadManager = mgr.getDownloadManager(); askForSavePath = mgr.askForSavePath(); - checkForYoutubeVideoSegments(); - context.unbindService(this); } @@ -332,6 +333,7 @@ public void onViewCreated(@NonNull final View view, showLoading(); initToolbar(dialogBinding.toolbarLayout.toolbar); + checkForYoutubeVideoSegments(); setupDownloadOptions(); prefs = PreferenceManager.getDefaultSharedPreferences(requireContext()); @@ -393,6 +395,7 @@ public void onDestroy() { @Override public void onDestroyView() { + youtubeVideoSegmentsDisposable.dispose(); dialogBinding = null; super.onDestroyView(); } @@ -1158,7 +1161,7 @@ private void continueSelectedDownload(@NonNull final StoredFileHelper storage) { } private void checkForYoutubeVideoSegments() { - disposables.add(Single.fromCallable(() -> { + youtubeVideoSegmentsDisposable = Single.fromCallable(() -> { VideoSegment[] videoSegments = null; try { videoSegments = SponsorBlockUtils @@ -1177,7 +1180,7 @@ private void checkForYoutubeVideoSegments() { setVideoSegments(videoSegments); okButton.setEnabled(true); hideLoading(); - })); + }); } public void showLoading() {