use of com.xabber.android.data.message.ChatAction in project xabber-android by redsolution.
the class ChatMessageAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final int viewType = getItemViewType(position);
MessageItem messageItem = getMessageItem(position);
switch(viewType) {
case VIEW_TYPE_HINT:
((BasicMessage) holder).messageText.setText(hint);
break;
case VIEW_TYPE_ACTION_MESSAGE:
ChatAction action = messageItem.getAction();
String time = StringUtils.getSmartTimeText(context, messageItem.getTimestamp());
String name;
if (isMUC) {
name = messageItem.getResource();
} else {
name = RosterManager.getInstance().getBestContact(account, messageItem.getChat().getUser()).getName();
}
((BasicMessage) holder).messageText.setText(time + ": " + action.getText(context, name, messageItem.getSpannable().toString()));
break;
case VIEW_TYPE_INCOMING_MESSAGE:
setUpIncomingMessage((IncomingMessage) holder, messageItem);
break;
case VIEW_TYPE_OUTGOING_MESSAGE:
setUpOutgoingMessage((Message) holder, messageItem);
break;
}
}
use of com.xabber.android.data.message.ChatAction in project xabber-android by redsolution.
the class ChatMessageAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(BasicMessage holder, int position) {
final int viewType = getItemViewType(position);
MessageItem messageItem = getMessageItem(position);
if (messageItem == null) {
LogManager.w(LOG_TAG, "onBindViewHolder Null message item. Position: " + position);
return;
}
switch(viewType) {
case VIEW_TYPE_HINT:
// holder.messageText.setText(hint);
break;
case VIEW_TYPE_ACTION_MESSAGE:
ChatAction action = MessageItem.getChatAction(messageItem);
String time = StringUtils.getSmartTimeText(context, new Date(messageItem.getTimestamp()));
String name;
if (isMUC) {
name = messageItem.getResource().toString();
} else {
name = RosterManager.getInstance().getBestContact(account, messageItem.getUser()).getName();
}
holder.messageText.setText(time + ": " + action.getText(context, name, MessageItem.getSpannable(messageItem).toString()));
break;
case VIEW_TYPE_INCOMING_MESSAGE:
setUpIncomingMessage((IncomingMessage) holder, messageItem);
break;
case VIEW_TYPE_OUTGOING_MESSAGE:
setUpOutgoingMessage((Message) holder, messageItem);
break;
}
}
use of com.xabber.android.data.message.ChatAction in project xabber-android by redsolution.
the class MessageTable method createMessageItem.
public static MessageItem createMessageItem(Cursor cursor) throws XmppStringprepException, UserJid.UserJidCreateException {
MessageItem messageItem = new MessageItem();
messageItem.setAccount(AccountJid.from(getAccount(cursor)));
messageItem.setUser(UserJid.from(getUser(cursor)));
messageItem.setResource(Resourcepart.from(getResource(cursor)));
messageItem.setText(getText(cursor));
ChatAction action = getAction(cursor);
if (action != null) {
messageItem.setAction(action.name());
}
messageItem.setTimestamp(getTimeStamp(cursor));
messageItem.setDelayTimestamp(getDelayTimeStamp(cursor));
messageItem.setIncoming(isIncoming(cursor));
messageItem.setRead(isRead(cursor));
messageItem.setSent(isSent(cursor));
messageItem.setError(hasError(cursor));
messageItem.setStanzaId(getStanzaId(cursor));
messageItem.setReceivedFromMessageArchive(getReceivedFromMessageArchive(cursor));
return messageItem;
}
use of com.xabber.android.data.message.ChatAction in project xabber-android by redsolution.
the class ActionMessageVH method bind.
public void bind(MessageItem messageItem, Context context, AccountJid account, boolean isMUC) {
ChatAction action = MessageItem.getChatAction(messageItem);
String time = StringUtils.getSmartTimeText(context, new Date(messageItem.getTimestamp()));
String name;
if (isMUC) {
name = messageItem.getResource().toString();
} else {
name = RosterManager.getInstance().getBestContact(account, messageItem.getUser()).getName();
}
messageText.setText(time + ": " + action.getText(context, name, MessageItem.getSpannable(messageItem).toString()));
}
Aggregations