use of org.moire.ultrasonic.view.ChatAdapter in project ultrasonic by ultrasonic.
the class ChatActivity method onResume.
@Override
protected void onResume() {
super.onResume();
if (!messageList.isEmpty()) {
ListAdapter chatAdapter = new ChatAdapter(ChatActivity.this, messageList);
chatListView.setAdapter(chatAdapter);
}
if (timer == null) {
timerMethod();
}
}
use of org.moire.ultrasonic.view.ChatAdapter in project ultrasonic by ultrasonic.
the class ChatActivity method load.
private synchronized void load() {
BackgroundTask<List<ChatMessage>> task = new TabActivityBackgroundTask<List<ChatMessage>>(this, false) {
@Override
protected List<ChatMessage> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(ChatActivity.this);
return musicService.getChatMessages(lastChatMessageTime, ChatActivity.this, this);
}
@Override
protected void done(List<ChatMessage> result) {
if (result != null && !result.isEmpty()) {
// Reset lastChatMessageTime if we have a newer message
for (ChatMessage message : result) {
if (message.getTime() > lastChatMessageTime) {
lastChatMessageTime = message.getTime();
}
}
// Reverse results to show them on the bottom
Collections.reverse(result);
messageList.addAll(result);
ListAdapter chatAdapter = new ChatAdapter(ChatActivity.this, messageList);
chatListView.setAdapter(chatAdapter);
}
}
};
task.execute();
}
Aggregations