diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java index 3d1521b5..720fa016 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java @@ -121,6 +121,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter 350) { + if (((CommentBaseViewHolder) holder).saveButton != null) { + ((CommentBaseViewHolder) holder).saveButton.setVisibility(View.VISIBLE); + } + } else { + if (((CommentBaseViewHolder) holder).saveButton != null) { + ((CommentBaseViewHolder) holder).saveButton.setVisibility(View.GONE); + } + } } } } @@ -434,6 +445,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java index 3111ef68..479d52d0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java @@ -109,6 +109,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni private AdjustableTouchSlopItemTouchHelper touchHelper; private boolean shouldSwipeBack; private FragmentCommentsListingBinding binding; + private View.OnLayoutChangeListener onLayoutChangeListener; + private int recyclerViewWidth; public CommentsListingFragment() { // Required empty public constructor @@ -302,6 +304,22 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni }); } + onLayoutChangeListener = (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { + int width = right - left; + if (recyclerViewWidth == width) { + return; + } + recyclerViewWidth = width; + v.post(() -> { + int widthInDp = Utils.convertPxToDp(width, mActivity); + if (mAdapter != null) { + mAdapter.provideItemWidth(widthInDp); + refreshAdapter(binding.recyclerViewCommentsListingFragment, mAdapter); + } + }); + }; + binding.recyclerViewCommentsListingFragment.addOnLayoutChangeListener(onLayoutChangeListener); + CommentViewModel.Factory factory; if (mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) { @@ -363,6 +381,10 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni @Override public void onDestroy() { EventBus.getDefault().unregister(this); + if (onLayoutChangeListener != null) { + binding.recyclerViewCommentsListingFragment.removeOnLayoutChangeListener(onLayoutChangeListener); + onLayoutChangeListener = null; + } super.onDestroy(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragmentNew.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragmentNew.java index 9b69cb97..260cc70e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragmentNew.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragmentNew.java @@ -1153,6 +1153,7 @@ public class ViewPostDetailFragmentNew extends Fragment implements FragmentCommu } else { binding.postDetailRecyclerViewViewPostDetailFragment.removeOnLayoutChangeListener(onLayoutChangeListener); } + onLayoutChangeListener = null; } super.onDestroyView(); }