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

Merge pull request #6242 from evermind-zz/fixes-for-upstream

fix Rotation crash on „Video not available“ page (#5941)
This commit is contained in:
Tobi 2021-06-03 12:22:23 +02:00 committed by GitHub
commit f98d2631e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -11,15 +11,20 @@ import org.schabi.newpipe.BaseFragment;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
public class EmptyFragment extends BaseFragment { public class EmptyFragment extends BaseFragment {
final boolean showMessage; private static final String SHOW_MESSAGE = "SHOW_MESSAGE";
public EmptyFragment(final boolean showMessage) { public static final EmptyFragment newInstance(final boolean showMessage) {
this.showMessage = showMessage; final EmptyFragment emptyFragment = new EmptyFragment();
final Bundle bundle = new Bundle(1);
bundle.putBoolean(SHOW_MESSAGE, showMessage);
emptyFragment.setArguments(bundle);
return emptyFragment;
} }
@Override @Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
final Bundle savedInstanceState) { final Bundle savedInstanceState) {
final boolean showMessage = getArguments().getBoolean(SHOW_MESSAGE);
final View view = inflater.inflate(R.layout.fragment_empty, container, false); final View view = inflater.inflate(R.layout.fragment_empty, container, false);
view.findViewById(R.id.empty_state_view).setVisibility( view.findViewById(R.id.empty_state_view).setVisibility(
showMessage ? View.VISIBLE : View.GONE); showMessage ? View.VISIBLE : View.GONE);

View File

@ -929,20 +929,20 @@ public final class VideoDetailFragment
if (showRelatedItems && binding.relatedItemsLayout == null) { if (showRelatedItems && binding.relatedItemsLayout == null) {
// temp empty fragment. will be updated in handleResult // 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); tabIcons.add(R.drawable.ic_art_track);
tabContentDescriptions.add(R.string.related_items_tab_description); tabContentDescriptions.add(R.string.related_items_tab_description);
} }
if (showDescription) { if (showDescription) {
// temp empty fragment. will be updated in handleResult // 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); tabIcons.add(R.drawable.ic_description);
tabContentDescriptions.add(R.string.description_tab_description); tabContentDescriptions.add(R.string.description_tab_description);
} }
if (pageAdapter.getCount() == 0) { if (pageAdapter.getCount() == 0) {
pageAdapter.addFragment(new EmptyFragment(true), EMPTY_TAB_TAG); pageAdapter.addFragment(EmptyFragment.newInstance(true), EMPTY_TAB_TAG);
} }
pageAdapter.notifyDataSetUpdate(); pageAdapter.notifyDataSetUpdate();