fix: can't cancel srtm file downloading

This commit is contained in:
nazar-kutz 2021-04-16 22:32:14 +03:00
parent 2f1e43147d
commit adbc331fce
2 changed files with 7 additions and 9 deletions

View file

@ -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);

View file

@ -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,15 +111,12 @@ public class SrtmDownloadItem extends DownloadItem {
@Override
public List<File> getDownloadedFiles(@NonNull OsmandApplication app) {
// may be check both indexes files
List<File> result;
List<File> result = new ArrayList<>();
for (IndexItem index : indexes) {
result = index.getDownloadedFiles(app);
if (!Algorithms.isEmpty(result)) {
result.addAll(index.getDownloadedFiles(app));
}
return result;
}
}
return Collections.emptyList();
}
public String getDate(@NonNull DateFormat dateFormat, boolean remote) {
// may be check only downloaded items if any downloaded