/**
   * 将用户名为username的用户从群中删除,同时在用户列表中删除群的信息
   *
   * @param username
   */
  public static void deleteMemberFromGroup(String username) {
    AVQuery<AVObject> query = new AVQuery<AVObject>("Group");
    try {
      sharegroup = query.get(groupid(username));
      // 获取群的id,并从用户列表中删除所在群的id,表明脱离群关系
      String objectid = sharegroup.getObjectId();
      groupShareid.remove(objectid);
      if (groupShareid != null && groupShareid.size() != 0) {
        LoginUtil.userinfo.put("groupsharedidsstr", Utils.strCombine(groupShareid));
      } else {
        LoginUtil.userinfo.put("groupsharedidsstr", "");
      }
      LoginUtil.userinfo.save();

      // 从群中删除用户的信息,如果群为空,则删除群
      String memberidsstr = sharegroup.getString("memberids"); // �获取所有群成员的id
      List<String> memberids = Utils.strParse(memberidsstr);
      for (String id : memberids) {
        if (id.equals(LoginUtil.userinfo.getObjectId())) {
          memberids.remove(id);
          break;
        }
      }
      if (memberids != null && memberids.size() != 0) {
        sharegroup.put("memberids", Utils.strCombine(memberids));
        sharegroup.save();
      } else {
        sharegroup.delete();
      }
    } catch (AVException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /** 删除单个用户名为username成员 */
  public static void deleteMember(String username) {
    AVObject person = new AVObject();
    AVQuery<AVObject> query1 = new AVQuery<AVObject>("UserInfo");
    try {
      person = query1.get(id(username));
      String singlesharedstr = person.getString("singlesharedidsstr");
      List<String> singleids = Utils.strParse(singlesharedstr);
      singleids.remove(LoginUtil.userinfo.getObjectId());

      // 从被动好友一方删除登陆用户
      if (singleids != null && singleids.size() != 0) {
        person.put("singlesharedidsstr", Utils.strCombine(singleids));
      } else {
        person.put("singlesharedidsstr", "");
      }
      person.save();
      // 从登陆用户列表中删除
      singleShareid.remove(person.getObjectId());
      if (singleShareid != null && singleShareid.size() != 0) {
        LoginUtil.userinfo.put("singlesharedidsstr", Utils.strCombine(singleShareid));
      } else {
        LoginUtil.userinfo.put("singlesharedidsstr", "");
      }
      LoginUtil.userinfo.save();

    } catch (AVException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public static void init() {
    try {
      LoginUtil.userinfo.refresh();
    } catch (AVException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    String single = LoginUtil.userinfo.getString("singlesharedidsstr");
    if (single != null && single.length() != 0) {
      singleShareid = Utils.strParse(single);
    }
    String group = LoginUtil.userinfo.getString("groupsharedidsstr");
    if (group != null && group.length() != 0) {
      groupShareid = Utils.strParse(group);
    }
    List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
    AVQuery<AVObject> query = new AVQuery<AVObject>("UserInfo");
    AVQuery<AVObject> query1 = new AVQuery<AVObject>("Group");
    if (singleShareid == null && groupShareid == null) {
      return;
    } else {

      if (singleShareid != null && singleShareid.size() != 0) {
        singleShareName.clear();
        for (String shareid : singleShareid) {
          try {
            singleShareName.add(query.get(shareid).getString("username"));
          } catch (AVException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
        for (String singlesharename : singleShareName) {
          HashMap<String, Object> item = new HashMap<String, Object>();
          item.put("name", singlesharename);
          data.add(item);
        }
      }
      if (groupShareid != null && groupShareid.size() != 0) {
        groupShareName.clear();
        for (String shareid : groupShareid) {
          try {
            query1.get(shareid).refresh();
            groupShareName.add(query1.get(shareid).getString("groupname"));
          } catch (AVException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
        for (String groupsharename : groupShareName) {
          HashMap<String, Object> item = new HashMap<String, Object>();
          item.put("name", groupsharename);
          data.add(item);
        }
      }
      SimpleAdapter adapter =
          new SimpleAdapter(
              context, data, R.layout.item, new String[] {"name"}, new int[] {R.id.name});
      listview.setAdapter(adapter);
    }
  }
 public static AVUser findUser(String id) throws AVException {
   AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   return q.get(id);
 }