use of com.rideread.rideread.bean.ChatMessage in project ride-read-android by Ride-Read.
the class ChatMessageAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ChatMessage msg = (ChatMessage) getItem(position);
ViewHolder viewHolder = null;
if (convertView == null) {
viewHolder = new ViewHolder();
if (getItemViewType(position) == 0) {
convertView = inflater.inflate(R.layout.im_chat_to_listitem, null);
} else {
convertView = inflater.inflate(R.layout.im_chat_from_listitem, null);
}
viewHolder.chatPortait = (ImageView) convertView.findViewById(R.id.im_chat_portait);
viewHolder.chatContent = (TextView) convertView.findViewById(R.id.im_chat_content);
viewHolder.chatTime = (TextView) convertView.findViewById(R.id.im_chat_time);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
if (!TextUtils.isEmpty(msg.getPubDate())) {
viewHolder.chatTime.setText(msg.getPubDate());
}
if (!TextUtils.isEmpty(msg.getContent())) {
viewHolder.chatContent.setText(msg.getContent());
}
viewHolder.chatPortait.setImageResource(msg.getPortait());
return convertView;
}
use of com.rideread.rideread.bean.ChatMessage in project ride-read-android by Ride-Read.
the class ChatActivity method sendTextMessage.
private void sendTextMessage(String text) {
final AVIMTextMessage message = new AVIMTextMessage();
message.setText(text);
datas.add(new ChatMessage(1, R.mipmap.me, null, text, null));
adapter.notifyDataSetChanged();
chatlist.smoothScrollToPosition(adapter.getCount() - 1);
editor.setText("");
imConversation.sendMessage(message, new AVIMConversationCallback() {
@Override
public void done(AVIMException e) {
if (filterException(e)) {
Log.e("信息发送", "信息发送成功");
} else {
Log.e("信息发送", "信息发送失败");
}
}
});
}
use of com.rideread.rideread.bean.ChatMessage in project ride-read-android by Ride-Read.
the class ChatActivity method onEvent.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(ImTypeMessageEvent event) {
if (null != imConversation && null != event && imConversation.getConversationId().equals(event.conversation.getConversationId())) {
if (event.message instanceof AVIMTextMessage) {
String msg = ((AVIMTextMessage) event.message).getText();
ChatMessage chatMessage = new ChatMessage(0, R.mipmap.me, menberId, msg, null);
adapter.addMessage(chatMessage);
adapter.notifyDataSetChanged();
chatlist.smoothScrollToPosition(adapter.getCount() - 1);
}
}
}
use of com.rideread.rideread.bean.ChatMessage in project ride-read-android by Ride-Read.
the class ChatActivity method initDatas.
private void initDatas() {
if (mDaoSession == null) {
mDaoSession = RideReadDBHelper.getInstance().getmDaoSession();
}
menberId = getIntent().getStringExtra("menberid");
//模拟本地数据,此处应该是查询本地聊天记录.
//datas=new ArrayList<ChatMessage>();
mDaoSession.insert(new ChatMessage(1, R.mipmap.me, menberId, "消息内容", null));
mDaoSession.insert(new ChatMessage(0, R.mipmap.me, "me", "消息内容消息内容消息内容", null));
// datas.add();
// datas.add();
// datas.add(new ChatMessage(0,R.mipmap.me,"me","消息内容消息内容消息内容消息内容消息内容",null));
datas = mDaoSession.loadAll(ChatMessage.class);
initView(datas);
}
Aggregations