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);
}
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);
}
});
}
Aggregations