Пример #1
0
  private void executeQuery() {
    if (mLastLocation == null) return;

    ParseQuery<Building> buildingQuery = ParseQuery.getQuery(Building.class);

    buildingQuery.whereNear(
        Building.KEY_LOCATION,
        new ParseGeoPoint(mLastLocation.getLatitude(), mLastLocation.getLongitude()));
    isQueryInProgress = true;

    //        if (mSort.equals("upcoming")) {
    //            buildingQuery.orderByAscending("Time");
    //        } else {
    //            buildingQuery.orderByAscending("Location");
    //        }

    buildingQuery.findInBackground(
        new FindCallback<Building>() {
          @Override
          public void done(List<Building> objects, ParseException e) {
            mAdapter.clear();
            needsData = false;
            isQueryInProgress = false;
            for (Building building : objects) {
              ParseQuery<Event> eventQuery = ParseQuery.getQuery(Event.class);
              eventQuery.whereEqualTo("Location", building);
              eventQuery.whereEqualTo("Tags", mSort);
              eventQuery.findInBackground(
                  new FindCallback<Event>() {
                    @Override
                    public void done(List<Event> objects, ParseException e) {
                      Log.d("Event", objects.toString());
                      mAdapter.addAll(objects);
                    }
                  });
            }
          }
        });
  }