@Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

          mSearchBar.updateCursorState(false);

          Node curNode = adapter.getItem(position);

          if (!curNode.isDept()) {

            if (adapter.getItem(position).getId() == EngineConst.uId) {
              EmployeeDetailActivity.launch(mContext);

            } else {
              Intent intent = new Intent(mContext, DialogueActivity.class);
              Bundle data = new Bundle();
              data.putInt("cid", EngineConst.cId);
              data.putInt("uid", curNode.getId());
              data.putString("name", curNode.getNodeData().nodeName);
              data.putBoolean("sex", curNode.getNodeData().isBoy);

              LogFactory.d(
                  "data",
                  "cid="
                      + EngineConst.cId
                      + "  uid ="
                      + curNode.getId()
                      + "  mName= "
                      + curNode.getNodeData().nodeName);

              Integer myMsgUserid = curNode.getId();
              if (!IMOApp.sendMsgUserId.isEmpty()) {
                if (IMOApp.sendMsgUserId.contains(curNode.getId())) {
                  IMOApp.sendMsgUserId.remove(myMsgUserid);
                  System.out.println("剩余的 msg id-----" + IMOApp.sendMsgUserId);
                  if (IMOApp.sendMsgUserId.isEmpty()) {
                    MainActivityGroup.getActivityGroup().mHandler.sendEmptyMessage(0);
                  }
                }
              }
              startActivity(intent.putExtras(data));
            }
          } else {

            mStructNavView.setVisibility(View.VISIBLE);
            adapter.showChildNodes(curNode);
            mListView.setSelection(0); // / for selected first node
            if (mStructNavView.getViewGroupChildCount() == 0) {
              mStructNavView.addItem(rootNodeDept.getNodeData().nodeName, rootNodeDept);
            }
            mStructNavView.addItem(curNode.getNodeData().nodeName, curNode);
            // 实现导航点击事件的封装。
            mStructNavView.setOnItemClickListener(adapter);
          }
        }
  @Override
  protected void registerEvents() {
    String isFirstLoading =
        (String) PreferenceManager.get("IMOLoading", new String[] {"isFirstLoading", "no"});
    MainActivityGroup.getActivityGroup().updateTipShow(!isFirstLoading.equals("yes"));

    if (getTcpConnection() == null) {
      resetConnection();
      if (getTcpConnection() != null) {
        IMOApp.getDataEngine().addToObserverList(this);
      }
    } else {
      IMOApp.getDataEngine().addToObserverList(this);
    }

    // //1- 更新自己的状态 login over
    doRequestOwnState();
    // / 2- 发送CrashReport
    sendCrashMSG();

    getOrganizeTree();

    getContactTree();

    mTitleBar.setSystemSetListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              return true;
            }
            if (event.getAction() == MotionEvent.ACTION_UP) {
              SystemSetActivity.launch(OrganizeActivity.this);
              return true;
            }

            return true;
          }
        });

    mTitleBar.setFaceOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            UserConfigActivity.launch(mContext);
          }
        });

    // ///状态弹窗显示
    mTitleBar.setStateOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            mChangeStatePop.popUp(getWindow().getDecorView());
          }
        });

    mChangeStatePop.setListener(
        new OnStateClickListener() {

          @Override
          public void onClickAction() {
            Globe.canConnect = false;
            requestLogOut(false);
          }
        });

    mChangeStatePop.setReLoginListener(
        new OnStateClickListener() {

          @Override
          public void onClickAction() {
            if (EngineConst.isNetworkValid && EngineConst.isReloginSuccess) {
              return;
            } else if (ConnectionChangeReceiver.pingAddress()) {
              System.out.println("shoudong old connection id = " + EngineConst.IMO_CONNECTION_ID);
              EngineConst.isReloginSuccess = false;
              String oldConnectionID = EngineConst.IMO_CONNECTION_ID;

              EngineConst.IMO_CONNECTION_ID = EngineConst.GenerateRandomString();

              System.out.println(
                  "shoudong new connection id :"
                      + EngineConst.IMO_CONNECTION_ID
                      + ",old connectionID :"
                      + oldConnectionID);

              AppService.getService()
                  .setTcpConnection(
                      (TCPConnection)
                          AppService.getService()
                              .getNIOThreadInstance()
                              .newTCPConnection(
                                  EngineConst.IMO_CONNECTION_ID,
                                  EngineConst.IMO_SERVER_ADDRESS,
                                  true));

              AppService.getService().getNIOThreadInstance().release(oldConnectionID, false);

              ReloginOutPacket out =
                  new ReloginOutPacket(
                      ByteBuffer.wrap(EngineConst.sessionKey),
                      IMOCommand.IMO_GET_RELOGIN,
                      EngineConst.cId,
                      EngineConst.uId);
              AppService.getService()
                  .getNIOThreadInstance()
                  .send(EngineConst.IMO_CONNECTION_ID, out, false);
            }
          }
        });

    mSearchBar.setOnClickEvent();

    mSearchBar.setOnSearchListener(
        new OnSearchListener() {

          @Override
          public void onSearch(View v) {
            LogFactory.d(TAG, "Dynamic key = " + ((EditText) v).getText());

            doSearch(((EditText) v).getText().toString().trim());
          }

          private void doSearch(String key) {
            // 查询的结果UIDList
            update2State(true);
            // 数据库中查询结果
            ArrayList<Integer> deptUserId = IMOApp.imoStorage.search(key);

            if (deptUserId != null) {
              mSearchResultAdapter.setShowData(getSearchResult(deptUserId));
              mSearchRestltListView.setAdapter(mSearchResultAdapter);
            } else {
              mSearchResultAdapter.setEmpty();
            }
          }

          @Override
          public void initState() {
            update2State(false);
          }
        });

    mSearchRestltListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
            if (mSearchResultAdapter.getItem(position).getId() == EngineConst.uId) {
              EmployeeDetailActivity.launch(mContext);

            } else {
              Intent intent = new Intent(mContext, DialogueActivity.class);
              Bundle data = new Bundle();
              Node curNode = mSearchResultAdapter.getItem(position);
              data.putInt("cid", curNode.getCid());
              data.putInt("uid", curNode.getId());
              data.putString("name", curNode.getNodeData().nodeName);
              data.putBoolean("sex", curNode.getNodeData().isBoy);
              startActivity(intent.putExtras(data));
            }
          }
        });
  }