diff --git a/DataExtractionOSM/src/com/osmand/data/index/DownloaderIndexFromGoogleCode.java b/DataExtractionOSM/src/com/osmand/data/index/DownloaderIndexFromGoogleCode.java
index 5d51daf9b0..19d13641dd 100644
--- a/DataExtractionOSM/src/com/osmand/data/index/DownloaderIndexFromGoogleCode.java
+++ b/DataExtractionOSM/src/com/osmand/data/index/DownloaderIndexFromGoogleCode.java
@@ -2,7 +2,6 @@ package com.osmand.data.index;
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
@@ -107,9 +106,9 @@ public class DownloaderIndexFromGoogleCode {
return files;
}
- public static InputStream getInputStreamToLoadIndex(String indexName) throws IOException{
+ public static URL getInputStreamToLoadIndex(String indexName) throws IOException{
URL url = new URL("http://osmand.googlecode.com/files/"+indexName); //$NON-NLS-1$
- return url.openStream();
+ return url;
}
}
diff --git a/OsmAnd/res/values-ru-rRU/strings.xml b/OsmAnd/res/values-ru-rRU/strings.xml
index 21ad4cd774..0ada4af94d 100644
--- a/OsmAnd/res/values-ru-rRU/strings.xml
+++ b/OsmAnd/res/values-ru-rRU/strings.xml
@@ -9,7 +9,7 @@
Загрузка...
Загружается список доступных индексов
Не найдены доступные индекс файлы с osmand.googlecode.com
- Выберите файл индекса для загрузки из интернета. Если вы не можете найти регион, вы можете создать его самостоятельно.
+ Если вы не можете найти регион, вы можете создать его самостоятельно.
Читайте на osmand.googlecode.com .
Показать на карте
Отредактирована избранная точка
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index f52d425603..42e263ca4a 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -8,8 +8,9 @@
Downloading file
Downloading...
Downloading list of available indexes
- The index files are not loaded from osmand.googlecode.com. If you can't find your region, you can make it yourself. See osmand.googlecode.com.
- Select index file to download from internet
+ The index files are not loaded from osmand.googlecode.com.
+ If you can't find your region, you can make it by yourself.
+See osmand.googlecode.com.
Show on map
Favorite point was edited
None of favorite points exist
diff --git a/OsmAnd/src/com/osmand/ProgressDialogImplementation.java b/OsmAnd/src/com/osmand/ProgressDialogImplementation.java
index 7091229f66..971b0f21d7 100644
--- a/OsmAnd/src/com/osmand/ProgressDialogImplementation.java
+++ b/OsmAnd/src/com/osmand/ProgressDialogImplementation.java
@@ -9,7 +9,7 @@ import android.os.Message;
public class ProgressDialogImplementation implements IProgress {
- private static final float deltaToChange = 0.04f;
+ private static final float deltaToChange = 0.023f;
private String taskName;
private int progress;
private int work;
@@ -60,8 +60,9 @@ public class ProgressDialogImplementation implements IProgress {
@Override
public void progress(int deltaWork) {
this.deltaWork += deltaWork;
- if(change(progress + deltaWork)){
- this.progress += deltaWork;
+ if(change(progress + this.deltaWork)){
+ this.progress += this.deltaWork;
+ this.deltaWork = 0;
updateMessage();
}
}
diff --git a/OsmAnd/src/com/osmand/ResourceManager.java b/OsmAnd/src/com/osmand/ResourceManager.java
index b39ba4cac6..7ee8ba0829 100644
--- a/OsmAnd/src/com/osmand/ResourceManager.java
+++ b/OsmAnd/src/com/osmand/ResourceManager.java
@@ -64,7 +64,7 @@ public class ResourceManager {
// Indexes
private Map addressMap = new TreeMap(Collator.getInstance());
- protected List amenityRepositories = new ArrayList();
+ protected Map amenityRepositories = new LinkedHashMap();
public AsyncLoadingThread asyncLoadingTiles = new AsyncLoadingThread();
@@ -253,7 +253,7 @@ public class ResourceManager {
progress.startTask(Messages.getMessage("indexing_poi") + f.getName(), -1); //$NON-NLS-1$
boolean initialized = repository.initialize(progress, f);
if (initialized) {
- amenityRepositories.add(repository);
+ amenityRepositories.put(repository.getName(), repository);
}else {
warnings.add(MessageFormat.format(Messages.getMessage("version_index_is_not_supported"), f.getName())); //$NON-NLS-1$
}
@@ -289,7 +289,7 @@ public class ResourceManager {
// //////////////////////////////////////////// Working with amenities ////////////////////////////////////////////////
public List searchRepositories(double latitude, double longitude) {
List repos = new ArrayList();
- for (AmenityIndexRepository index : amenityRepositories) {
+ for (AmenityIndexRepository index : amenityRepositories.values()) {
if (index.checkContains(latitude,longitude)) {
repos.add(index);
}
@@ -304,7 +304,7 @@ public class ResourceManager {
double leftLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX - 0.5);
double rightLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX + 0.5);
List amenities = new ArrayList();
- for (AmenityIndexRepository index : amenityRepositories) {
+ for (AmenityIndexRepository index : amenityRepositories.values()) {
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
if (!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filter.getFilterId(), amenities)) {
index.searchAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, limit, filter, amenities);
@@ -317,7 +317,7 @@ public class ResourceManager {
public void searchAmenitiesAsync(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, PoiFilter filter, List toFill){
String filterId = filter == null ? null : filter.getFilterId();
- for(AmenityIndexRepository index : amenityRepositories){
+ for(AmenityIndexRepository index : amenityRepositories.values()){
if(index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)){
if(!index.checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filterId, toFill, true)){
asyncLoadingTiles.requestToLoadAmenities(
@@ -340,7 +340,7 @@ public class ResourceManager {
////////////////////////////////////////////// Closing methods ////////////////////////////////////////////////
public void closeAmenities(){
- for(AmenityIndexRepository r : amenityRepositories){
+ for(AmenityIndexRepository r : amenityRepositories.values()){
r.close();
}
amenityRepositories.clear();
@@ -363,7 +363,7 @@ public class ResourceManager {
public void onLowMemory() {
log.info("On low memory : cleaning tiles - size = " + cacheOfImages.size()); //$NON-NLS-1$
clearTiles();
- for(AmenityIndexRepository r : amenityRepositories){
+ for(AmenityIndexRepository r : amenityRepositories.values()){
r.clearCache();
}
for(RegionAddressRepository r : addressMap.values()){
diff --git a/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java b/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java
index 002efadd06..ada8febf0c 100644
--- a/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java
+++ b/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java
@@ -4,6 +4,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
@@ -112,7 +114,7 @@ public class DownloadIndexActivity extends ListActivity {
parent = new File(Environment.getExternalStorageDirectory(), ResourceManager.ADDRESS_PATH);
regionName += IndexConstants.ADDRESS_INDEX_EXT;
} else if(key.endsWith(IndexConstants.POI_INDEX_EXT)){
- parent = new File(Environment.getExternalStorageDirectory(), ResourceManager.ADDRESS_PATH);
+ parent = new File(Environment.getExternalStorageDirectory(), ResourceManager.POI_PATH);
regionName += IndexConstants.POI_INDEX_EXT;
}
if(parent != null){
@@ -133,8 +135,10 @@ public class DownloadIndexActivity extends ListActivity {
try {
FileOutputStream out = new FileOutputStream(file);
try {
- InputStream is = DownloaderIndexFromGoogleCode.getInputStreamToLoadIndex(key);
- impl.startTask(getString(R.string.downloading_file), is.available());
+ URL url = DownloaderIndexFromGoogleCode.getInputStreamToLoadIndex(key);
+ URLConnection conn = url.openConnection();
+ InputStream is = conn.getInputStream();
+ impl.startTask(getString(R.string.downloading_file), conn.getContentLength());
byte[] buffer = new byte[BUFFER_SIZE];
int read = 0;
while((read = is.read(buffer)) != -1){
@@ -158,6 +162,8 @@ public class DownloadIndexActivity extends ListActivity {
} catch (IOException e) {
log.error("Exception ocurred", e); //$NON-NLS-1$
showWarning(getString(R.string.error_io_error));
+ // Possibly file is corrupted
+ file.delete();
} finally {
dlg.dismiss();
}
@@ -170,7 +176,7 @@ public class DownloadIndexActivity extends ListActivity {
runOnUiThread(new Runnable(){
@Override
public void run() {
- Toast.makeText(DownloadIndexActivity.this, messages, Toast.LENGTH_LONG);
+ Toast.makeText(DownloadIndexActivity.this, messages, Toast.LENGTH_LONG).show();
}
});