From adbc331fce11f662989fae618f26c164ad6810e1 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 16 Apr 2021 22:32:14 +0300 Subject: [PATCH] fix: can't cancel srtm file downloading --- .../osmand/plus/download/DownloadIndexesThread.java | 3 +++ .../net/osmand/plus/download/SrtmDownloadItem.java | 13 ++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index ab45abe6d0..568dcc9ed6 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -243,6 +243,9 @@ public class DownloadIndexesThread { if (item instanceof MultipleDownloadItem) { MultipleDownloadItem multipleDownloadItem = (MultipleDownloadItem) item; cancelDownload(multipleDownloadItem.getAllIndexes()); + } else if (item instanceof SrtmDownloadItem) { + IndexItem indexItem = ((SrtmDownloadItem) item).getIndexItem(); + cancelDownload(indexItem); } else if (item instanceof IndexItem) { IndexItem indexItem = (IndexItem) item; cancelDownload(indexItem); diff --git a/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java b/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java index aada6acd55..a9a184d57c 100644 --- a/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java +++ b/OsmAnd/src/net/osmand/plus/download/SrtmDownloadItem.java @@ -10,11 +10,10 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.helpers.enums.MetricsConstants; -import net.osmand.util.Algorithms; import java.io.File; import java.text.DateFormat; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT; @@ -105,7 +104,6 @@ public class SrtmDownloadItem extends DownloadItem { @Override public String getFileName() { - // may be check only downloaded items if any downloaded return getIndexItem().getFileName(); } @@ -113,14 +111,11 @@ public class SrtmDownloadItem extends DownloadItem { @Override public List getDownloadedFiles(@NonNull OsmandApplication app) { // may be check both indexes files - List result; + List result = new ArrayList<>(); for (IndexItem index : indexes) { - result = index.getDownloadedFiles(app); - if (!Algorithms.isEmpty(result)) { - return result; - } + result.addAll(index.getDownloadedFiles(app)); } - return Collections.emptyList(); + return result; } public String getDate(@NonNull DateFormat dateFormat, boolean remote) {