Search in sources :

Example 21 with ChatMessage

use of com.yellowmessenger.sdk.models.db.ChatMessage in project yellowmessenger-sdk by yellowmessenger.

the class RecyclerChatActivity method sendImageMessage.

public void sendImageMessage(Bitmap bm, String filename) {
    String message = "";
    ChatMessage chatMessage = new ChatMessage(username, message, name, true);
    chatMessage.setBitmap(bm);
    addMessage(chatMessage);
    EventBus.getDefault().post(new UploadStartEvent(chatMessage, filename));
}
Also used : ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) UploadStartEvent(com.yellowmessenger.sdk.events.UploadStartEvent)

Example 22 with ChatMessage

use of com.yellowmessenger.sdk.models.db.ChatMessage 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 23 with ChatMessage

use of com.yellowmessenger.sdk.models.db.ChatMessage 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)

Example 24 with ChatMessage

use of com.yellowmessenger.sdk.models.db.ChatMessage in project yellowmessenger-sdk by yellowmessenger.

the class XMPPService method onEvent.

@Subscribe
public void onEvent(UploadStartEvent event) {
    ChatMessage chatMessage = event.getChatMessage();
    uploadMap.put(event.getUploadId(), chatMessage);
}
Also used : ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 25 with ChatMessage

use of com.yellowmessenger.sdk.models.db.ChatMessage in project yellowmessenger-sdk by yellowmessenger.

the class XMPPService method sendUnsentMessages.

public void sendUnsentMessages() {
    try {
        List<ChatMessage> unsentMessages = ChatMessageDAO.getUnsentMessages();
        for (ChatMessage chatMessage : unsentMessages) {
            Message msg = new Message(JidCreate.from(chatMessage.getUsername(), DOMAIN, ""), Message.Type.chat);
            if (chatMessage.getMessageValue() != null) {
                msg.setBody(chatMessage.getMessageValue());
            } else {
                msg.setBody(chatMessage.getMessage());
            }
            mConnection.sendStanza(msg);
            chatMessage.setUnsent(false);
            chatMessage.setStanzaId(msg.getStanzaId());
            chatMessage.save();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) Message(org.jivesoftware.smack.packet.Message) ChatMessage(com.yellowmessenger.sdk.models.db.ChatMessage) SmackException(org.jivesoftware.smack.SmackException) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

ChatMessage (com.yellowmessenger.sdk.models.db.ChatMessage)29 SendMessageEvent (com.yellowmessenger.sdk.events.SendMessageEvent)13 View (android.view.View)7 HorizontalScrollView (android.widget.HorizontalScrollView)7 ImageView (android.widget.ImageView)7 TextView (android.widget.TextView)7 ParseException (java.text.ParseException)7 Date (java.util.Date)7 Subscribe (org.greenrobot.eventbus.Subscribe)5 Intent (android.content.Intent)4 ChatResponse (com.yellowmessenger.sdk.models.ChatResponse)3 Question (com.yellowmessenger.sdk.models.Question)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 SmackException (org.jivesoftware.smack.SmackException)3 JSONObject (org.json.JSONObject)3 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)3 Paint (android.graphics.Paint)2 Bundle (android.os.Bundle)2 ViewGroup (android.view.ViewGroup)2 MessageReceivedEvent (com.yellowmessenger.sdk.events.MessageReceivedEvent)2