Search in sources :

Example 1 with ChatAdapter

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();
    }
}
Also used : ChatAdapter(org.moire.ultrasonic.view.ChatAdapter) ListAdapter(android.widget.ListAdapter)

Example 2 with ChatAdapter

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();
}
Also used : TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) MusicService(org.moire.ultrasonic.service.MusicService) ChatMessage(org.moire.ultrasonic.domain.ChatMessage) ArrayList(java.util.ArrayList) List(java.util.List) ChatAdapter(org.moire.ultrasonic.view.ChatAdapter) ListAdapter(android.widget.ListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)2 ChatAdapter (org.moire.ultrasonic.view.ChatAdapter)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ChatMessage (org.moire.ultrasonic.domain.ChatMessage)1 MusicService (org.moire.ultrasonic.service.MusicService)1 TabActivityBackgroundTask (org.moire.ultrasonic.util.TabActivityBackgroundTask)1