Search in sources :

Example 1 with RequestEditMessage

use of com.fanap.podchat.requestobject.RequestEditMessage in project pod-chat-android-sdk by FanapSoft.

the class ChatPresenter method editMessage.

@Override
public void editMessage(int messageId, String messageNewContent, String metaData, ChatHandler handler) {
    RequestEditMessage requestEditMessage = new RequestEditMessage.Builder(messageNewContent, messageId).metaData(metaData).build();
    chat.editMessage(requestEditMessage, handler);
}
Also used : RequestEditMessage(com.fanap.podchat.requestobject.RequestEditMessage)

Example 2 with RequestEditMessage

use of com.fanap.podchat.requestobject.RequestEditMessage in project pod-chat-android-sdk by FanapSoft.

the class ThreadCacheTest method sendMessageAndEdit.

public void sendMessageAndEdit() {
    populateThreadsFromServer();
    Collections.shuffle(threadsInServer);
    Thread thread = threadsInServer.get(0);
    Assert.assertNotNull(thread);
    final long[] messageId = { 0 };
    // send new message
    chatListeners = new ChatListener() {

        @Override
        public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
            messageId[0] = response.getResult().getMessageVO().getId();
            resumeProcess();
            System.out.println("new message sent -> msg : " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestMessage request = new RequestMessage.Builder("Message for test edit :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    chat.sendTextMessage(request, null);
    pauseProcess();
    // delete last message
    chatListeners = new ChatListener() {

        @Override
        public void onEditedMessage(String content, ChatResponse<ResultNewMessage> response) {
            resumeProcess();
            System.out.println("Edited: " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestEditMessage requestEditMessage = new RequestEditMessage.Builder("last message edited " + messageId[0], messageId[0]).build();
    chat.editMessage(requestEditMessage, null);
    pauseProcess();
}
Also used : ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) RequestEditMessage(com.fanap.podchat.requestobject.RequestEditMessage) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread)

Aggregations

RequestEditMessage (com.fanap.podchat.requestobject.RequestEditMessage)2 ChatListener (com.fanap.podchat.chat.ChatListener)1 Thread (com.fanap.podchat.mainmodel.Thread)1 ErrorOutPut (com.fanap.podchat.model.ErrorOutPut)1 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)1 ResultThread (com.fanap.podchat.model.ResultThread)1 RequestMessage (com.fanap.podchat.requestobject.RequestMessage)1 RequestThread (com.fanap.podchat.requestobject.RequestThread)1