Dynamic "where" in custom ParseQueryAdapter
I am using Parse.com as a framework to populate a ListView. My adapter looks like this:
public ItemsQueryAdapter(Context context) {
super(context, new ParseQueryAdapter.QueryFactory<ParseObject>() {
public ParseQuery create() {
ParseQuery Query = ParseQuery.getQuery("Item");
LatLngBounds latLngBounds = new LatLngBounds.Builder().
include(SphericalUtil.computeOffset(currentLatLng, currentRadius, 0)).
include(SphericalUtil.computeOffset(currentLatLng, currentRadius, 90)).
include(SphericalUtil.computeOffset(currentLatLng, currentRadius, 180)).
include(SphericalUtil.computeOffset(currentLatLng, currentRadius, 270)).build();
itemsQuery.whereWithinGeoBox("location", new ParseGeoPoint(latLngBounds.southwest.latitude, latLngBounds.southwest.longitude), new ParseGeoPoint(latLngBounds.northeast.latitude, latLngBounds.northeast.longitude));
itemsQuery.orderByDescending("createdAt");
itemsQuery.include("user");
return itemsQuery;
}
});
}
And my ListView is populated like this:
itemsQueryAdapter = new ItemsQueryAdapter(getActivity());
ListView listView = (ListView) getView().findViewById(R.id.lvItems);
listView.setAdapter(itemsQueryAdapter);
itemsQueryAdapter.loadObjects();
The problem I am facing is that inside a custom adapter, both currentLatLng and currentRadius can change and therefore must be dynamically "loaded" on each loadObjects (). Is there a way to do this?
Best regards, D.
+3
source to share
No one has answered this question yet
Check out similar questions: