use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.
the class RecyclerChatActivity method sendLocation.
private void sendLocation(LatLng latLng, String locationName, String address) {
optionsLayout.setVisibility(View.GONE);
optionsLayout.removeAllViews();
try {
JSONObject locationObj = new JSONObject();
locationObj.put("lat", latLng.latitude);
locationObj.put("lng", latLng.longitude);
locationObj.put("name", locationName);
locationObj.put("address", address);
JSONObject messageObject = new JSONObject();
messageObject.put("location", locationObj);
final ChatMessage chatMessage = new ChatMessage(username, messageObject.toString(), name, true);
addMessage(chatMessage);
EventBus.getDefault().post(new SendMessageEvent(chatMessage));
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.
the class XMPPService method onEvent.
@Subscribe
public void onEvent(UploadCompleteEvent event) {
ChatMessage chatMessage = uploadMap.get(event.getUploadId());
chatMessage.setMessage("{\"type\":\"image\",\"image\": \"" + event.getUrl() + "\"}");
chatMessage.setBitmap(null);
EventBus.getDefault().post(new SendMessageEvent(chatMessage));
}
use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.
the class ChatActivity method sendOptionEvent.
public void sendOptionEvent(SendOptionEvent sendOptionEvent) {
optionsLayout.setVisibility(View.GONE);
optionsLayout.removeAllViews();
ChatMessage chatMessage = new ChatMessage(username, sendOptionEvent.getOption().getLabel(), name, true);
addMessage(chatMessage);
chatMessage.setMessageValue(sendOptionEvent.getOption().getValue());
EventBus.getDefault().post(new SendMessageEvent(chatMessage));
}
use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.
the class ChatActivity method onEvent.
@Subscribe
public void onEvent(AudioCompleteEvent event) {
try {
JSONObject jsonObject = new JSONObject(event.getResponse());
ChatMessage chatMessage = new ChatMessage(username, jsonObject.getJSONArray("transcriptions").getJSONObject(0).getString("utf_text"), name, true);
EventBus.getDefault().post(new SendMessageEvent(chatMessage));
addMessage(chatMessage);
dialog.hide();
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.yellowmessenger.sdk.events.SendMessageEvent in project yellowmessenger-sdk by yellowmessenger.
the class ChatActivity 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();
}
}
Aggregations