Skip to content

Commit 2e771cd

Browse files
committed
Fix crash when rotating device on unsupported channels
1 parent 629b685 commit 2e771cd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

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

Lines changed: 12 additions & 1 deletion
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;
81+
8082
/*//////////////////////////////////////////////////////////////////////////
8183
// Views
8284
//////////////////////////////////////////////////////////////////////////*/
@@ -130,6 +132,9 @@ 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+
if (channelContentNotSupported) {
136+
showContentNotSupported();
137+
}
133138
}
134139

135140
@Override
@@ -524,9 +529,15 @@ public void handleResult(@NonNull final ChannelInfo result) {
524529
playlistControlBinding.getRoot().setVisibility(View.GONE);
525530
}
526531

532+
channelContentNotSupported = false;
527533
for (final Throwable throwable : result.getErrors()) {
528534
if (throwable instanceof ContentNotSupportedException) {
529-
showContentNotSupported();
535+
/*
536+
channelBinding might not be initialized when handleResult() is called
537+
(e.g. after rotating the screen, https://github.com/TeamNewPipe/NewPipe/issues/6696)
538+
showContentNotSupported() will be called later
539+
*/
540+
channelContentNotSupported = true;
530541
}
531542
}
532543

0 commit comments

Comments
 (0)