From 48a8076fc064a4df1ff1d11c8999e324974f79c7 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 17 Sep 2021 20:47:21 +0800 Subject: Rewrite code related to hiding read posts. --- .../adapters/PostRecyclerViewAdapter.java | 76 +--------------------- .../infinityforreddit/fragments/PostFragment.java | 18 ----- 2 files changed, 3 insertions(+), 91 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 39762f79..f1438382 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -169,7 +169,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter= 0 && temp < super.getItemCount()) { @@ -1813,21 +1772,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { if (mLongPressToHideToolbarInCompactLayout) { if (bottomConstraintLayout.getLayoutParams().height == 0) { - ViewGroup.LayoutParams params = (LinearLayout.LayoutParams) bottomConstraintLayout.getLayoutParams(); + ViewGroup.LayoutParams params = bottomConstraintLayout.getLayoutParams(); params.height = LinearLayout.LayoutParams.WRAP_CONTENT; bottomConstraintLayout.setLayoutParams(params); mCallback.delayTransition(); @@ -3621,7 +3553,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter readPosts; - private Set currentlyReadPostIds = new HashSet<>(); private Unbinder unbinder; private Map subredditOrUserIcons = new HashMap<>(); @@ -391,13 +389,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mSwipeRefreshLayout.setOnRefreshListener(this::refresh); int recyclerViewPosition = 0; - int hideReadPostsIndex = 0; if (savedInstanceState != null) { recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE); isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); readPosts = savedInstanceState.getParcelableArrayList(READ_POST_LIST_STATE); - hideReadPostsIndex = savedInstanceState.getInt(HIDE_READ_POSTS_INDEX_STATE, 0); postFilter = savedInstanceState.getParcelable(POST_FILTER_STATE); concatenatedSubredditNames = savedInstanceState.getString(CONCATENATED_SUBREDDIT_NAMES_STATE); postFragmentId = savedInstanceState.getLong(POST_FRAGMENT_ID_STATE); @@ -842,8 +838,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mPostRecyclerView.scrollToPosition(recyclerViewPosition); } - mAdapter.setHideReadPostsIndex(hideReadPostsIndex); - if (activity instanceof ActivityToolbarInterface) { ((ActivityToolbarInterface) activity).displaySortType(); } @@ -872,7 +866,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false); } this.readPosts = readPostList; - currentlyReadPostIds.addAll(Lists.transform(readPosts, ReadPost::getId)); initializeAndBindPostViewModel(accessToken); } }); @@ -1279,9 +1272,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { super.onSaveInstanceState(outState); outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode); outState.putParcelableArrayList(READ_POST_LIST_STATE, readPosts); - if (mAdapter != null) { - outState.putInt(HIDE_READ_POSTS_INDEX_STATE, mAdapter.getHideReadPostsIndex()); - } if (mLinearLayoutManager != null) { outState.putInt(RECYCLER_VIEW_POSITION_STATE, mLinearLayoutManager.findFirstVisibleItemPosition()); } else if (mStaggeredGridLayoutManager != null) { @@ -1332,10 +1322,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } } - public void addCurrentlyReadPostId(String id) { - currentlyReadPostIds.add(id); - } - @Override public void changeNSFW(boolean nsfw) { postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && nsfw; @@ -1492,10 +1478,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Override public void hideReadPosts() { - /*if (mAdapter != null) { - mAdapter.prepareToHideReadPosts(); - refreshAdapter(); - }*/ mPostViewModel.hideReadPosts(); } -- cgit v1.2.3