@Test public void count_file_in_background() throws Exception { Assert.assertFalse(callbackFlag); NCMBQuery<NCMBFile> query = NCMBFile.getQuery(); query.countInBackground(new CountCallback() { @Override public void done(int result, NCMBException e) { if (e != null) { Assert.fail("this callback should not raise exception"); } else { Assert.assertEquals(result, 50); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void countInBackground(CountCallback callback) { int iSetLimitNumber = limitNumber; countFlag = true; limitNumber = 1; NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); JSONObject countConditions = getConditions(); limitNumber = iSetLimitNumber; countFlag = false; objServ.countObjectInBackground(mClassName, countConditions, callback); }
NCMBQuery { public void countInBackground(CountCallback callback) { int iSetLimitNumber = limitNumber; countFlag = true; limitNumber = 1; NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); JSONObject countConditions = getConditions(); limitNumber = iSetLimitNumber; countFlag = false; objServ.countObjectInBackground(mClassName, countConditions, callback); } }
NCMBQuery { public void countInBackground(CountCallback callback) { int iSetLimitNumber = limitNumber; countFlag = true; limitNumber = 1; NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); JSONObject countConditions = getConditions(); limitNumber = iSetLimitNumber; countFlag = false; objServ.countObjectInBackground(mClassName, countConditions, callback); } NCMBQuery(String className); }
NCMBQuery { public void countInBackground(CountCallback callback) { int iSetLimitNumber = limitNumber; countFlag = true; limitNumber = 1; NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); JSONObject countConditions = getConditions(); limitNumber = iSetLimitNumber; countFlag = false; objServ.countObjectInBackground(mClassName, countConditions, callback); } NCMBQuery(String className); List<T> find(); void findInBackground(final FindCallback<T> callback); JSONObject getConditions(); void whereEqualTo(String key, Object value); void whereNotEqualTo(String key, Object value); void whereLessThan(String key, Object value); void whereGreaterThan(String key, Object value); void whereLessThanOrEqualTo(String key, Object value); void whereGreaterThanOrEqualTo(String key, Object value); void whereContainedIn(String key, Collection<? extends Object> objects); void whereNotContainedIn(String key, Collection<? extends Object> objects); void whereExists(String key); void whereDoesNotExists(String key); void whereContainedInArray(String key, Collection<? extends Object> elements); void whereNotContainedInArray(String key, Collection<? extends Object> elements); void whereContainsAll(String key, Collection<? extends Object> elements); void or(Collection<NCMBQuery> queries); void whereMatchesKeyInQuery(String key, String inQueryKey, NCMBQuery inQuery); void whereMatchesQuery(String key, NCMBQuery inQuery); void whereRelatedTo(NCMBObject parent, String key); void whereWithinGeoBox(String key, Location southwest, Location northeast); void whereWithinKilometers(String key, Location center, double distance); void whereWithinMiles(String key, Location center, int distance); void whereWithinRadians(String key, Location center, int distance); void setLimit(int number); void setSkip(int number); void setIncludeKey(String key); void addOrderByAscending(String key); void addOrderByDescending(String key); void deleteOrder(String key); int count(); void countInBackground(CountCallback callback); }
NCMBQuery { public void countInBackground(CountCallback callback) { int iSetLimitNumber = limitNumber; countFlag = true; limitNumber = 1; NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); JSONObject countConditions = getConditions(); limitNumber = iSetLimitNumber; countFlag = false; objServ.countObjectInBackground(mClassName, countConditions, callback); } NCMBQuery(String className); List<T> find(); void findInBackground(final FindCallback<T> callback); JSONObject getConditions(); void whereEqualTo(String key, Object value); void whereNotEqualTo(String key, Object value); void whereLessThan(String key, Object value); void whereGreaterThan(String key, Object value); void whereLessThanOrEqualTo(String key, Object value); void whereGreaterThanOrEqualTo(String key, Object value); void whereContainedIn(String key, Collection<? extends Object> objects); void whereNotContainedIn(String key, Collection<? extends Object> objects); void whereExists(String key); void whereDoesNotExists(String key); void whereContainedInArray(String key, Collection<? extends Object> elements); void whereNotContainedInArray(String key, Collection<? extends Object> elements); void whereContainsAll(String key, Collection<? extends Object> elements); void or(Collection<NCMBQuery> queries); void whereMatchesKeyInQuery(String key, String inQueryKey, NCMBQuery inQuery); void whereMatchesQuery(String key, NCMBQuery inQuery); void whereRelatedTo(NCMBObject parent, String key); void whereWithinGeoBox(String key, Location southwest, Location northeast); void whereWithinKilometers(String key, Location center, double distance); void whereWithinMiles(String key, Location center, int distance); void whereWithinRadians(String key, Location center, int distance); void setLimit(int number); void setSkip(int number); void setIncludeKey(String key); void addOrderByAscending(String key); void addOrderByDescending(String key); void deleteOrder(String key); int count(); void countInBackground(CountCallback callback);  }