Fix exceptions
This commit is contained in:
parent
f74cd38672
commit
4ab62b2cc8
9 changed files with 64 additions and 34 deletions
|
@ -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 {
|
||||
|
|
|
@ -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<IMapDownloaderCallback> ls = new ArrayList<IMapDownloaderCallback>(resourceManger.getMapTileDownloader().getDownloaderCallbacks());
|
||||
for (IMapDownloaderCallback c : ls) {
|
||||
c.tileDownloaded(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,12 +145,13 @@ public class PoiFilter {
|
|||
}
|
||||
|
||||
public ResultMatcher<Amenity> getResultMatcher(final ResultMatcher<Amenity> matcher){
|
||||
if(nameFilter != null) {
|
||||
final String filter = nameFilter;
|
||||
if(filter != null) {
|
||||
final boolean en = application.getSettings().USE_ENGLISH_NAMES.get();
|
||||
return new ResultMatcher<Amenity>() {
|
||||
@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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,8 +786,10 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
|||
}
|
||||
AccessibleToast.makeText(LocalIndexesActivity.this, b.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
if(asyncLoader.getStatus() == Status.PENDING) {
|
||||
asyncLoader.execute(LocalIndexesActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
public boolean hasDataToSave() {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
try {
|
||||
Cursor q = db.query(false, TRACK_NAME, new String[0], null, null, null, null, null, null);
|
||||
boolean has = q.moveToFirst();
|
||||
q.close();
|
||||
|
@ -116,6 +117,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (has) {
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -158,12 +162,16 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null && warnings.isEmpty()) {
|
||||
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;
|
||||
|
|
|
@ -62,11 +62,17 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue