protected int count(boolean needsLock) { final int[] value = {0}; countInBackground(true, new CountCallback() { @Override public void done(int count, AVException e) { value[0] = count; } }); return value[0]; }
protected int count(boolean needsLock) { final int[] value = {0}; countInBackground(true, new CountCallback() { @Override public void done(int count, AVException e) { value[0] = count; } }); return value[0]; }
/** * Counts the number of objects that match this query in a background thread. This does not use * caching. * * @param callback callback.done(count, e) will be called when the count completes. */ public void countInBackground(CountCallback callback) { this.countInBackground(false, callback); }
/** * Counts the number of objects that match this query in a background thread. This does not use * caching. * * @param callback callback.done(count, e) will be called when the count completes. */ public void countInBackground(CountCallback callback) { this.countInBackground(false, callback); }
/** * Counts the number of objects that match this query. This does not use caching. */ public int count() throws AVException { final int[] value = {0}; countInBackground(true, new CountCallback() { @Override public void done(int count, AVException e) { if (e == null) { value[0] = count; } else { AVExceptionHolder.add(e); } } @Override protected boolean mustRunOnUIThread() { return false; } }); if (AVExceptionHolder.exists()) { throw AVExceptionHolder.remove(); } return value[0]; }
/** * Counts the number of objects that match this query. This does not use caching. */ public int count() throws AVException { final int[] value = {0}; countInBackground(true, new CountCallback() { @Override public void done(int count, AVException e) { if (e == null) { value[0] = count; } else { AVExceptionHolder.add(e); } } @Override protected boolean mustRunOnUIThread() { return false; } }); if (AVExceptionHolder.exists()) { throw AVExceptionHolder.remove(); } return value[0]; }
/** * 从 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); } } }); }