Beispiel #1
0
  private String getMsgContent(TIMMessage msg) {
    String msgContent = new String();
    TIMElem elem = msg.getElement(0);
    if (elem == null) {
      return "";
    }
    if (elem.getType() == TIMElemType.Text) {
      // 文本元素, 获取文本内容
      TIMTextElem e = (TIMTextElem) elem;
      Log.d(TAG, "msg: " + e.getText());
      msgContent = e.getText();
    } else if (elem.getType() == TIMElemType.Image) {
      // 图片元素, getThumb()获取缩略图byte[]
      msgContent = "[图片]";
    } else if (elem.getType() == TIMElemType.File) {
      msgContent = "[文件]";
    } else if (elem.getType() == TIMElemType.Sound) {
      msgContent = "[语音]";
    } else if (elem.getType() == TIMElemType.GroupTips) {
      msgContent = "[群事件通知]";
    } else {
      msgContent = "";
    }

    return msgContent;
  }
 public void onEvent(ChatListEvent chatListEvent) {
   final List<TIMMessage> timMessageList = chatListEvent.getList();
   ListIterator<MyOrderBean.ListEntity> listEntityListIterator =
       (ListIterator<MyOrderBean.ListEntity>) list.listIterator();
   for (TIMMessage message : timMessageList) {
     TIMTextElem element = (TIMTextElem) message.getElement(1);
     String timeId = element.getText();
     if (TextUtils.equals(ChatManager.getChattingFlag(), timeId)) {
       continue;
     }
     while (listEntityListIterator.hasNext()) {
       MyOrderBean.ListEntity entity = listEntityListIterator.next();
       String orderid = entity.getOrderid();
       if (TextUtils.equals(orderid, timeId)) {
         LogTools.w(message.getElementCount() / 4);
         int unread = Integer.valueOf(entity.getUnread());
         int incomming = (int) (message.getElementCount() / 4);
         entity.setUnread(String.valueOf(unread + incomming));
       }
     }
   }
   commonBinderAdapter.notifyDataSetChanged();
 }