Skip to content

Commit

Permalink
Expand DetailFragment again when exiting the CommentRepliesFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Aug 29, 2023
1 parent 48e36fb commit c92cd0f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
21 changes: 17 additions & 4 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.schabi.newpipe.fragments.BackPressable;
import org.schabi.newpipe.fragments.MainFragment;
import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
import org.schabi.newpipe.fragments.list.comments.CommentRepliesFragment;
import org.schabi.newpipe.fragments.list.search.SearchFragment;
import org.schabi.newpipe.local.feed.notifications.NotificationWorker;
import org.schabi.newpipe.player.Player;
Expand Down Expand Up @@ -554,6 +555,11 @@ public void onBackPressed() {
if (((BackPressable) fragment).onBackPressed()) {
return;
}
} else if (fragment instanceof CommentRepliesFragment) {
// expand DetailsFragment if CommentRepliesFragment was opened
// to show the top level comments again
BottomSheetBehavior.from(mainBinding.fragmentPlayerHolder)
.setState(BottomSheetBehavior.STATE_EXPANDED);
}

} else {
Expand Down Expand Up @@ -629,10 +635,17 @@ public void onRequestPermissionsResult(final int requestCode,
* </pre>
*/
private void onHomeButtonPressed() {
// If search fragment wasn't found in the backstack...
if (!NavigationHelper.tryGotoSearchFragment(getSupportFragmentManager())) {
// ...go to the main fragment
NavigationHelper.gotoMainFragment(getSupportFragmentManager());
final FragmentManager fm = getSupportFragmentManager();
final Fragment fragment = fm.findFragmentById(R.id.fragment_holder);

if (fragment instanceof CommentRepliesFragment) {
// expand DetailsFragment if CommentRepliesFragment was opened
// to show the top level comments again
BottomSheetBehavior.from(mainBinding.fragmentPlayerHolder)
.setState(BottomSheetBehavior.STATE_EXPANDED);
} else if (!NavigationHelper.tryGotoSearchFragment(fm)) {
// If search fragment wasn't found in the backstack go to the main fragment
NavigationHelper.gotoMainFragment(fm);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,5 @@ protected Single<ListExtractor.InfoItemsPage<CommentsInfoItem>> loadMoreItemsLog
protected ItemViewMode getItemViewMode() {
return ItemViewMode.LIST;
}

}

0 comments on commit c92cd0f

Please sign in to comment.