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 a8484c491..262567e4b 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 icepick.State; 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 class DownloadDialog extends DialogFragment downloadManager = mgr.getDownloadManager(); askForSavePath = mgr.askForSavePath(); - checkForYoutubeVideoSegments(); - context.unbindService(this); } @@ -332,6 +333,7 @@ public class DownloadDialog extends DialogFragment showLoading(); initToolbar(dialogBinding.toolbarLayout.toolbar); + checkForYoutubeVideoSegments(); setupDownloadOptions(); prefs = PreferenceManager.getDefaultSharedPreferences(requireContext()); @@ -393,6 +395,7 @@ public class DownloadDialog extends DialogFragment @Override public void onDestroyView() { + youtubeVideoSegmentsDisposable.dispose(); dialogBinding = null; super.onDestroyView(); } @@ -1158,7 +1161,7 @@ public class DownloadDialog extends DialogFragment } private void checkForYoutubeVideoSegments() { - disposables.add(Single.fromCallable(() -> { + youtubeVideoSegmentsDisposable = Single.fromCallable(() -> { VideoSegment[] videoSegments = null; try { videoSegments = SponsorBlockUtils @@ -1177,7 +1180,7 @@ public class DownloadDialog extends DialogFragment setVideoSegments(videoSegments); okButton.setEnabled(true); hideLoading(); - })); + }); } public void showLoading() {