1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Merge pull request #8192 from GGAutomaton/fix-6696

Fix crash when rotating device on unsupported channels
This commit is contained in:
Stypox 2022-05-06 10:58:59 +02:00 committed by GitHub
commit 5b435c586e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,6 +77,8 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
private final CompositeDisposable disposables = new CompositeDisposable(); private final CompositeDisposable disposables = new CompositeDisposable();
private Disposable subscribeButtonMonitor; private Disposable subscribeButtonMonitor;
private boolean channelContentNotSupported = false;
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Views // Views
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -130,6 +132,7 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) { public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState); super.onViewCreated(rootView, savedInstanceState);
channelBinding = FragmentChannelBinding.bind(rootView); channelBinding = FragmentChannelBinding.bind(rootView);
showContentNotSupportedIfNeeded();
} }
@Override @Override
@ -524,9 +527,12 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
playlistControlBinding.getRoot().setVisibility(View.GONE); playlistControlBinding.getRoot().setVisibility(View.GONE);
} }
channelContentNotSupported = false;
for (final Throwable throwable : result.getErrors()) { for (final Throwable throwable : result.getErrors()) {
if (throwable instanceof ContentNotSupportedException) { if (throwable instanceof ContentNotSupportedException) {
showContentNotSupported(); channelContentNotSupported = true;
showContentNotSupportedIfNeeded();
break;
} }
} }
@ -558,7 +564,13 @@ public class ChannelFragment extends BaseListInfoFragment<StreamInfoItem, Channe
}); });
} }
private void showContentNotSupported() { private void showContentNotSupportedIfNeeded() {
// channelBinding might not be initialized when handleResult() is called
// (e.g. after rotating the screen, #6696)
if (!channelContentNotSupported || channelBinding == null) {
return;
}
channelBinding.errorContentNotSupported.setVisibility(View.VISIBLE); channelBinding.errorContentNotSupported.setVisibility(View.VISIBLE);
channelBinding.channelKaomoji.setText("(︶︹︺)"); channelBinding.channelKaomoji.setText("(︶︹︺)");
channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f); channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);