@Override public Observable<Boolean> publishMessage(List<MessageEntity> messageEntities) { return Observable.defer( () -> { boolean status = true; mTweetMessage.tweetMessages(mMessageDataMapper.unmap(messageEntities)); status = mPostMessage.postMessage(mMessageDataMapper.unmap(messageEntities)); return Observable.just(status); }); }
/** Handle receiving SMS message */ protected void handleSmsReceived(Intent intent) { String body; Bundle bundle = intent.getExtras(); Message msg = new Message(); log("handleSmsReceived() bundle " + bundle); if (bundle != null) { SmsMessage[] messages = getMessagesFromIntent(intent); sms = messages[0]; if (messages != null) { // extract message details. phone number and the message body msg.messageFrom = sms.getOriginatingAddress(); msg.messageDate = new Date(sms.getTimestampMillis()); if (messages.length == 1 || sms.isReplace()) { body = sms.getDisplayMessageBody(); } else { StringBuilder bodyText = new StringBuilder(); for (int i = 0; i < messages.length; i++) { bodyText.append(messages[i].getMessageBody()); } body = bodyText.toString(); } msg.messageBody = body; msg.messageUuid = new ProcessSms(mContext).getUuid(); msg.messageType = Message.Type.PENDING; msg.status = Message.Status.UNCONFIRMED; } log("handleSmsReceived() messagesUuid: " + messagesUuid); // Log received SMS mFileManager.appendAndClose( getString(R.string.received_msg, msg.messageBody, msg.messageFrom)); // Route the SMS if (App.getTwitterInstance().getSessionManager().getActiveSession() != null) { boolean status = mTweetMessage.routeSms(msg); showNotification(status); } boolean status = mPostMessage.routeSms(msg); showNotification(status); } }