Search in sources :

Example 1 with RequestDeleteMessage

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

the class ChatPresenter method deleteMessage.

@Override
public void deleteMessage(ArrayList<Long> messageIds, long threadId, Boolean deleteForAll, ChatHandler handler) {
    RequestDeleteMessage requestDeleteMessage = new RequestDeleteMessage.Builder().messageIds(messageIds).deleteForAll(deleteForAll).build();
    String un = chat.deleteMessage(requestDeleteMessage, handler);
}
Also used : RequestDeleteMessage(com.fanap.podchat.requestobject.RequestDeleteMessage)

Example 2 with RequestDeleteMessage

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

the class ThreadCacheTest method sendMessageAndDelete.

public void sendMessageAndDelete() {
    populateThreadsFromServer();
    Collections.shuffle(threadsInServer);
    Thread thread = threadsInServer.get(0);
    Assert.assertNotNull(thread);
    ArrayList<Long> msgIds = new ArrayList<>();
    // send new message
    chatListeners = new ChatListener() {

        @Override
        public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
            resumeProcess();
            msgIds.add(response.getResult().getMessageVO().getId());
            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 delete :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    chat.sendTextMessage(request, null);
    pauseProcess();
    // delete last message
    chatListeners = new ChatListener() {

        @Override
        public void onDeleteMessage(String content, ChatResponse<ResultDeleteMessage> response) {
            resumeProcess();
            System.out.println("Deleted: " + 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);
    RequestDeleteMessage requestDeleteMessage = new RequestDeleteMessage.Builder().messageIds(msgIds).deleteForAll(true).build();
    presenter.deleteMessage(requestDeleteMessage, null);
    pauseProcess();
}
Also used : RequestDeleteMessage(com.fanap.podchat.requestobject.RequestDeleteMessage) ArrayList(java.util.ArrayList) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread) ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) ResultDeleteMessage(com.fanap.podchat.mainmodel.ResultDeleteMessage)

Example 3 with RequestDeleteMessage

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

the class ChatActivity method deleteMessage.

public void deleteMessage() {
    ArrayList<Long> msgIds = new ArrayList<>();
    msgIds.add((long) TEST_THREAD_ID);
    // msgIds.add(47566L);
    // msgIds.add(47564L);
    RequestDeleteMessage requestDeleteMessage = new RequestDeleteMessage.Builder().messageIds(msgIds).deleteForAll(true).build();
    presenter.deleteMessage(requestDeleteMessage, null);
// presenter.deleteMessage(16804, true, new ChatHandler() {
// @Override
// public void onDeleteMessage(String uniqueId) {
// super.onDeleteMessage(uniqueId);
// }
// });
}
Also used : RequestDeleteMessage(com.fanap.podchat.requestobject.RequestDeleteMessage) ArrayList(java.util.ArrayList)

Aggregations

RequestDeleteMessage (com.fanap.podchat.requestobject.RequestDeleteMessage)3 ArrayList (java.util.ArrayList)2 ChatListener (com.fanap.podchat.chat.ChatListener)1 ResultDeleteMessage (com.fanap.podchat.mainmodel.ResultDeleteMessage)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