mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 13:58:20 +03:00
fix DownloadDialog crash if there are no streams available yet
If there are no streams the DownloadDialog will close again quickly, but the rxJava job fetching the VideoSegments is still going. This patch fixes that: - move initialization of getting VideoSegments rxJava job until after initToolbar() - have Disposable for the VideoSegments stuff that will be disposed if the DownloadDialog will be destroyed.
This commit is contained in:
parent
ed6a94b3fb
commit
8ef31d0b5a
1 changed files with 7 additions and 4 deletions
|
@ -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<Intent> 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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue