From 5eba4e31f8727130e66d7c86329149b739d96a88 Mon Sep 17 00:00:00 2001 From: bopol Date: Thu, 9 Apr 2020 09:45:21 +0200 Subject: [PATCH] fix ContentNotSupportedError not showing if cached and rename function --- .../fragments/list/channel/ChannelFragment.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 90363c32421..acc9c670f8b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -437,10 +437,12 @@ public void handleResult(@NonNull final ChannelInfo result) { // handling ContentNotSupportedException not to show the error but an appropriate string // so that crashes won't be sent uselessly and the user will understand what happened Iterator it = errors.iterator(); + Throwable contentNotSupported = null; while (it.hasNext()) { Throwable throwable = it.next(); if (throwable instanceof ContentNotSupportedException) { - updateNoVideoDisplay(); + showContentNotSupported(); + contentNotSupported = throwable; it.remove(); } } @@ -449,6 +451,12 @@ public void handleResult(@NonNull final ChannelInfo result) { showSnackBarError(result.getErrors(), UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(result.getServiceId()), result.getUrl(), 0); } + + if (contentNotSupported != null) { + // adding it after snackbarError so that it's not removed and + // the CNS error will still show up even if the channel is cached + errors.add(contentNotSupported); + } } if (disposables != null) { @@ -468,7 +476,7 @@ public void handleResult(@NonNull final ChannelInfo result) { .playOnBackgroundPlayer(activity, getPlayQueue(), false)); } - private void updateNoVideoDisplay() { + private void showContentNotSupported() { contentNotSupportedTextView.setVisibility(View.VISIBLE); kaomojiTextView.setText("(︶︹︺)"); kaomojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);