Fix exceptions

This commit is contained in:
Victor Shcherb 2012-09-29 16:10:31 +02:00
parent f5e1513b8c
commit cbfd48aa6e
3 changed files with 46 additions and 6 deletions

View file

@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import net.osmand.LogUtil;
import net.osmand.plus.OsmandApplication;
@ -81,8 +83,41 @@ public class LiveMonitoringHelper {
}
public void sendData(LiveMonitoringData data) {
String url = MessageFormat.format(settings.LIVE_MONITORING_URL.get(), data.lat+"", data.lon+"",
data.time+"", data.hdop+"", data.alt+"", data.speed+"");
String st = settings.LIVE_MONITORING_URL.get();
List<String> prm = new ArrayList<String>();
int maxLen = 0;
for(int i = 0; i < 6; i++) {
boolean b = st.contains("{"+i+"}");
if(b) {
maxLen = i;
}
}
for (int i = 0; i < maxLen + 1; i++) {
switch (i) {
case 0:
prm.add(data.lat + "");
break;
case 1:
prm.add(data.lon + "");
break;
case 2:
prm.add(data.time + "");
break;
case 3:
prm.add(data.hdop + "");
break;
case 4:
prm.add(data.alt + "");
break;
case 5:
prm.add(data.speed + "");
break;
default:
break;
}
}
String url = MessageFormat.format(st, prm.toArray());
try {
HttpParams params = new BasicHttpParams();

View file

@ -946,6 +946,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(),
settings.getIntermediatePoints(), getLastKnownLocation(), routingHelper.getCurrentGPXRoute());
}
mapView.refreshMap();
}
public void followRoute(ApplicationMode appMode, LatLon finalLocation, List<LatLon> intermediatePoints, Location currentLocation, GPXRouteParams gpxRoute){

View file

@ -161,7 +161,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
}
SQLiteDatabase db = getWritableDatabase();
if (db != null && warnings.isEmpty()) {
if (db != null && warnings.isEmpty() && db.isOpen()) {
try {
// remove all from db
db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE " + TRACK_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@ -180,9 +180,13 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
public Map<String, GPXFile> collectRecordedData() {
Map<String, GPXFile> data = new LinkedHashMap<String, GPXFile>();
SQLiteDatabase db = getReadableDatabase();
if(db != null) {
collectDBPoints(db, data);
collectDBTracks(db, data);
if (db != null && db.isOpen()) {
try {
collectDBPoints(db, data);
collectDBTracks(db, data);
} finally {
db.close();
}
}
return data;
}