diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-06-26 13:22:04 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-06-26 13:22:04 +0000 |
commit | 7db721f297c85f203bd67bc7876fcfaea235b7d7 (patch) | |
tree | 4ee170a1b4a155bf069eac8a58decd9c1f0769d7 | |
parent | 9819059e297e0767ed6a90c4d5c228c320943da4 (diff) | |
download | infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.tar infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.tar.gz infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.tar.bz2 infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.tar.lz infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.tar.xz infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.tar.zst infinity-for-reddit-7db721f297c85f203bd67bc7876fcfaea235b7d7.zip |
Fix comments disappear in ViewPostDetailFragment after the system kills Infinity.
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java | 10 |
1 files changed, 6 insertions, 4 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 beff863f..0caf078e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -12,6 +12,7 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.util.DisplayMetrics; +import android.util.Log; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.Menu; @@ -323,7 +324,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic int totalItemCount = mLinearLayoutManager.getItemCount(); int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); - if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) { + if (mCommentsAdapter != null && mCommentsAdapter.getItemCount() >= 1 && (visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) { fetchMoreComments(); } } @@ -403,7 +404,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { if (touchHelper != null) { touchHelper.attachToRecyclerView(null); - touchHelper.attachToRecyclerView(mRecyclerView); + touchHelper.attachToRecyclerView((mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView)); if (mCommentsAdapter != null) { mCommentsAdapter.onItemSwipe(viewHolder, direction, swipeLeftAction, swipeRightAction); } @@ -467,7 +468,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic }); if (enableSwipeAction) { - touchHelper.attachToRecyclerView(mRecyclerView); + touchHelper.attachToRecyclerView((mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView)); } mSwipeRefreshLayout.setOnRefreshListener(() -> refresh(true, true)); @@ -1797,10 +1798,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } if (stateChanged) { - if (mCommentsRecyclerView != null) { + if (mCommentsRecyclerView == null) { refreshAdapter(mRecyclerView, mConcatAdapter); } else { refreshAdapter(mRecyclerView, mPostAdapter); + refreshAdapter(mCommentsRecyclerView, mCommentsAdapter); } } } |