public static void findUserInConversationAllInfo( String objectId, FindCallback<AVObject> callback) { AVQuery<AVObject> query = new AVQuery<AVObject>(USERINFO); query.whereEqualTo(OBJECTID, objectId); query.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE); query.findInBackground(callback); }
private UpdateInfo getNewestUpdateInfo() throws AVException { AVQuery<UpdateInfo> query = AVObject.getQuery(UpdateInfo.class); query.setLimit(1); query.orderByDescending(UpdateInfo.VERSION); if (policy != null) { query.setCachePolicy(policy); } List<UpdateInfo> updateInfos = query.find(); if (updateInfos.size() > 0) { return updateInfos.get(0); } return null; }
public static void findFriendsWithCachePolicy( AVQuery.CachePolicy cachePolicy, FindCallback<AVUser> findCallback) { AVUser curUser = AVUser.getCurrentUser(); AVQuery<AVUser> q = null; try { q = curUser.followeeQuery(AVUser.class); } catch (Exception e) { throw new NullPointerException(); } q.setCachePolicy(cachePolicy); q.include("followee"); q.findInBackground(findCallback); }
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 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; }
public static void findUserUrl(String id, FindCallback<AVObject> call) throws AVException { AVQuery<AVObject> query = new AVQuery<AVObject>(USERINFO); query.whereEqualTo(USERID, id); query.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE); query.findInBackground(call); // q.get(id); }
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); }