Skip to content

Commit 5b435c5

Browse files
authored
Merge pull request #8192 from GGAutomaton/fix-6696
Fix crash when rotating device on unsupported channels
2 parents a1435bd + 71e46d1 commit 5b435c5

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
7777
private final CompositeDisposable disposables = new CompositeDisposable();
7878
private Disposable subscribeButtonMonitor;
7979

80+
private boolean channelContentNotSupported = false;
81+
8082
/*//////////////////////////////////////////////////////////////////////////
8183
// Views
8284
//////////////////////////////////////////////////////////////////////////*/
@@ -130,6 +132,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
130132
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
131133
super.onViewCreated(rootView, savedInstanceState);
132134
channelBinding = FragmentChannelBinding.bind(rootView);
135+
showContentNotSupportedIfNeeded();
133136
}
134137

135138
@Override
@@ -524,9 +527,12 @@ public void handleResult(@NonNull final ChannelInfo result) {
524527
playlistControlBinding.getRoot().setVisibility(View.GONE);
525528
}
526529

530+
channelContentNotSupported = false;
527531
for (final Throwable throwable : result.getErrors()) {
528532
if (throwable instanceof ContentNotSupportedException) {
529-
showContentNotSupported();
533+
channelContentNotSupported = true;
534+
showContentNotSupportedIfNeeded();
535+
break;
530536
}
531537
}
532538

@@ -558,7 +564,13 @@ public void handleResult(@NonNull final ChannelInfo result) {
558564
});
559565
}
560566

561-
private void showContentNotSupported() {
567+
private void showContentNotSupportedIfNeeded() {
568+
// channelBinding might not be initialized when handleResult() is called
569+
// (e.g. after rotating the screen, #6696)
570+
if (!channelContentNotSupported || channelBinding == null) {
571+
return;
572+
}
573+
562574
channelBinding.errorContentNotSupported.setVisibility(View.VISIBLE);
563575
channelBinding.channelKaomoji.setText("(︶︹︺)");
564576
channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);

0 commit comments

Comments
 (0)