Fix some crashes
This commit is contained in:
parent
4e2bdf8553
commit
79bb246c72
6 changed files with 16 additions and 12 deletions
|
@ -545,7 +545,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
|
||||||
protected void select(int mode) {
|
protected void select(int mode) {
|
||||||
LatLon searchPoint = settings.getLastSearchedPoint();
|
LatLon searchPoint = settings.getLastSearchedPoint();
|
||||||
AddressInformation ai = getAddressInformation();
|
AddressInformation ai = getAddressInformation();
|
||||||
if (ai != null) {
|
if (ai != null && searchPoint != null) {
|
||||||
if (mode == ADD_TO_FAVORITE) {
|
if (mode == ADD_TO_FAVORITE) {
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);
|
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);
|
||||||
|
|
|
@ -179,10 +179,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCurrentTrack(View v, final Activity ctx, final OsmandApplication app) {
|
public static void updateCurrentTrack(View v, final Activity ctx, final OsmandApplication app) {
|
||||||
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
|
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
||||||
return;
|
if (v == null || ctx == null || app == null || plugin == null) {
|
||||||
}
|
|
||||||
if (v == null || ctx == null || app == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
|
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||||
|
@ -195,10 +193,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
stop.setOnClickListener(new View.OnClickListener() {
|
stop.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
plugin.stopRecording();
|
plugin.stopRecording();
|
||||||
} else {
|
} else if(plugin != null){
|
||||||
if (app.getLocationProvider().checkGPSEnabled(ctx)) {
|
if (app.getLocationProvider().checkGPSEnabled(ctx)) {
|
||||||
plugin.startGPXMonitoring(ctx);
|
plugin.startGPXMonitoring(ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false);
|
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false);
|
||||||
int clr = list.get(colorSpinner.getSelectedItemPosition());
|
int clr = list.get(colorSpinner.getSelectedItemPosition());
|
||||||
if(clr != 0 ) {
|
if(clr != 0 && sf.getModifiableGpxFile() != null) {
|
||||||
sf.getModifiableGpxFile().setColor(clr);
|
sf.getModifiableGpxFile().setColor(clr);
|
||||||
sf.processPoints();
|
sf.processPoints();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,11 @@ public class HillshadeLayer extends MapTileLayer {
|
||||||
private SQLiteDatabase sqliteDb;
|
private SQLiteDatabase sqliteDb;
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
|
|
||||||
File tilesDir = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
File tilesDir = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||||
|
File cacheDir = app.getCacheDir();
|
||||||
// fix http://stackoverflow.com/questions/26937152/workaround-for-nexus-9-sqlite-file-write-operations-on-external-dirs
|
// fix http://stackoverflow.com/questions/26937152/workaround-for-nexus-9-sqlite-file-write-operations-on-external-dirs
|
||||||
sqliteDb = SQLiteDatabase.openDatabase(new File(tilesDir, HILLSHADE_CACHE).getPath() ,
|
sqliteDb = SQLiteDatabase.openDatabase(new File(cacheDir, HILLSHADE_CACHE).getPath() ,
|
||||||
null, SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING
|
null, SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING
|
||||||
| SQLiteDatabase.CREATE_IF_NECESSARY );
|
| SQLiteDatabase.CREATE_IF_NECESSARY );
|
||||||
if(sqliteDb.getVersion() == 0) {
|
if(sqliteDb.getVersion() == 0) {
|
||||||
|
|
|
@ -117,12 +117,14 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ApplicationMode change) {
|
public void stateChanged(ApplicationMode change) {
|
||||||
|
if(prologSystem != null) {
|
||||||
prologSystem.getTheoryManager().retract(new Struct("appMode", new Var()));
|
prologSystem.getTheoryManager().retract(new Struct("appMode", new Var()));
|
||||||
prologSystem.getTheoryManager()
|
prologSystem.getTheoryManager()
|
||||||
.assertA(
|
.assertA(
|
||||||
new Struct("appMode", new Struct(ctx.getSettings().APPLICATION_MODE.get().getStringKey()
|
new Struct("appMode", new Struct(ctx.getSettings().APPLICATION_MODE.get().getStringKey()
|
||||||
.toLowerCase())), true, "", true);
|
.toLowerCase())), true, "", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void init(String voiceProvider, OsmandSettings settings, String configFile) throws CommandPlayerException {
|
private void init(String voiceProvider, OsmandSettings settings, String configFile) throws CommandPlayerException {
|
||||||
prologSystem.clearTheory();
|
prologSystem.clearTheory();
|
||||||
|
@ -256,6 +258,9 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
if(ctx != null && ctx.getSettings() != null) {
|
||||||
|
ctx.getSettings().APPLICATION_MODE.removeListener(this);
|
||||||
|
}
|
||||||
ctx = null;
|
ctx = null;
|
||||||
prologSystem = null;
|
prologSystem = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue