File tree Expand file tree Collapse file tree
app/src/main/java/org/schabi/newpipe Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,9 +120,20 @@ public void setTitle(final String title) {
120120 }
121121 }
122122
123+ /**
124+ * Finds the root fragment by looping through all of the parent fragments. The root fragment
125+ * is supposed to be {@link org.schabi.newpipe.fragments.MainFragment}, and is the fragment that
126+ * handles keeping the backstack of opened fragments in NewPipe, and also the player bottom
127+ * sheet. This function therefore returns the fragment manager of said fragment.
128+ *
129+ * @return the fragment manager of the root fragment, i.e.
130+ * {@link org.schabi.newpipe.fragments.MainFragment}
131+ */
123132 protected FragmentManager getFM () {
124- return getParentFragment () == null
125- ? getFragmentManager ()
126- : getParentFragment ().getFragmentManager ();
133+ Fragment current = this ;
134+ while (current .getParentFragment () != null ) {
135+ current = current .getParentFragment ();
136+ }
137+ return current .getFragmentManager ();
127138 }
128139}
You can’t perform that action at this time.
0 commit comments