diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-06-26 13:43:30 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-06-26 13:43:30 +0000 |
commit | 7b1221bfc95930cdc1126c540dc19e09421a57ec (patch) | |
tree | 6d0ac912c537dfb9c1eafe9c279d48e77eb55372 | |
parent | 6e4a808cbbb9ea2454da51b363155b9b6b2f4ea5 (diff) | |
download | infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.tar infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.tar.gz infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.tar.bz2 infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.tar.lz infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.tar.xz infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.tar.zst infinity-for-reddit-7b1221bfc95930cdc1126c540dc19e09421a57ec.zip |
Long press the fab in ViewPostDetailActivity to go to the previous parent comment. Fix bugs in scrollToNextParentComment() and scrollToPreviousParentComment() in ViewPostDetailFragment.
Diffstat (limited to '')
2 files changed, 15 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index 80dc5788..34fbc55a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -209,6 +209,17 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele } }); + fab.setOnLongClickListener(view -> { + if (sectionsPagerAdapter != null) { + ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment(); + if (fragment != null) { + fragment.scrollToPreviousParentComment(); + return true; + } + } + return false; + }); + checkNewAccountAndBindView(savedInstanceState); } 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 0201f183..40d2ff9f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -1660,7 +1660,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (mLinearLayoutManager != null) { int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); if (mCommentsAdapter != null) { - int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(currentPosition); + int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); if (nextParentPosition < 0) { return; } @@ -1677,11 +1677,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (mLinearLayoutManager != null) { int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); if (mCommentsAdapter != null) { - int nextParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(currentPosition); - if (nextParentPosition < 0) { + int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + if (previousParentPosition < 0) { return; } - mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition); + mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition); if (mLinearLayoutManager != null) { mIsSmoothScrolling = true; mLinearLayoutManager.startSmoothScroll(mSmoothScroller); |