Skip to content

Commit

Permalink
Fix crash when rotating device on unsupported channels
Browse files Browse the repository at this point in the history
  • Loading branch information
GGAutomaton committed Apr 4, 2022
1 parent 629b685 commit 2e771cd
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
private final CompositeDisposable disposables = new CompositeDisposable();
private Disposable subscribeButtonMonitor;

private boolean channelContentNotSupported;

/*//////////////////////////////////////////////////////////////////////////
// Views
//////////////////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -130,6 +132,9 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
channelBinding = FragmentChannelBinding.bind(rootView);
if (channelContentNotSupported) {
showContentNotSupported();
}
}

@Override
Expand Down Expand Up @@ -524,9 +529,15 @@ public void handleResult(@NonNull final ChannelInfo result) {
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;
}
}

Expand Down

0 comments on commit 2e771cd

Please sign in to comment.