Ejemplo n.º 1
0
 /**
  * 鍦ㄤ細璇濆垪琛ㄤ腑鎺ユ敹娑堟伅
  *
  * @param event
  */
 public void onEventMainThread(MessageEvent event) {
   Log.i(TAG, "onEventMainThread MessageEvent execute");
   Message msg = event.getMessage();
   String targetID = msg.getTargetID();
   ConversationType convType = msg.getTargetType();
   Conversation conv;
   if (convType == ConversationType.group) {
     conv = JMessageClient.getGroupConversation(Integer.parseInt(targetID));
   } else {
     conv = JMessageClient.getSingleConversation(targetID);
   }
   if (conv != null && convType == ConversationType.single) {
     // 濡傛灉缂撳瓨浜嗗ご鍍忥紝鐩存帴鍒锋柊浼氳瘽鍒楄〃
     if (NativeImageLoader.getInstance().getBitmapFromMemCache(targetID) != null) {
       Log.i("Test", "conversation ");
       mConvListController.refreshConvList();
       // 娌℃湁澶村儚锛屼粠Conversation鎷�
     } else {
       File file = conv.getAvatarFile();
       // 鎷垮埌鍚庣紦瀛樺苟鍒锋柊
       if (file != null) {
         mConvListController.loadAvatarAndRefresh(targetID, file.getAbsolutePath());
         // conversation涓病鏈夊ご鍍忥紝鐩存帴鍒锋柊锛孲DK浼氬湪鍚庡彴鑾峰緱澶村儚锛屾嬁鍒板悗浼氭墽琛宱nEvent(ConversationRefreshEvent
         // conversationRefreshEvent)
       } else mConvListController.refreshConvList();
     }
   } else {
     mConvListController.refreshConvList();
   }
 }
  public void onEvent(MessageEvent event) {
    final Message msg = event.getMessage();

    Log.i(TAG, "onEvent:" + msg.toString());

    // 可以在这里创建Notification
    if (msg.getTargetType() == ConversationType.single) {
      JSONObject obj = this.getJSonFormMessage(msg);
      Log.i(TAG, "@@@" + obj.toString());

      PluginResult dataResult = new PluginResult(PluginResult.Status.OK, obj);
      dataResult.setKeepCallback(true);
      if (mJMessageReceiveCallback != null) {
        mJMessageReceiveCallback.sendPluginResult(dataResult);
      }
    } else {
      LOG.w(TAG, "message is not singleTyle");
    }
  }