From 50db0d0719e9ebc90c8585bf93415fa6feca5316 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 23 Jun 2021 13:35:42 +0800 Subject: Add OnScrollListener to correct RecyclerView in ViewPostDetailFragment. --- .../infinityforreddit/fragments/ViewPostDetailFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/main/java') 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 992b6880..8903e9d7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -290,7 +290,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } if (children != null && children.size() > 0) { - mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -333,7 +333,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } }); } else { - mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -1162,7 +1162,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (children.size() > 0) { mRecyclerView.clearOnScrollListeners(); - mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -1300,7 +1300,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (children.size() > 0) { mRecyclerView.clearOnScrollListeners(); - mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); -- cgit v1.2.3