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 Rotation crash on „Video not available“ page (#5941) #6242

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Changes from all 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
fix Rotation crash on „Video not available“ page (#5941)
The EmptyFragment should not have a constructor at all.
Now a static methods creates the Fragment and arguments
are handled via a Bundle.
evermind-zz committed May 5, 2021
commit a012e26d635153a012fce067df200cc50d02ab5e
Original file line number Diff line number Diff line change
@@ -11,15 +11,20 @@
import org.schabi.newpipe.R;

public class EmptyFragment extends BaseFragment {
final boolean showMessage;
private static final String SHOW_MESSAGE = "SHOW_MESSAGE";

public EmptyFragment(final boolean showMessage) {
this.showMessage = showMessage;
public static final EmptyFragment newInstance(final boolean showMessage) {
final EmptyFragment emptyFragment = new EmptyFragment();
final Bundle bundle = new Bundle(1);
bundle.putBoolean(SHOW_MESSAGE, showMessage);
emptyFragment.setArguments(bundle);
return emptyFragment;
}

@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
final Bundle savedInstanceState) {
final boolean showMessage = getArguments().getBoolean(SHOW_MESSAGE);
final View view = inflater.inflate(R.layout.fragment_empty, container, false);
view.findViewById(R.id.empty_state_view).setVisibility(
showMessage ? View.VISIBLE : View.GONE);
Original file line number Diff line number Diff line change
@@ -929,20 +929,20 @@ private void initTabs() {

if (showRelatedItems && binding.relatedItemsLayout == null) {
// temp empty fragment. will be updated in handleResult
pageAdapter.addFragment(new EmptyFragment(false), RELATED_TAB_TAG);
pageAdapter.addFragment(EmptyFragment.newInstance(false), RELATED_TAB_TAG);
tabIcons.add(R.drawable.ic_art_track);
tabContentDescriptions.add(R.string.related_items_tab_description);
}

if (showDescription) {
// temp empty fragment. will be updated in handleResult
pageAdapter.addFragment(new EmptyFragment(false), DESCRIPTION_TAB_TAG);
pageAdapter.addFragment(EmptyFragment.newInstance(false), DESCRIPTION_TAB_TAG);
tabIcons.add(R.drawable.ic_description);
tabContentDescriptions.add(R.string.description_tab_description);
}

if (pageAdapter.getCount() == 0) {
pageAdapter.addFragment(new EmptyFragment(true), EMPTY_TAB_TAG);
pageAdapter.addFragment(EmptyFragment.newInstance(true), EMPTY_TAB_TAG);
}
pageAdapter.notifyDataSetUpdate();