private void reloadMembers() { GroupMemberListModel model = (GroupMemberListModel) listModels.get(namedObject.getEntity()); List<? extends QQStranger> members = getMembers(); if (model == null) { model = new GroupMemberListModel(new UserListComparator()); for (QQStranger m : members) { model.addElement(new UserListElement(new UIUser(m))); // 下载头像, 只下载一次,后面是手动更新 if (isLoadFace) { IMEventService events = getContext().getSerivce(IMService.Type.EVENT); events.broadcast(new IMEvent(IMEventType.USER_FACE_REQUEST, m)); } } listModels.put(namedObject.getEntity(), model); } model.sort(); // 根据状态排序 membersCount.setText("Members (" + getOnlineCount(members) + "/" + members.size() + ")"); if (model != memberList.getModel()) { memberList.setModel(model); } model.updateAll(); // 停止进度条 progressOverlay.setShowLoad(false); }
@IMEventHandler(IMEventType.SHOW_MEMBERS_WINDOW) protected void showMembersWindow(IMEvent event) { UINamedObject named = (UINamedObject) event.getTarget(); Window win = event.getData("view"); Rectangle rect = win.getBounds(); setLocation(rect.x + rect.width - 30, rect.y + 25); setIconImage(named.getIcon()); setTitle(named.getName()); this.namedObject = named; progressOverlay.setShowLoad(true); setVisible(true); isLoadFace = true; // 设置允许下载头像 checkReloadMembers(namedObject); // 显示成员 win.addComponentListener( new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { int x = e.getComponent().getX() + e.getComponent().getWidth() - 30; int y = e.getComponent().getY() + 25; if (isPtInRect(getBounds(), new Point(x, y))) { setLocation(x, y); } } }); }