diff --git a/OsmAnd/src/com/bidforfix/andorid/BidForFixActivity.java b/OsmAnd/src/com/bidforfix/andorid/BidForFixActivity.java index 509e7fd62d..9acc1601fd 100644 --- a/OsmAnd/src/com/bidforfix/andorid/BidForFixActivity.java +++ b/OsmAnd/src/com/bidforfix/andorid/BidForFixActivity.java @@ -51,6 +51,10 @@ public abstract class BidForFixActivity extends ListActivity { protected void onCreate(Bundle savedInstanceState) { setTheme(android.R.style.Theme_Light); super.onCreate(savedInstanceState); + // throws null pointer exception on some devices if lv is not set + ListView lv = new ListView(this); + lv.setId(android.R.id.list); + setContentView(lv); if (getHelper().isReloadNeeded()) { showDialog(LOAD_ITEMS); } else { diff --git a/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java b/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java index 076a12bfab..e1d2532b4c 100644 --- a/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java +++ b/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java @@ -1,6 +1,7 @@ package net.osmand.plus; import java.io.File; +import java.util.ArrayList; import java.util.List; import java.util.Stack; @@ -217,7 +218,8 @@ public class AsyncLoadingThread extends Thread { public void finish() { running = false; // use downloader callback - for (IMapDownloaderCallback c : resourceManger.getMapTileDownloader().getDownloaderCallbacks()) { + ArrayList ls = new ArrayList(resourceManger.getMapTileDownloader().getDownloaderCallbacks()); + for (IMapDownloaderCallback c : ls) { c.tileDownloaded(null); } } diff --git a/OsmAnd/src/net/osmand/plus/PoiFilter.java b/OsmAnd/src/net/osmand/plus/PoiFilter.java index 9cf4c78cdc..5a9770eb36 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFilter.java +++ b/OsmAnd/src/net/osmand/plus/PoiFilter.java @@ -145,12 +145,13 @@ public class PoiFilter { } public ResultMatcher getResultMatcher(final ResultMatcher matcher){ - if(nameFilter != null) { + final String filter = nameFilter; + if(filter != null) { final boolean en = application.getSettings().USE_ENGLISH_NAMES.get(); return new ResultMatcher() { @Override public boolean publish(Amenity object) { - if(!OsmAndFormatter.getPoiStringWithoutType(object, en).toLowerCase().contains(nameFilter) || + if(!OsmAndFormatter.getPoiStringWithoutType(object, en).toLowerCase().contains(filter) || (matcher != null && !matcher.publish(object))) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/RegionAddressRepositoryBinary.java b/OsmAnd/src/net/osmand/plus/RegionAddressRepositoryBinary.java index a1826d6610..0122ae44d8 100644 --- a/OsmAnd/src/net/osmand/plus/RegionAddressRepositoryBinary.java +++ b/OsmAnd/src/net/osmand/plus/RegionAddressRepositoryBinary.java @@ -244,7 +244,7 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository { addCityToPreloadedList(object); canceled = true; } - } else if (object.getId().longValue() == id) { + } else if (object.getId() != null && object.getId().longValue() == id) { addCityToPreloadedList((City) object); canceled = true; } diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java index 66ba678b51..d870d004ce 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java @@ -259,8 +259,6 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { AccessibleToast.makeText(LocalIndexesActivity.this, R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show(); } else { if(f.renameTo(dest)){ - asyncLoader = new LoadLocalIndexTask(); - asyncLoader.execute(LocalIndexesActivity.this); reloadIndexes(); } else { AccessibleToast.makeText(LocalIndexesActivity.this, R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show(); @@ -788,7 +786,9 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } AccessibleToast.makeText(LocalIndexesActivity.this, b.toString(), Toast.LENGTH_LONG).show(); } - asyncLoader.execute(LocalIndexesActivity.this); + if(asyncLoader.getStatus() == Status.PENDING) { + asyncLoader.execute(LocalIndexesActivity.this); + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 01bbc7e175..8bb9428f91 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -168,7 +168,10 @@ public class MapActivityActions implements DialogProvider { @Override public void onClick(DialogInterface dialog, int which) { // Don't use showDialog because it is impossible to refresh favorite items list - createReplaceFavouriteDialog(args).show(); + Dialog dlg = createReplaceFavouriteDialog(args); + if(dlg != null) { + dlg.show(); + } // mapActivity.showDialog(DIALOG_REPLACE_FAVORITE); } diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 5f1dd7ebaf..7857c06003 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -104,17 +104,21 @@ public class SavingTrackHelper extends SQLiteOpenHelper { public boolean hasDataToSave() { SQLiteDatabase db = getWritableDatabase(); if (db != null) { - Cursor q = db.query(false, TRACK_NAME, new String[0], null, null, null, null, null, null); - boolean has = q.moveToFirst(); - q.close(); - if (has) { - return true; - } - q = db.query(false, POINT_NAME, new String[0], null, null, null, null, null, null); - has = q.moveToFirst(); - q.close(); - if (has) { - return true; + try { + Cursor q = db.query(false, TRACK_NAME, new String[0], null, null, null, null, null, null); + boolean has = q.moveToFirst(); + q.close(); + if (has) { + return true; + } + q = db.query(false, POINT_NAME, new String[0], null, null, null, null, null, null); + has = q.moveToFirst(); + q.close(); + if (has) { + return true; + } + } finally { + db.close(); } } @@ -158,12 +162,16 @@ public class SavingTrackHelper extends SQLiteOpenHelper { SQLiteDatabase db = getWritableDatabase(); if (db != null && warnings.isEmpty()) { - // 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$ - db.execSQL("DELETE FROM " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - // delete all -// db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$ -// db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$ + 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$ + db.execSQL("DELETE FROM " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + // delete all + // db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$ + // db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$ + } finally { + db.close(); + } } distance = 0; return warnings; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index d9e4217df2..08103212f9 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -61,12 +61,18 @@ public class OsmEditingPlugin extends OsmandPlugin { public void registerLayers(MapActivity activity){ osmBugsLayer = new OsmBugsLayer(activity); } + + public OsmBugsLayer getBugsLayer(MapActivity activity) { + if(osmBugsLayer == null) { + registerLayers(activity); + } + return osmBugsLayer; + } @Override public void mapActivityCreate(MapActivity activity) { - poiActions = new EditingPOIActivity(activity); - activity.addDialogProvider(poiActions); - activity.addDialogProvider(osmBugsLayer); + activity.addDialogProvider(getPoiActions(activity)); + activity.addDialogProvider(getBugsLayer(activity)); } @Override @@ -100,24 +106,30 @@ public class OsmEditingPlugin extends OsmandPlugin { cat.addPreference(pref); } - public EditingPOIActivity getPoiActions() { + public EditingPOIActivity getPoiActions(MapActivity activity) { + if(poiActions == null) { + poiActions = new EditingPOIActivity(activity); + } return poiActions; } @Override - public void registerMapContextMenuActions(MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, + public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, final Object selectedObj) { OnContextMenuClick listener = new OnContextMenuClick() { @Override public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) { if (resId == R.string.context_menu_item_create_poi) { - poiActions.showCreateDialog(latitude, longitude); + getPoiActions(mapActivity).showCreateDialog(latitude, longitude); } else if (resId == R.string.context_menu_item_open_bug) { + if(osmBugsLayer == null) { + registerLayers(mapActivity); + } osmBugsLayer.openBug(latitude, longitude); } else if (resId == R.string.poi_context_menu_delete) { - getPoiActions().showDeleteDialog((Amenity) selectedObj); + getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj); } else if (resId == R.string.poi_context_menu_modify) { - getPoiActions().showEditDialog((Amenity) selectedObj); + getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj); } } }; diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index b8821761c9..2145dd0345 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -189,7 +189,7 @@ public class VoiceRouter { NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true); // after last turn say: - if (nextInfo == null || nextInfo.directionInfo.distance == 0) { + if (nextInfo == null || nextInfo.directionInfo == null || nextInfo.directionInfo.distance == 0) { // if(currentStatus <= STATUS_UNKNOWN && currentDirection > 0){ This caused this prompt to be suppressed when coming back from a // UTwp situation if (currentStatus <= STATUS_UNKNOWN) {