Search in sources :

Example 1 with ChatHistoryAdapter

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;
        }
    });
}
Also used : ChatHistoryAdapter(de.tum.in.tumcampusapp.component.ui.chat.adapter.ChatHistoryAdapter) ChatMessage(de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage)

Aggregations

ChatHistoryAdapter (de.tum.in.tumcampusapp.component.ui.chat.adapter.ChatHistoryAdapter)1 ChatMessage (de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage)1