mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Address code review comments
This commit is contained in:
parent
5fffee2c7d
commit
b1add13bfd
@ -553,28 +553,27 @@ public class MainActivity extends AppCompatActivity {
|
||||
// In case bottomSheet is not visible on the screen or collapsed we can assume that the user
|
||||
// interacts with a fragment inside fragment_holder so all back presses should be
|
||||
// handled by it
|
||||
final var fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (bottomSheetHiddenOrCollapsed()) {
|
||||
final var fm = getSupportFragmentManager();
|
||||
final var fragment = fm.findFragmentById(R.id.fragment_holder);
|
||||
final var fragment = fragmentManager.findFragmentById(R.id.fragment_holder);
|
||||
// If current fragment implements BackPressable (i.e. can/wanna handle back press)
|
||||
// delegate the back press to it
|
||||
if (fragment instanceof BackPressable backPressable && backPressable.onBackPressed()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
final var fragmentPlayer = getSupportFragmentManager()
|
||||
.findFragmentById(R.id.fragment_player_holder);
|
||||
final var player = fragmentManager.findFragmentById(R.id.fragment_player_holder);
|
||||
// If current fragment implements BackPressable (i.e. can/wanna handle back press)
|
||||
// delegate the back press to it
|
||||
if (fragmentPlayer instanceof BackPressable backPressable
|
||||
&& !backPressable.onBackPressed()) {
|
||||
if (player instanceof BackPressable backPressable && !backPressable.onBackPressed()) {
|
||||
BottomSheetBehavior.from(mainBinding.fragmentPlayerHolder)
|
||||
.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
|
||||
if (fragmentManager.getBackStackEntryCount() == 1) {
|
||||
finish();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
|
@ -73,7 +73,6 @@ import org.schabi.newpipe.error.ReCaptchaActivity;
|
||||
import org.schabi.newpipe.error.UserAction;
|
||||
import org.schabi.newpipe.extractor.Image;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
@ -1011,19 +1010,6 @@ public final class VideoDetailFragment
|
||||
updateTabLayoutVisibility();
|
||||
}
|
||||
|
||||
public void scrollToComment(final CommentsInfoItem comment) {
|
||||
final int commentsTabPos = pageAdapter.getItemPositionByTitle(COMMENTS_TAB_TAG);
|
||||
final var fragment = pageAdapter.getItem(commentsTabPos);
|
||||
|
||||
// TODO: Implement the scrolling with Compose.
|
||||
// unexpand the app bar only if scrolling to the comment succeeded
|
||||
// if (fragment instanceof CommentsFragment commentsFragment &&
|
||||
// commentsFragment.scrollToComment(comment)) {
|
||||
// binding.appBarLayout.setExpanded(false, false);
|
||||
// binding.viewPager.setCurrentItem(commentsTabPos, false);
|
||||
// }
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Play Utils
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import my.nanihadesuka.compose.LazyColumnScrollbar
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.extractor.Page
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem
|
||||
import org.schabi.newpipe.extractor.stream.Description
|
||||
import org.schabi.newpipe.paging.CommentsDisabledException
|
||||
@ -91,7 +92,17 @@ private class CommentDataProvider : PreviewParameterProvider<PagingData<Comments
|
||||
override val values = sequenceOf(
|
||||
// Normal view
|
||||
PagingData.from(
|
||||
(1..100).map {
|
||||
listOf(
|
||||
CommentsInfoItem(
|
||||
commentText = Description(
|
||||
"Comment 1\n\nThis line should be hidden by default.",
|
||||
Description.PLAIN_TEXT
|
||||
),
|
||||
uploaderName = "Test",
|
||||
replies = Page(""),
|
||||
replyCount = 10
|
||||
)
|
||||
) + (2..10).map {
|
||||
CommentsInfoItem(
|
||||
commentText = Description("Comment $it", Description.PLAIN_TEXT),
|
||||
uploaderName = "Test"
|
||||
|
Loading…
Reference in New Issue
Block a user