Skip to content

Commit dc16f31

Browse files
committed
android demo: update download link of maps
1 parent a6ac76a commit dc16f31

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

android/app/src/main/java/com/graphhopper/android/MainActivity.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class MainActivity extends Activity
6969
private volatile boolean prepareInProgress = false;
7070
private volatile boolean shortestPathRunning = false;
7171
private String currentArea = "berlin";
72-
private String fileListURL = "http://download2.graphhopper.com/public/maps/0.7/";
72+
private String fileListURL = "http://download2.graphhopper.com/public/maps/" + Constants.getMajorVersion() + "/";
7373
private String prefixURL = fileListURL;
7474
private String downloadURL;
7575
private File mapsFolder;
@@ -225,13 +225,13 @@ public boolean accept( File dir, String filename )
225225

226226
chooseArea(localButton, localSpinner, nameList,
227227
new MySpinnerListener()
228-
{
229-
@Override
230-
public void onSelect( String selectedArea, String selectedFile )
231-
{
232-
initFiles(selectedArea);
233-
}
234-
});
228+
{
229+
@Override
230+
public void onSelect( String selectedArea, String selectedFile )
231+
{
232+
initFiles(selectedArea);
233+
}
234+
});
235235
}
236236

237237
private void chooseAreaFromRemote()
@@ -366,13 +366,13 @@ protected Object saveDoInBackground( Void... _ignore )
366366
downloader.setTimeout(30000);
367367
downloader.downloadAndUnzip(downloadURL, localFolder,
368368
new ProgressListener()
369-
{
370-
@Override
371-
public void update( long val )
372-
{
373-
publishProgress((int) val);
374-
}
375-
});
369+
{
370+
@Override
371+
public void update( long val )
372+
{
373+
publishProgress((int) val);
374+
}
375+
});
376376
return null;
377377
}
378378

@@ -407,13 +407,13 @@ void loadMap( File areaFolder )
407407

408408
tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
409409
mapView.getModel().mapViewPosition, false, true, AndroidGraphicFactory.INSTANCE)
410-
{
411-
@Override
412-
public boolean onLongPress( LatLong tapLatLong, Point layerXY, Point tapXY )
413-
{
414-
return onMapTap(tapLatLong, layerXY, tapXY);
415-
}
416-
};
410+
{
411+
@Override
412+
public boolean onLongPress( LatLong tapLatLong, Point layerXY, Point tapXY )
413+
{
414+
return onMapTap(tapLatLong, layerXY, tapXY);
415+
}
416+
};
417417
tileRendererLayer.setTextScale(1.5f);
418418
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
419419
mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(mapDataStore.boundingBox().getCenterPoint(), (byte) 15));

core/src/main/java/com/graphhopper/util/Constants.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,16 @@ public static String getVersions()
118118
}
119119
BUILD_DATE = buildDate;
120120
}
121+
122+
public static String getMajorVersion()
123+
{
124+
int firstIdx = VERSION.indexOf(".");
125+
if (firstIdx < 0)
126+
throw new IllegalStateException("Cannot extract major version from version " + VERSION);
127+
128+
int sndIdx = VERSION.indexOf(".", firstIdx + 1);
129+
if (sndIdx < 0)
130+
return VERSION;
131+
return VERSION.substring(0, sndIdx);
132+
}
121133
}

0 commit comments

Comments
 (0)