Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when rotating device on unsupported channels #8192

Merged
merged 4 commits into from
May 6, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Stypox marked this conversation as resolved.
Show resolved Hide resolved

/*//////////////////////////////////////////////////////////////////////////
// Views
//////////////////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -130,6 +132,7 @@ 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);
showContentNotSupportedIfNeeded();
}

@Override
Expand Down Expand Up @@ -524,9 +527,11 @@ 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();
channelContentNotSupported = true;
GGAutomaton marked this conversation as resolved.
Show resolved Hide resolved
showContentNotSupportedIfNeeded();
Stypox marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -558,7 +563,13 @@ public void handleResult(@NonNull final ChannelInfo result) {
});
}

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.channelKaomoji.setText("(︶︹︺)");
channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);
Expand Down