From 67c0ceedc9833f2c495dfe78e4bc0d80a9b2fd18 Mon Sep 17 00:00:00 2001 From: camo0112 <56369484+camo0112@users.noreply.github.com> Date: Tue, 20 Apr 2021 13:06:40 +0530 Subject: [PATCH 1/2] Error handling in subscribe() in DownloadDialog --- .../newpipe/download/DownloadDialog.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) 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 4d3726c38..6d9f727a1 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -312,25 +312,27 @@ public class DownloadDialog extends DialogFragment private void fetchStreamsSize() { disposables.clear(); - disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedVideoStreams) .subscribe(result -> { - if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.video_button) { - setupVideoSpinner(); - } - })); + if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() + == R.id.video_button) { + setupVideoSpinner(); + } + }, throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))); disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedAudioStreams) .subscribe(result -> { - if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.audio_button) { - setupAudioSpinner(); - } - })); + if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() + == R.id.audio_button) { + setupAudioSpinner(); + } + }, throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))); disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedSubtitleStreams) .subscribe(result -> { - if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.subtitle_button) { - setupSubtitleSpinner(); - } - })); + if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() + == R.id.subtitle_button) { + setupSubtitleSpinner(); + } + }, throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))); } @Override From 4357e02c58d0bb136bd260fa321a34e4dc64aee1 Mon Sep 17 00:00:00 2001 From: camo0112 <56369484+camo0112@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:21:20 +0530 Subject: [PATCH 2/2] user can report the error --- .../schabi/newpipe/download/DownloadDialog.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 6d9f727a1..00fe63da3 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -318,21 +318,30 @@ public class DownloadDialog extends DialogFragment == R.id.video_button) { setupVideoSpinner(); } - }, throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))); + }, throwable -> ErrorActivity.reportErrorInSnackbar(context, + new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG, + "Downloading video stream size", + currentInfo.getServiceId())))); disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedAudioStreams) .subscribe(result -> { if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.audio_button) { setupAudioSpinner(); } - }, throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))); + }, throwable -> ErrorActivity.reportErrorInSnackbar(context, + new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG, + "Downloading audio stream size", + currentInfo.getServiceId())))); disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedSubtitleStreams) .subscribe(result -> { if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId() == R.id.subtitle_button) { setupSubtitleSpinner(); } - }, throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))); + }, throwable -> ErrorActivity.reportErrorInSnackbar(context, + new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG, + "Downloading subtitle stream size", + currentInfo.getServiceId())))); } @Override