Open henrylao opened 3 years ago
Tested querying on data-models-branch
public void queryAvailableRoutes(List<RoomRoute> allRoutes) {
allRoutes.clear();
ParseQuery<RoomRoute> mainQuery = new ParseQuery<RoomRoute>(RoomRoute.class);
mainQuery.whereEqualTo(RoomRoute.KEY_IS_AVAILABLE, true);
mainQuery.findInBackground(new FindCallback<RoomRoute>() {
@Override
public void done(List<RoomRoute> routesFound, ParseException e) {
if (e == null) {
allRoutes.addAll(routesFound);
Log.i(TAG, String.valueOf(allRoutes.size()) + " routes found");
String toDisplay = "";
for (RoomRoute r : routesFound) {
Log.i(TAG, r.getPhoneNumber());
toDisplay += r.getPhoneNumber();
toDisplay += "\n";
}
Toast.makeText(getBaseContext(), toDisplay, Toast.LENGTH_SHORT).show();
// add handling for no-routes found case
// assignment should be done immediately... on the first resource found?
// create room here and navigate accordingly away
// current implementation opens itself up to race conditions tho unlikely
} else {
// add handling if there are issues with querying
Log.i(TAG, "Error querying routes");
}
}
});
}