use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class ItemViewHolder method download.
protected void download(IndexItem indexItem, DownloadResourceGroup parentOptional) {
boolean handled = false;
if (parentOptional != null) {
WorldRegion region = DownloadResourceGroup.getRegion(parentOptional);
context.setDownloadItem(region, indexItem.getTargetFile(context.getMyApplication()).getAbsolutePath());
}
if (indexItem.getType() == DownloadActivityType.ROADS_FILE && parentOptional != null) {
for (IndexItem ii : parentOptional.getIndividualResources()) {
if (ii.getType() == DownloadActivityType.NORMAL_FILE) {
if (ii.isDownloaded()) {
handled = true;
confirmDownload(indexItem);
}
break;
}
}
}
if (!handled) {
context.startDownload(indexItem);
}
}
use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class DownloadedRegionsLayer method getFilter.
public String getFilter(StringBuilder btnName) {
StringBuilder filter = new StringBuilder();
int zoom = view.getZoom();
RotatedTileBox queriedBox = data.getQueriedBox();
final List<BinaryMapDataObject> currentObjects = data.results;
if (osmandRegions.isInitialized() && queriedBox != null) {
if (zoom >= ZOOM_TO_SHOW_MAP_NAMES && Math.abs(queriedBox.getZoom() - zoom) <= ZOOM_THRESHOLD && currentObjects != null) {
btnName.setLength(0);
btnName.append(view.getResources().getString(R.string.shared_string_download));
filter.setLength(0);
Set<String> set = new TreeSet<String>();
int cx = view.getCurrentRotatedTileBox().getCenter31X();
int cy = view.getCurrentRotatedTileBox().getCenter31Y();
if ((currentObjects.size() > 0)) {
for (int i = 0; i < currentObjects.size(); i++) {
final BinaryMapDataObject o = currentObjects.get(i);
if (!osmandRegions.contain(o, cx, cy)) {
continue;
}
String fullName = osmandRegions.getFullName(o);
WorldRegion rd = osmandRegions.getRegionData(fullName);
if (rd != null && rd.isRegionMapDownload() && rd.getRegionDownloadName() != null) {
String name = rd.getLocaleName();
if (checkIfObjectDownloaded(rd.getRegionDownloadName())) {
return null;
}
if (!set.add(name)) {
continue;
}
if (set.size() > 1) {
btnName.append(" ").append(view.getResources().getString(R.string.shared_string_or)).append(" ");
filter.append(", ");
} else {
btnName.append(" ");
}
filter.append(name);
btnName.append(name);
}
}
}
}
}
if (filter.length() == 0) {
return null;
}
return filter.toString();
}
Aggregations