private ProgressBar progress;
+ private AltosMapLoader loader;
+
+ long loader_notify_time;
+
/* AltosMapLoaderListener interfaces */
public void loader_start(final int max) {
+ loader_notify_time = System.currentTimeMillis();
+
this.runOnUiThread(new Runnable() {
public void run() {
progress.setMax(max);
}
public void loader_notify(final int cur, final int max, final String name) {
+ long now = System.currentTimeMillis();
+
+ if (now - loader_notify_time < 100)
+ return;
+
+ loader_notify_time = now;
+
this.runOnUiThread(new Runnable() {
public void run() {
progress.setProgress(cur);
}
public void loader_done(int max) {
+ loader = null;
this.runOnUiThread(new Runnable() {
public void run() {
progress.setProgress(0);
}
private void load() {
+ if (loader != null)
+ return;
+
try {
double lat = latitude();
double lon = longitude();
AltosDebug.debug("PreloadMap load %f %f %d %d %f %d\n",
lat, lon, min, max, r, t);
- new AltosMapLoader(map, this, lat, lon, min, max, r, t);
+ loader = new AltosMapLoader(map, this, lat, lon, min, max, r, t);
} catch (ParseException e) {
AltosDebug.debug("PreloadMap load raised exception %s", e.toString());
}
protected void onDestroy() {
super.onDestroy();
+ if (loader != null)
+ loader.abort();
+
// Stop listening for location updates
((LocationManager) getSystemService(Context.LOCATION_SERVICE)).removeUpdates(this);
}