Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/MapFragment.java
Show First 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | private void requestStopsToShow(){ | ||||
new AsyncStopFetcher.BoundingBoxLimit(lngFrom,lngTo,latFrom, latTo)); | new AsyncStopFetcher.BoundingBoxLimit(lngFrom,lngTo,latFrom, latTo)); | ||||
} | } | ||||
/** | /** | ||||
* Add stops as Markers on the map | * Add stops as Markers on the map | ||||
* @param stops the list of stops that must be included | * @param stops the list of stops that must be included | ||||
*/ | */ | ||||
protected void showStopsMarkers(List<Stop> stops){ | protected void showStopsMarkers(List<Stop> stops){ | ||||
if (getContext() == null){ | if (getContext() == null || stops == null){ | ||||
//we are not attached | //we are not attached | ||||
return; | return; | ||||
} | } | ||||
boolean good = true; | boolean good = true; | ||||
for (Stop stop : stops) { | for (Stop stop : stops) { | ||||
if (shownStops.contains(stop.ID)){ | if (shownStops.contains(stop.ID)){ | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | static class AsyncStopFetcher extends AsyncTask<AsyncStopFetcher.BoundingBoxLimit,Void, List<Stop>>{ | ||||
return null; | return null; | ||||
} | } | ||||
final BoundingBoxLimit limit = limits[0]; | final BoundingBoxLimit limit = limits[0]; | ||||
//Log.d(DEBUG_TAG, "Async Stop Fetcher started working"); | //Log.d(DEBUG_TAG, "Async Stop Fetcher started working"); | ||||
NextGenDB dbHelper = new NextGenDB(fragmentWeakReference.get().getContext()); | NextGenDB dbHelper = new NextGenDB(fragmentWeakReference.get().getContext()); | ||||
Stop[] stops = dbHelper.queryAllInsideMapView(limit.latitFrom, limit.latitTo, | ArrayList<Stop> stops = dbHelper.queryAllInsideMapView(limit.latitFrom, limit.latitTo, | ||||
limit.longFrom, limit.latitTo); | limit.longFrom, limit.latitTo); | ||||
dbHelper.close(); | dbHelper.close(); | ||||
return Arrays.asList(stops); | return stops; | ||||
} | } | ||||
@Override | @Override | ||||
protected void onPostExecute(List<Stop> stops) { | protected void onPostExecute(List<Stop> stops) { | ||||
super.onPostExecute(stops); | super.onPostExecute(stops); | ||||
//Log.d(DEBUG_TAG, "Async Stop Fetcher has finished working"); | //Log.d(DEBUG_TAG, "Async Stop Fetcher has finished working"); | ||||
if(fragmentWeakReference.get()==null) { | if(fragmentWeakReference.get()==null) { | ||||
Log.w(DEBUG_TAG, "AsyncLoad fragmentWeakreference null"); | Log.w(DEBUG_TAG, "AsyncLoad fragmentWeakreference null"); | ||||
return; | return; | ||||
} | } | ||||
if (stops!=null) | |||||
Log.d(DEBUG_TAG, "AsyncLoad number of stops: "+stops.size()); | Log.d(DEBUG_TAG, "AsyncLoad number of stops: "+stops.size()); | ||||
fragmentWeakReference.get().showStopsMarkers(stops); | fragmentWeakReference.get().showStopsMarkers(stops); | ||||
} | } | ||||
private static class BoundingBoxLimit{ | private static class BoundingBoxLimit{ | ||||
final double longFrom, longTo, latitFrom, latitTo; | final double longFrom, longTo, latitFrom, latitTo; | ||||
public BoundingBoxLimit(double longFrom, double longTo, double latitFrom, double latitTo) { | public BoundingBoxLimit(double longFrom, double longTo, double latitFrom, double latitTo) { | ||||
this.longFrom = longFrom; | this.longFrom = longFrom; | ||||
this.longTo = longTo; | this.longTo = longTo; | ||||
this.latitFrom = latitFrom; | this.latitFrom = latitFrom; | ||||
this.latitTo = latitTo; | this.latitTo = latitTo; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register