mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Fix onPostUpdateEvent and onNeedForPostListFromPostRecyclerViewAdapterEvent in PostFragment.
This commit is contained in:
parent
91d24e1e0c
commit
5fddea1362
@ -37,6 +37,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.paging.ItemSnapshotList;
|
||||||
import androidx.paging.LoadState;
|
import androidx.paging.LoadState;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
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.ChangeVoteButtonsPositionEvent;
|
||||||
import ml.docilealligator.infinityforreddit.events.NeedForPostListFromPostFragmentEvent;
|
import ml.docilealligator.infinityforreddit.events.NeedForPostListFromPostFragmentEvent;
|
||||||
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostList;
|
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostList;
|
||||||
|
import ml.docilealligator.infinityforreddit.events.ProvidePostListToViewPostDetailActivityEvent;
|
||||||
import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent;
|
import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent;
|
||||||
import ml.docilealligator.infinityforreddit.events.ShowThumbnailOnTheRightInCompactLayoutEvent;
|
import ml.docilealligator.infinityforreddit.events.ShowThumbnailOnTheRightInCompactLayoutEvent;
|
||||||
import ml.docilealligator.infinityforreddit.post.Post;
|
import ml.docilealligator.infinityforreddit.post.Post;
|
||||||
@ -1566,9 +1568,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
|
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
|
||||||
//TODO: fix this
|
ItemSnapshotList<Post> posts = mAdapter.snapshot();
|
||||||
/*PagedList<Post> posts = mAdapter.getCurrentList();
|
if (event.positionInList >= 0 && event.positionInList < posts.size()) {
|
||||||
if (posts != null && event.positionInList >= 0 && event.positionInList < posts.size()) {
|
|
||||||
Post post = posts.get(event.positionInList);
|
Post post = posts.get(event.positionInList);
|
||||||
if (post != null && post.getFullName().equals(event.post.getFullName())) {
|
if (post != null && post.getFullName().equals(event.post.getFullName())) {
|
||||||
post.setTitle(event.post.getTitle());
|
post.setTitle(event.post.getTitle());
|
||||||
@ -1581,7 +1582,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
post.setSaved(event.post.isSaved());
|
post.setSaved(event.post.isSaved());
|
||||||
mAdapter.notifyItemChanged(event.positionInList);
|
mAdapter.notifyItemChanged(event.positionInList);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -1848,10 +1849,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onNeedForPostListFromPostRecyclerViewAdapterEvent(NeedForPostListFromPostFragmentEvent event) {
|
public void onNeedForPostListFromPostRecyclerViewAdapterEvent(NeedForPostListFromPostFragmentEvent event) {
|
||||||
//TODO: fix this
|
if (postFragmentId == event.postFragmentTimeId && mAdapter != null) {
|
||||||
/*if (postFragmentId == event.postFragmentTimeId) {
|
EventBus.getDefault().post(new ProvidePostListToViewPostDetailActivityEvent(postFragmentId, new ArrayList<>(mAdapter.snapshot())));
|
||||||
EventBus.getDefault().post(new ProvidePostListToViewPostDetailActivityEvent(postFragmentId, new ArrayList<>(mPostViewModel.getPosts().getValue())));
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
Loading…
Reference in New Issue
Block a user