use of de.tum.in.tumcampusapp.component.ui.chat.adapter.ChatHistoryAdapter in project TumCampusApp by TCA-Team.
the class ChatActivity method onMessagesLoaded.
private void onMessagesLoaded() {
final List<ChatMessage> msgs = chatMessageViewModel.getAll(currentChatRoom.getId());
// Update results in UI
runOnUiThread(() -> {
if (chatHistoryAdapter == null) {
chatHistoryAdapter = new ChatHistoryAdapter(ChatActivity.this, msgs, currentChatMember);
lvMessageHistory.setAdapter(chatHistoryAdapter);
} else {
chatHistoryAdapter.updateHistory(chatMessageViewModel.getAll(currentChatRoom.getId()));
}
// If all messages are loaded hide header view
if ((!msgs.isEmpty() && msgs.get(0).getPrevious() == 0) || chatHistoryAdapter.getCount() == 0) {
lvMessageHistory.removeHeaderView(bar);
} else {
loadingMore = false;
}
});
}
Aggregations