Search in sources :

Example 11 with SendMessageEvent

use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.

the class RecyclerChatActivity method sendActionEvent.

public void sendActionEvent(SendActionEvent sendActionEvent) {
    ChatMessage chatMessage = new ChatMessage(username, sendActionEvent.getAction().getTitle(), name, true);
    addMessage(chatMessage);
    chatMessage.setMessageValue(sendActionEvent.getAction().getText() != null ? sendActionEvent.getAction().getText() : sendActionEvent.getAction().getTitle());
    EventBus.getDefault().post(new SendMessageEvent(chatMessage));
}
Also used : ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) SendMessageEvent(com.yellowmessenger.sdk.events.SendMessageEvent)

Example 12 with SendMessageEvent

use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.

the class RecyclerChatActivity method sendMessage.

public void sendMessage(View view) {
    String message = editText.getText().toString();
    if (!message.trim().equals("")) {
        ChatMessage chatMessage = new ChatMessage(username, message, name, true);
        EventBus.getDefault().post(new SendMessageEvent(chatMessage));
        addMessage(chatMessage);
        editText.setText("");
        optionsLayout.removeAllViews();
    }
}
Also used : ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) SendMessageEvent(com.yellowmessenger.sdk.events.SendMessageEvent)

Example 13 with SendMessageEvent

use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.

the class RecyclerChatActivity method sendOption.

public void sendOption(final Question question, final Option option) {
    if (option.isLocation()) {
        askForLocation();
    } else {
        optionsLayout.setVisibility(View.GONE);
        optionsLayout.removeAllViews();
        ChatMessage chatMessage = new ChatMessage(username, option.getLabel(), name, true);
        chatMessage.setMessageValue(option.getValue());
        EventBus.getDefault().post(new SendMessageEvent(chatMessage));
        addMessage(chatMessage);
    }
}
Also used : ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) SendMessageEvent(com.yellowmessenger.sdk.events.SendMessageEvent)

Aggregations

SendMessageEvent (com.yellowmessenger.sdk.events.SendMessageEvent)13 ChatMessage (com.yellowmessenger.sdk.models.db.ChatMessage)13 JSONObject (org.json.JSONObject)3 IOException (java.io.IOException)2 Subscribe (org.greenrobot.eventbus.Subscribe)2 JSONException (org.json.JSONException)2