Fix some crashes

This commit is contained in:
Victor Shcherb 2015-11-25 11:10:13 +01:00
parent 1955fe4f0f
commit 52746d1765
6 changed files with 16 additions and 12 deletions

View file

@ -2027,7 +2027,7 @@
<string name="application_dir_description">Vælg hvor kortfilerne skal gemmes.</string>
<string name="show_on_start_description">\'Fra\' starter direkte på kortet</string>
<string name="map_downloaded">Kort hentet</string>
<string name="map_downloaded_descr">Kort over %1$ s er hentet. Gå tilbage til kortet for at begynde at bruge det.</string>
<string name="map_downloaded_descr">Kort over %1$s er hentet. Gå tilbage til kortet for at begynde at bruge det.</string>
<string name="go_to_map">Gå til kortet</string>
<string name="shared_string_qr_code">QR kode</string>
<string name="enter_country_name">Indtast landenavn</string>

View file

@ -549,7 +549,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,11 +117,13 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
@Override
public void stateChanged(ApplicationMode change) {
prologSystem.getTheoryManager().retract(new Struct("appMode", new Var()));
prologSystem.getTheoryManager()
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 {
@ -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;
}