Fix some crashes

This commit is contained in:
Victor Shcherb 2015-11-25 11:10:13 +01:00
parent 4e2bdf8553
commit 79bb246c72
6 changed files with 16 additions and 12 deletions

View file

@ -545,7 +545,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
protected void select(int mode) {
LatLon searchPoint = settings.getLastSearchedPoint();
AddressInformation ai = getAddressInformation();
if (ai != null) {
if (ai != null && searchPoint != null) {
if (mode == ADD_TO_FAVORITE) {
Bundle b = new Bundle();
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);

View file

@ -179,10 +179,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public static void updateCurrentTrack(View v, final Activity ctx, final OsmandApplication app) {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
return;
}
if (v == null || ctx == null || app == null) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (v == null || ctx == null || app == null || plugin == null) {
return;
}
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() {
@Override
public void onClick(View v) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (isRecording) {
plugin.stopRecording();
} else {
} else if(plugin != null){
if (app.getLocationProvider().checkGPSEnabled(ctx)) {
plugin.startGPXMonitoring(ctx);
}

View file

@ -335,7 +335,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
public void onClick(DialogInterface dialog, int which) {
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false);
int clr = list.get(colorSpinner.getSelectedItemPosition());
if(clr != 0 ) {
if(clr != 0 && sf.getModifiableGpxFile() != null) {
sf.getModifiableGpxFile().setColor(clr);
sf.processPoints();
}

View file

@ -48,9 +48,11 @@ public class HillshadeLayer extends MapTileLayer {
private SQLiteDatabase sqliteDb;
@Override
protected Void doInBackground(Void... params) {
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
sqliteDb = SQLiteDatabase.openDatabase(new File(tilesDir, HILLSHADE_CACHE).getPath() ,
sqliteDb = SQLiteDatabase.openDatabase(new File(cacheDir, HILLSHADE_CACHE).getPath() ,
null, SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING
| SQLiteDatabase.CREATE_IF_NECESSARY );
if(sqliteDb.getVersion() == 0) {

View file

@ -117,12 +117,14 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
@Override
public void stateChanged(ApplicationMode change) {
if(prologSystem != null) {
prologSystem.getTheoryManager().retract(new Struct("appMode", new Var()));
prologSystem.getTheoryManager()
.assertA(
new Struct("appMode", new Struct(ctx.getSettings().APPLICATION_MODE.get().getStringKey()
.toLowerCase())), true, "", true);
}
}
private void init(String voiceProvider, OsmandSettings settings, String configFile) throws CommandPlayerException {
prologSystem.clearTheory();
@ -256,6 +258,9 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
@Override
public void clear() {
if(ctx != null && ctx.getSettings() != null) {
ctx.getSettings().APPLICATION_MODE.removeListener(this);
}
ctx = null;
prologSystem = null;
}