1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Merge pull request #10645 from Stypox/fix-fragment-manager

Fix crashes due to wrong root fragment manager
This commit is contained in:
Stypox 2023-12-20 12:03:24 +01:00 committed by GitHub
commit a16dcb63b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,9 +120,20 @@ public abstract class BaseFragment extends Fragment {
} }
} }
/**
* Finds the root fragment by looping through all of the parent fragments. The root fragment
* is supposed to be {@link org.schabi.newpipe.fragments.MainFragment}, and is the fragment that
* handles keeping the backstack of opened fragments in NewPipe, and also the player bottom
* sheet. This function therefore returns the fragment manager of said fragment.
*
* @return the fragment manager of the root fragment, i.e.
* {@link org.schabi.newpipe.fragments.MainFragment}
*/
protected FragmentManager getFM() { protected FragmentManager getFM() {
return getParentFragment() == null Fragment current = this;
? getFragmentManager() while (current.getParentFragment() != null) {
: getParentFragment().getFragmentManager(); current = current.getParentFragment();
}
return current.getFragmentManager();
} }
} }