Search in sources :

Example 6 with Message

use of drift.com.drift.model.Message in project drift-sdk-android by Driftt.

the class ConversationActivity method sendMessage.

void sendMessage() {
    MessageRequest messageRequest = new MessageRequest(textEntryEditText.getText().toString(), endUserId, null, this);
    final Message message = messageRequest.messageFromRequest(conversationId);
    conversationAdapter.addMessage(recyclerView, message);
    sendMessageRequest(messageRequest, message);
}
Also used : MessageRequest(drift.com.drift.model.MessageRequest) Message(drift.com.drift.model.Message)

Example 7 with Message

use of drift.com.drift.model.Message in project drift-sdk-android by Driftt.

the class MessagesWrapper method createConversation.

public static void createConversation(String bodyString, final APICallbackWrapper<Message> callback) {
    HashMap<String, String> payload = new HashMap<>();
    Editable editableText = new SpannableStringBuilder(bodyString);
    Linkify.addLinks(editableText, Linkify.WEB_URLS);
    String body = Html.toHtml(editableText).trim();
    payload.put("body", body);
    APIManager.getConversationClient().createConversation(payload).enqueue(new Callback<Message>() {

        @Override
        public void onResponse(Call<Message> call, Response<Message> response) {
            if ((response.code() != 200 && response.code() != 201) || response.body() == null) {
                callback.onResponse(null);
            } else {
                callback.onResponse(response.body());
            }
        }

        @Override
        public void onFailure(Call<Message> call, Throwable throwable) {
            LoggerHelper.logMessage(TAG, throwable.getLocalizedMessage());
            callback.onResponse(null);
        }
    });
}
Also used : Message(drift.com.drift.model.Message) HashMap(java.util.HashMap) Editable(android.text.Editable) SpannableStringBuilder(android.text.SpannableStringBuilder)

Aggregations

Message (drift.com.drift.model.Message)7 Editable (android.text.Editable)2 MessageRequest (drift.com.drift.model.MessageRequest)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Handler (android.os.Handler)1 ActionBar (android.support.v7.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 TextWatcher (android.text.TextWatcher)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ConversationAdapter (drift.com.drift.adapters.ConversationAdapter)1 ClickListener (drift.com.drift.helpers.ClickListener)1 RecyclerTouchListener (drift.com.drift.helpers.RecyclerTouchListener)1 Auth (drift.com.drift.model.Auth)1