Merge pull request #9382 from osmandapp/wrong_slope_suggest

not suggest to download terrain if at least one map downloaded on the…
This commit is contained in:
vshcherb 2020-07-07 01:27:31 +02:00 committed by GitHub
commit 44c8c904cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -513,16 +513,20 @@ public class DownloadResources extends DownloadResourceGroup {
}
public static List<IndexItem> findIndexItemsAt(OsmandApplication app, LatLon latLon, DownloadActivityType type, boolean includeDownloaded) throws IOException {
return findIndexItemsAt(app, latLon, type, includeDownloaded, -1);
return findIndexItemsAt(app, latLon, type, includeDownloaded, -1, false);
}
public static List<IndexItem> findIndexItemsAt(OsmandApplication app, LatLon latLon, DownloadActivityType type, boolean includeDownloaded, int limit) throws IOException {
public static List<IndexItem> findIndexItemsAt(OsmandApplication app, LatLon latLon, DownloadActivityType type, boolean includeDownloaded, int limit, boolean skipIfOneDownloaded) throws IOException {
List<IndexItem> res = new ArrayList<>();
OsmandRegions regions = app.getRegions();
DownloadIndexesThread downloadThread = app.getDownloadThread();
List<WorldRegion> downloadRegions = regions.getWorldRegionsAt(latLon);
for (WorldRegion downloadRegion : downloadRegions) {
if (includeDownloaded || !isIndexItemDownloaded(downloadThread, type, downloadRegion, res)) {
boolean itemDownloaded = isIndexItemDownloaded(downloadThread, type, downloadRegion, res);
if (skipIfOneDownloaded && itemDownloaded) {
return new ArrayList<>();
}
if (includeDownloaded || !itemDownloaded) {
addIndexItem(downloadThread, type, downloadRegion, res);
}
if (limit != -1 && res.size() == limit) {

View file

@ -424,14 +424,14 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
TerrainMode mode = srtmPlugin.getTerrainMode();
IndexItem currentDownloadingItem = downloadThread.getCurrentDownloadingItem();
int currentDownloadingProgress = downloadThread.getCurrentDownloadingItemProgress();
List<IndexItem> hillshadeItems = DownloadResources.findIndexItemsAt(
app, ((MapActivity) mapActivity).getMapLocation(),
mode == HILLSHADE ? HILLSHADE_FILE : SLOPE_FILE);
if (hillshadeItems.size() > 0) {
List<IndexItem> terrainItems = DownloadResources.findIndexItemsAt(
app, mapActivity.getMapLocation(),
mode == HILLSHADE ? HILLSHADE_FILE : SLOPE_FILE, false, -1, true);
if (terrainItems.size() > 0) {
downloadContainer.setVisibility(View.VISIBLE);
downloadTopDivider.setVisibility(View.VISIBLE);
downloadBottomDivider.setVisibility(View.VISIBLE);
for (final IndexItem indexItem : hillshadeItems) {
for (final IndexItem indexItem : terrainItems) {
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder()
.setLayout(R.layout.list_item_icon_and_download)
.setTitle(indexItem.getVisibleName(app, app.getRegions(), false))