diff options
author | scria1000 <91804886+scria1000@users.noreply.github.com> | 2021-11-16 23:18:31 +0000 |
---|---|---|
committer | scria1000 <91804886+scria1000@users.noreply.github.com> | 2021-11-16 23:18:31 +0000 |
commit | b106e0677a47e203076fd0a4f5bfcc92b08def6d (patch) | |
tree | ed47a9653efad30aaed58203b6f466770a4927b2 | |
parent | 04cc769ccfbcf08667ff85350f12556b8e98a453 (diff) | |
download | infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.tar infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.tar.gz infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.tar.bz2 infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.tar.lz infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.tar.xz infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.tar.zst infinity-for-reddit-b106e0677a47e203076fd0a4f5bfcc92b08def6d.zip |
Make scroll button work on single comment mode
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index e912418d..5e4d8c3e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -67,6 +67,7 @@ import butterknife.ButterKnife; import im.ene.toro.exoplayer.ExoCreator; import im.ene.toro.media.PlaybackInfo; import im.ene.toro.media.VolumeInfo; +import im.ene.toro.widget.Container; import ml.docilealligator.infinityforreddit.DeleteThing; import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.FragmentCommunicator; @@ -1736,28 +1737,32 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } public void scrollToNextParentComment() { - int currentPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); - if (mCommentsAdapter != null) { - int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + RecyclerView chooseYourView = mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView; + if (mCommentsAdapter != null && chooseYourView != null) { + int currentPosition = ((LinearLayoutManagerBugFixed) chooseYourView.getLayoutManager()).findFirstVisibleItemPosition(); + //int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? currentPosition - 1 : currentPosition); if (nextParentPosition < 0) { return; } - mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition); + mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? nextParentPosition + 1 : nextParentPosition); mIsSmoothScrolling = true; - (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller); + chooseYourView.getLayoutManager().startSmoothScroll(mSmoothScroller); } } public void scrollToPreviousParentComment() { - int currentPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); - if (mCommentsAdapter != null) { - int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + RecyclerView chooseYourView = mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView; + if (mCommentsAdapter != null && chooseYourView != null) { + int currentPosition = ((LinearLayoutManagerBugFixed) chooseYourView.getLayoutManager()).findFirstVisibleItemPosition(); + //int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? currentPosition - 1 : currentPosition); if (previousParentPosition < 0) { return; } - mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition); + mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? previousParentPosition + 1 : previousParentPosition); mIsSmoothScrolling = true; - (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller); + chooseYourView.getLayoutManager().startSmoothScroll(mSmoothScroller); } } |