Skip to content

Commit b1add13

Browse files
Address code review comments
1 parent 5fffee2 commit b1add13

3 files changed

Lines changed: 18 additions & 22 deletions

File tree

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -553,28 +553,27 @@ public void onBackPressed() {
553553
// In case bottomSheet is not visible on the screen or collapsed we can assume that the user
554554
// interacts with a fragment inside fragment_holder so all back presses should be
555555
// handled by it
556+
final var fragmentManager = getSupportFragmentManager();
557+
556558
if (bottomSheetHiddenOrCollapsed()) {
557-
final var fm = getSupportFragmentManager();
558-
final var fragment = fm.findFragmentById(R.id.fragment_holder);
559+
final var fragment = fragmentManager.findFragmentById(R.id.fragment_holder);
559560
// If current fragment implements BackPressable (i.e. can/wanna handle back press)
560561
// delegate the back press to it
561562
if (fragment instanceof BackPressable backPressable && backPressable.onBackPressed()) {
562563
return;
563564
}
564565
} else {
565-
final var fragmentPlayer = getSupportFragmentManager()
566-
.findFragmentById(R.id.fragment_player_holder);
566+
final var player = fragmentManager.findFragmentById(R.id.fragment_player_holder);
567567
// If current fragment implements BackPressable (i.e. can/wanna handle back press)
568568
// delegate the back press to it
569-
if (fragmentPlayer instanceof BackPressable backPressable
570-
&& !backPressable.onBackPressed()) {
569+
if (player instanceof BackPressable backPressable && !backPressable.onBackPressed()) {
571570
BottomSheetBehavior.from(mainBinding.fragmentPlayerHolder)
572571
.setState(BottomSheetBehavior.STATE_COLLAPSED);
573572
return;
574573
}
575574
}
576575

577-
if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
576+
if (fragmentManager.getBackStackEntryCount() == 1) {
578577
finish();
579578
} else {
580579
super.onBackPressed();

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
import org.schabi.newpipe.error.UserAction;
7474
import org.schabi.newpipe.extractor.Image;
7575
import org.schabi.newpipe.extractor.NewPipe;
76-
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
7776
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
7877
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
7978
import org.schabi.newpipe.extractor.stream.AudioStream;
@@ -1011,19 +1010,6 @@ public void scrollToTop() {
10111010
updateTabLayoutVisibility();
10121011
}
10131012

1014-
public void scrollToComment(final CommentsInfoItem comment) {
1015-
final int commentsTabPos = pageAdapter.getItemPositionByTitle(COMMENTS_TAB_TAG);
1016-
final var fragment = pageAdapter.getItem(commentsTabPos);
1017-
1018-
// TODO: Implement the scrolling with Compose.
1019-
// unexpand the app bar only if scrolling to the comment succeeded
1020-
// if (fragment instanceof CommentsFragment commentsFragment &&
1021-
// commentsFragment.scrollToComment(comment)) {
1022-
// binding.appBarLayout.setExpanded(false, false);
1023-
// binding.viewPager.setCurrentItem(commentsTabPos, false);
1024-
// }
1025-
}
1026-
10271013
/*//////////////////////////////////////////////////////////////////////////
10281014
// Play Utils
10291015
//////////////////////////////////////////////////////////////////////////*/

app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.Flow
2727
import kotlinx.coroutines.flow.flowOf
2828
import my.nanihadesuka.compose.LazyColumnScrollbar
2929
import org.schabi.newpipe.R
30+
import org.schabi.newpipe.extractor.Page
3031
import org.schabi.newpipe.extractor.comments.CommentsInfoItem
3132
import org.schabi.newpipe.extractor.stream.Description
3233
import org.schabi.newpipe.paging.CommentsDisabledException
@@ -91,7 +92,17 @@ private class CommentDataProvider : PreviewParameterProvider<PagingData<Comments
9192
override val values = sequenceOf(
9293
// Normal view
9394
PagingData.from(
94-
(1..100).map {
95+
listOf(
96+
CommentsInfoItem(
97+
commentText = Description(
98+
"Comment 1\n\nThis line should be hidden by default.",
99+
Description.PLAIN_TEXT
100+
),
101+
uploaderName = "Test",
102+
replies = Page(""),
103+
replyCount = 10
104+
)
105+
) + (2..10).map {
95106
CommentsInfoItem(
96107
commentText = Description("Comment $it", Description.PLAIN_TEXT),
97108
uploaderName = "Test"

0 commit comments

Comments
 (0)