public static List<AVUser> searchUser(String searchName, int skip) throws AVException {
   AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
   q.whereContains(User.USERNAME, searchName);
   q.limit(Constant.PAGE_SIZE);
   q.skip(skip);
   AVUser user = AVUser.getCurrentUser();
   List<String> friendIds = new ArrayList<String>(CacheService.getFriendIds());
   friendIds.add(user.getObjectId());
   q.whereNotContainedIn(Constant.OBJECT_ID, friendIds);
   q.orderByDescending(Constant.UPDATED_AT);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   List<AVUser> users = q.find();
   CacheService.registerUsers(users);
   return users;
 }
  private void addQueryRule(T anchor, boolean afterwards, int pageSize, AVQuery<T> query) {

    // set page size
    query.limit(pageSize);
    // before or after

    String queryOrder = query.getOrder();
    if ((anchor != null) && (queryOrder != null)) {
      boolean isDescending = queryOrder.startsWith("-");
      String field = isDescending ? queryOrder.substring(1) : queryOrder;
      if ((isDescending && afterwards) || (!isDescending && !afterwards)) {
        query.whereLessThan(field, anchor.get(field));
      } else {
        query.whereGreaterThan(field, anchor.get(field));
      }
    }
  }
 private void loadMoreFriend(int skip, final int limit, final boolean isRefresh) {
   AVQuery<LeanchatUser> q = LeanchatUser.getQuery(LeanchatUser.class);
   q.whereContains(LeanchatUser.USERNAME, searchName);
   q.limit(Constants.PAGE_SIZE);
   q.skip(skip);
   LeanchatUser user = LeanchatUser.getCurrentUser();
   List<String> friendIds = new ArrayList<String>(FriendsManager.getFriendIds());
   friendIds.add(user.getObjectId());
   q.whereNotContainedIn(Constants.OBJECT_ID, friendIds);
   q.orderByDescending(Constants.UPDATED_AT);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   q.findInBackground(
       new FindCallback<LeanchatUser>() {
         @Override
         public void done(List<LeanchatUser> list, AVException e) {
           UserCacheUtils.cacheUsers(list);
           recyclerView.setLoadComplete(list.toArray(), false);
         }
       });
 }
  public static List<CompanyPost> findCompanyPost(
      int skip, int limit, String dateString, String cityName) throws AVException {

    AVQuery<CompanyPost> q = CompanyPost.getQuery(CompanyPost.class);
    // hehe 还好哟示例
    // TODO  这里如果include user 其他用户没法发布评论啊....尼玛啊  但是为什么能取到ObjectId呢啊啊啊啊,ffff  这里查到了是不是要保存到cache里边啊?!
    q.include(CompanyPost.USER);
    q.include(CompanyPost.COMMENT);
    if (dateString != null && !dateString.isEmpty()) {
      Date startDate;
      Date endDate;
      Date nowDate = new Date();
      try {
        startDate = DateUtils.getFirstDayOfMonth(dateString, "yyyy-MM-dd");
        // 必须比今天要早不是么...
        if (nowDate.getTime() > startDate.getTime()) {
          startDate = nowDate;
        }
        endDate = DateUtils.getLastDayOfMonth(dateString, "yyyy-MM-dd");
      } catch (Exception e) {
        e.printStackTrace();
        return new ArrayList<>();
      }
      q.whereGreaterThan("datePlanned", startDate);
      q.whereLessThan("datePlanned", endDate);
    }

    if (cityName != null && !cityName.isEmpty()) {
      q.whereEqualTo("destination", cityName);
    }
    q.skip(skip);
    q.limit(limit);
    q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
    q.orderByDescending(AVObject.CREATED_AT);
    List<CompanyPost> posts = q.find();
    for (int i = 0; i < posts.size(); i++) {
      CacheService.registerUser((LeanchatUser) posts.get(i).getPublisher());
    }
    return posts;
  }