Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

fix DownloadDialog crash if there are no streams available yet #356

Open
wants to merge 1 commit into
base: sponsorblock
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -153,6 +154,8 @@ public class DownloadDialog extends DialogFragment
private final ActivityResultLauncher<Intent> requestDownloadPickVideoFolderLauncher =
registerForActivityResult(
new StartActivityForResult(), this::requestDownloadPickVideoFolderResult);
@NonNull
private Disposable youtubeVideoSegmentsDisposable;


/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -254,8 +257,6 @@ public void onServiceConnected(final ComponentName cname, final IBinder service)
downloadManager = mgr.getDownloadManager();
askForSavePath = mgr.askForSavePath();

checkForYoutubeVideoSegments();

context.unbindService(this);
}

Expand Down Expand Up @@ -332,6 +333,7 @@ public void onViewCreated(@NonNull final View view,
showLoading();

initToolbar(dialogBinding.toolbarLayout.toolbar);
checkForYoutubeVideoSegments();
setupDownloadOptions();

prefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
Expand Down Expand Up @@ -393,6 +395,7 @@ public void onDestroy() {

@Override
public void onDestroyView() {
youtubeVideoSegmentsDisposable.dispose();
dialogBinding = null;
super.onDestroyView();
}
Expand Down Expand Up @@ -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
Expand All @@ -1177,7 +1180,7 @@ private void checkForYoutubeVideoSegments() {
setVideoSegments(videoSegments);
okButton.setEnabled(true);
hideLoading();
}));
});
}

public void showLoading() {
Expand Down