Fix crash when rotating device on unsupported channels

This commit is contained in:
GGAutomaton 2022-04-04 23:58:39 +08:00
parent 629b685f5a
commit 2e771cd65a
1 changed files with 12 additions and 1 deletions

View File

@ -77,6 +77,8 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
private final CompositeDisposable disposables = new CompositeDisposable();
private Disposable subscribeButtonMonitor;
private boolean channelContentNotSupported;
/*//////////////////////////////////////////////////////////////////////////
// Views
//////////////////////////////////////////////////////////////////////////*/
@ -130,6 +132,9 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
channelBinding = FragmentChannelBinding.bind(rootView);
if (channelContentNotSupported) {
showContentNotSupported();
}
}
@Override
@ -524,9 +529,15 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
playlistControlBinding.getRoot().setVisibility(View.GONE);
}
channelContentNotSupported = false;
for (final Throwable throwable : result.getErrors()) {
if (throwable instanceof ContentNotSupportedException) {
showContentNotSupported();
/*
channelBinding might not be initialized when handleResult() is called
(e.g. after rotating the screen, https://github.com/TeamNewPipe/NewPipe/issues/6696)
showContentNotSupported() will be called later
*/
channelContentNotSupported = true;
}
}