mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
Auto fetch more chats if loaded chats don't fill the view
This commit is contained in:
parent
ff296c3bfc
commit
be53864f02
@ -560,8 +560,22 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
appStateViewModel.getCurrentUser().observe(getViewLifecycleOwner(), currentUser -> {
|
||||
viewModel.setCurrentUser(currentUser);
|
||||
setupItemsAdapter(currentUser);
|
||||
viewModel.getItems().observe(getViewLifecycleOwner(),
|
||||
list -> itemsAdapter.submitList(list, () -> itemOrHeaders = itemsAdapter.getList()));
|
||||
viewModel.getItems().observe(
|
||||
getViewLifecycleOwner(),
|
||||
list -> itemsAdapter.submitList(list, () -> {
|
||||
itemOrHeaders = itemsAdapter.getList();
|
||||
binding.chats.post(() -> {
|
||||
final RecyclerView.LayoutManager layoutManager = binding.chats.getLayoutManager();
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
final int position = ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
|
||||
if (position < 0) return;
|
||||
if (position == itemsAdapter.getItemCount() - 1) {
|
||||
viewModel.fetchChats();
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
final NavController navController = NavHostFragment.findNavController(this);
|
||||
final NavBackStackEntry backStackEntry = navController.getCurrentBackStackEntry();
|
||||
|
Loading…
Reference in New Issue
Block a user