diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-09-07 11:18:18 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-09-07 11:18:18 +0000 |
commit | 5fddea1362cf65968abc49550ada834f2ddaa37e (patch) | |
tree | 567321679aab70c60235a3cb82ad4cfd312a9ef9 /app/src | |
parent | 91d24e1e0c8bb0abdb2d9bfe748c7edea9206658 (diff) | |
download | infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.tar infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.tar.gz infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.tar.bz2 infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.tar.lz infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.tar.xz infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.tar.zst infinity-for-reddit-5fddea1362cf65968abc49550ada834f2ddaa37e.zip |
Fix onPostUpdateEvent and onNeedForPostListFromPostRecyclerViewAdapterEvent in PostFragment.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 59af5dd9..1c4565b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -37,6 +37,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; +import androidx.paging.ItemSnapshotList; import androidx.paging.LoadState; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearSmoothScroller; @@ -120,6 +121,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeVideoAutoplayEvent; import ml.docilealligator.infinityforreddit.events.ChangeVoteButtonsPositionEvent; import ml.docilealligator.infinityforreddit.events.NeedForPostListFromPostFragmentEvent; import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostList; +import ml.docilealligator.infinityforreddit.events.ProvidePostListToViewPostDetailActivityEvent; import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent; import ml.docilealligator.infinityforreddit.events.ShowThumbnailOnTheRightInCompactLayoutEvent; import ml.docilealligator.infinityforreddit.post.Post; @@ -1566,9 +1568,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Subscribe public void onPostUpdateEvent(PostUpdateEventToPostList event) { - //TODO: fix this - /*PagedList<Post> posts = mAdapter.getCurrentList(); - if (posts != null && event.positionInList >= 0 && event.positionInList < posts.size()) { + ItemSnapshotList<Post> posts = mAdapter.snapshot(); + if (event.positionInList >= 0 && event.positionInList < posts.size()) { Post post = posts.get(event.positionInList); if (post != null && post.getFullName().equals(event.post.getFullName())) { post.setTitle(event.post.getTitle()); @@ -1581,7 +1582,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { post.setSaved(event.post.isSaved()); mAdapter.notifyItemChanged(event.positionInList); } - }*/ + } } @Subscribe @@ -1848,10 +1849,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Subscribe public void onNeedForPostListFromPostRecyclerViewAdapterEvent(NeedForPostListFromPostFragmentEvent event) { - //TODO: fix this - /*if (postFragmentId == event.postFragmentTimeId) { - EventBus.getDefault().post(new ProvidePostListToViewPostDetailActivityEvent(postFragmentId, new ArrayList<>(mPostViewModel.getPosts().getValue()))); - }*/ + if (postFragmentId == event.postFragmentTimeId && mAdapter != null) { + EventBus.getDefault().post(new ProvidePostListToViewPostDetailActivityEvent(postFragmentId, new ArrayList<>(mAdapter.snapshot()))); + } } @Subscribe |