|
@ -183,11 +183,13 @@ public class PostsRecyclerView extends RecyclerView { |
|
|
|
|
|
|
|
|
private void initSelf() { |
|
|
private void initSelf() { |
|
|
feedViewModel = new ViewModelProvider(viewModelStoreOwner).get(FeedViewModel.class); |
|
|
feedViewModel = new ViewModelProvider(viewModelStoreOwner).get(FeedViewModel.class); |
|
|
feedViewModel.getList().observe(lifeCycleOwner, list -> feedAdapter.submitList(list, () -> { |
|
|
|
|
|
|
|
|
feedViewModel.getList().observe(lifeCycleOwner, list -> { |
|
|
|
|
|
if (list.size() > 0) feedAdapter.submitList(list, () -> { |
|
|
if (!shouldScrollToTop) return; |
|
|
if (!shouldScrollToTop) return; |
|
|
smoothScrollToPosition(0); |
|
|
smoothScrollToPosition(0); |
|
|
shouldScrollToTop = false; |
|
|
shouldScrollToTop = false; |
|
|
})); |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
postFetcher = new PostFetcher(postFetchService, fetchListener); |
|
|
postFetcher = new PostFetcher(postFetchService, fetchListener); |
|
|
if (layoutPreferences.getHasGap()) { |
|
|
if (layoutPreferences.getHasGap()) { |
|
|
addItemDecoration(gridSpacingItemDecoration); |
|
|
addItemDecoration(gridSpacingItemDecoration); |
|
|