public static void queryUser(String username, FindCallback<LeanchatUser> findCallback) { final long a = System.currentTimeMillis(); // AVQuery<LeanchatUser> query = new AVQuery<>("_User"); AVQuery<LeanchatUser> query = AVObject.getQuery(LeanchatUser.class); query.whereEqualTo(LeanchatUser.USERNAME, username); query.findInBackground(findCallback); }
public void getRolesInBackground(final AVCallback<List<AVRole>> callback) { AVQuery<AVRole> roleQuery = new AVQuery<AVRole>(AVRole.className); roleQuery.whereEqualTo(AVUSER_ENDPOINT, this); roleQuery.findInBackground(new FindCallback<AVRole>() { @Override public void done(List<AVRole> list, AVException e) { callback.internalDone(list, e); } }); }
/** * Create a query that can be used to query the parent objects in this relation. * * @param parentClassName The parent class name * @param relationKey The relation field key in parent * @param child The child object. * @return A AVQuery that restricts the results to parent objects in this relations. */ public static <M extends AVObject> AVQuery<M> reverseQuery(String parentClassName, String relationKey, AVObject child) { AVQuery<M> query = new AVQuery<M>(parentClassName); query.whereEqualTo(relationKey, AVUtils.mapFromPointerObject(child)); return query; }
/** * Create a query that can be used to query the parent objects in this relation. * * @param parentClassName The parent class name * @param relationKey The relation field key in parent * @param child The child object. * @return A AVQuery that restricts the results to parent objects in this relations. */ public static <M extends AVObject> AVQuery<M> reverseQuery(String parentClassName, String relationKey, AVObject child) { AVQuery<M> query = new AVQuery<M>(parentClassName); query.whereEqualTo(relationKey, AVUtils.mapFromPointerObject(child)); return query; }
/** * 从 server 获取未读消息的数量 */ public void countUnreadRequests(final CountCallback countCallback) { AVQuery<AddRequest> addRequestAVQuery = AVObject.getQuery(AddRequest.class); addRequestAVQuery.setCachePolicy(AVQuery.CachePolicy.NETWORK_ONLY); addRequestAVQuery.whereEqualTo(AddRequest.TO_USER, LeanchatUser.getCurrentUser()); addRequestAVQuery.whereEqualTo(AddRequest.IS_READ, false); addRequestAVQuery.countInBackground(new CountCallback() { @Override public void done(int i, AVException e) { if (null != countCallback) { unreadAddRequestsCount = i; countCallback.done(i, e); } } }); }
@JSONField(serialize = false) public List<AVRole> getRoles() throws AVException { AVQuery<AVRole> roleQuery = new AVQuery<AVRole>(AVRole.className); roleQuery.whereEqualTo(AVUser.AVUSER_ENDPOINT, this); return roleQuery.find(); }
pushQuery.whereNotContainedIn(deviceTypeTag, DEVICE_TYPES); } else if (pushTarget.size() == 1) { pushQuery.whereEqualTo(deviceTypeTag, pushTarget.toArray()[0]);
pushQuery.whereNotContainedIn(deviceTypeTag, DEVICE_TYPES); } else if (pushTarget.size() == 1) { pushQuery.whereEqualTo(deviceTypeTag, pushTarget.toArray()[0]);
/** * Create a query that can be used to query the parent objects in this relation. * * @param theParentClazz The parent subclass. * @param relationKey The relation field key in parent * @param child The child object. * @return A AVQuery that restricts the results to parent objects in this relations. */ public static <M extends AVObject> AVQuery<M> reverseQuery(Class<M> theParentClazz, String relationKey, AVObject child) { AVQuery<M> query = new AVQuery<M>(AVObject.getSubClassName(theParentClazz), theParentClazz); query.whereEqualTo(relationKey, AVUtils.mapFromPointerObject(child)); return query; }
/** * Create a query that can be used to query the parent objects in this relation. * * @param theParentClazz The parent subclass. * @param relationKey The relation field key in parent * @param child The child object. * @return A AVQuery that restricts the results to parent objects in this relations. */ public static <M extends AVObject> AVQuery<M> reverseQuery(Class<M> theParentClazz, String relationKey, AVObject child) { AVQuery<M> query = new AVQuery<M>(AVObject.getSubClassName(theParentClazz), theParentClazz); query.whereEqualTo(relationKey, AVUtils.mapFromPointerObject(child)); return query; }
private void createAddRequest(LeanchatUser toUser) throws Exception { LeanchatUser curUser = LeanchatUser.getCurrentUser(); AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class); q.whereEqualTo(AddRequest.FROM_USER, curUser); q.whereEqualTo(AddRequest.TO_USER, toUser); q.whereEqualTo(AddRequest.STATUS, AddRequest.STATUS_WAIT); int count = 0; try { count = q.count(); } catch (AVException e) { LogUtils.logException(e); if (e.getCode() == AVException.OBJECT_NOT_FOUND) { count = 0; } else { throw e; } } if (count > 0) { // 抛出异常,然后提示用户 throw new IllegalStateException(App.ctx.getString(R.string.contact_alreadyCreateAddRequest)); } else { AddRequest add = new AddRequest(); add.setFromUser(curUser); add.setToUser(toUser); add.setStatus(AddRequest.STATUS_WAIT); add.setIsRead(false); add.save(); } }
public void findAddRequests(int skip, int limit, FindCallback findCallback) { LeanchatUser user = LeanchatUser.getCurrentUser(); AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class); q.include(AddRequest.FROM_USER); q.skip(skip); q.limit(limit); q.whereEqualTo(AddRequest.TO_USER, user); q.orderByDescending(AVObject.CREATED_AT); q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE); q.findInBackground(findCallback); }
} else { AVQuery<AVObject> query = new AVQuery<>("LiveUser"); query.whereEqualTo("uid", liveUser.getUid()); query.findInBackground(new FindCallback<AVObject>() { @Override