Skip to content

Commit 62b593d

Browse files
authored
Merge pull request #6118 from sauravrao637/errorHandlingInSubcribe
Error handling in subscribe() in DownloadDialog
2 parents 0eb69b6 + 4357e02 commit 62b593d

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,25 +312,36 @@ public void onStopTrackingTouch(final SeekBar p1) { }
312312

313313
private void fetchStreamsSize() {
314314
disposables.clear();
315-
316315
disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedVideoStreams)
317316
.subscribe(result -> {
318-
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.video_button) {
319-
setupVideoSpinner();
320-
}
321-
}));
317+
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()
318+
== R.id.video_button) {
319+
setupVideoSpinner();
320+
}
321+
}, throwable -> ErrorActivity.reportErrorInSnackbar(context,
322+
new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG,
323+
"Downloading video stream size",
324+
currentInfo.getServiceId()))));
322325
disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedAudioStreams)
323326
.subscribe(result -> {
324-
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.audio_button) {
325-
setupAudioSpinner();
326-
}
327-
}));
327+
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()
328+
== R.id.audio_button) {
329+
setupAudioSpinner();
330+
}
331+
}, throwable -> ErrorActivity.reportErrorInSnackbar(context,
332+
new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG,
333+
"Downloading audio stream size",
334+
currentInfo.getServiceId()))));
328335
disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedSubtitleStreams)
329336
.subscribe(result -> {
330-
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.subtitle_button) {
331-
setupSubtitleSpinner();
332-
}
333-
}));
337+
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()
338+
== R.id.subtitle_button) {
339+
setupSubtitleSpinner();
340+
}
341+
}, throwable -> ErrorActivity.reportErrorInSnackbar(context,
342+
new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG,
343+
"Downloading subtitle stream size",
344+
currentInfo.getServiceId()))));
334345
}
335346

336347
@Override

0 commit comments

Comments
 (0)