Skip to content

Commit 82bfea9

Browse files
committed
remove infinite while loop and put condition in it.
1 parent dd15893 commit 82bfea9

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -528,20 +528,13 @@ public static void closeCommentRepliesFragments(@NonNull final FragmentActivity
528528
}
529529

530530
// Only pop back stack entries named CommentRepliesFragment.TAG if they are at the top.
531-
while (true) {
532-
final int count = fm.getBackStackEntryCount();
533-
if (count == 0) {
534-
break;
535-
}
536-
final FragmentManager.BackStackEntry topEntry = fm.getBackStackEntryAt(count - 1);
537-
final String topName = topEntry.getName();
538-
if (CommentRepliesFragment.TAG.equals(topName)) {
539-
// Safe to pop the topmost matching entry (it won't remove other unrelated entries)
540-
fm.popBackStackImmediate(topName, FragmentManager.POP_BACK_STACK_INCLUSIVE);
541-
} else {
542-
break;
543-
}
531+
while (fm.getBackStackEntryCount() > 0
532+
&& CommentRepliesFragment.TAG.equals(fm.getBackStackEntryAt(
533+
fm.getBackStackEntryCount() - 1).getName())) {
534+
fm.popBackStackImmediate(CommentRepliesFragment.TAG,
535+
FragmentManager.POP_BACK_STACK_INCLUSIVE);
544536
}
537+
545538
}
546539

547540
public static void openPlaylistFragment(final FragmentManager fragmentManager,

0 commit comments

Comments
 (0)