use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method reloadData.
private void reloadData() {
DownloadResources indexes = activity.getDownloadThread().getIndexes();
group = indexes.getGroupById(groupId);
if (!openAsDialog()) {
updateSearchView();
}
updateSubscribeEmailView();
updateDescriptionView();
if (group != null) {
listAdapter.update(group);
toolbar.setTitle(group.getName(activity));
WorldRegion region = group.getRegion();
if (region instanceof CustomRegion) {
int headerColor = ((CustomRegion) region).getHeaderColor();
if (headerColor != CustomRegion.INVALID_ID) {
toolbar.setBackgroundColor(headerColor);
}
}
}
expandAllGroups();
}
use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class ItemViewHolder method download.
protected void download(DownloadItem item, DownloadResourceGroup parentOptional) {
boolean handled = false;
if (parentOptional != null && item instanceof IndexItem) {
IndexItem indexItem = (IndexItem) item;
WorldRegion region = DownloadResourceGroup.getRegion(parentOptional);
context.setDownloadItem(region, indexItem.getTargetFile(context.getMyApplication()).getAbsolutePath());
}
if (item.getType() == DownloadActivityType.ROADS_FILE && parentOptional != null) {
for (IndexItem ii : parentOptional.getIndividualResources()) {
if (ii.getType() == DownloadActivityType.NORMAL_FILE) {
if (ii.isDownloaded()) {
handled = true;
confirmDownload(item);
}
break;
}
}
}
if (!handled) {
startDownload(item);
}
}
use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class DownloadItemFragment method reloadData.
private void reloadData() {
DownloadActivity activity = getDownloadActivity();
OsmandApplication app = activity.getMyApplication();
DownloadResources indexes = activity.getDownloadThread().getIndexes();
group = indexes.getGroupById(regionId);
CustomIndexItem indexItem = (CustomIndexItem) group.getItemByIndex(itemIndex);
if (indexItem != null) {
toolbar.setTitle(indexItem.getVisibleName(app, app.getRegions()));
DownloadDescriptionInfo descriptionInfo = indexItem.getDescriptionInfo();
if (descriptionInfo != null) {
updateDescription(app, descriptionInfo, description);
updateImagesPager(app, descriptionInfo, imagesPager);
updateActionButtons(activity, descriptionInfo, indexItem, buttonsContainer, R.layout.bottom_buttons, nightMode);
}
}
WorldRegion region = group.getParentGroup().getRegion();
if (region instanceof CustomRegion) {
int headerColor = ((CustomRegion) region).getHeaderColor();
if (headerColor != CustomRegion.INVALID_ID) {
toolbar.setBackgroundColor(headerColor);
}
}
}
use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class DownloadResources method buildRegionsGroups.
private void buildRegionsGroups(WorldRegion region, DownloadResourceGroup group) {
LinkedList<WorldRegion> queue = new LinkedList<WorldRegion>();
LinkedList<DownloadResourceGroup> parent = new LinkedList<DownloadResourceGroup>();
queue.add(region);
parent.add(group);
while (!queue.isEmpty()) {
WorldRegion reg = queue.pollFirst();
DownloadResourceGroup parentGroup = parent.pollFirst();
List<WorldRegion> subregions = reg.getSubregions();
DownloadResourceGroup mainGrp = new DownloadResourceGroup(parentGroup, DownloadResourceGroupType.REGION, reg.getRegionId());
mainGrp.region = reg;
parentGroup.addGroup(mainGrp);
if (reg instanceof CustomRegion) {
CustomRegion customRegion = (CustomRegion) reg;
List<IndexItem> indexItems = customRegion.loadIndexItems();
if (!Algorithms.isEmpty(indexItems)) {
DownloadResourceGroup flatFiles = new DownloadResourceGroup(mainGrp, REGION_MAPS);
for (IndexItem ii : indexItems) {
flatFiles.addItem(ii);
}
mainGrp.addGroup(flatFiles);
}
}
DownloadResourceGroup subRegions = new DownloadResourceGroup(mainGrp, DownloadResourceGroupType.EXTRA_MAPS);
mainGrp.addGroup(subRegions);
// add to processing queue
for (WorldRegion rg : subregions) {
queue.add(rg);
parent.add(subRegions);
}
}
}
use of net.osmand.map.WorldRegion in project Osmand by osmandapp.
the class DownloadResources method findIndexItemsAt.
public static List<IndexItem> findIndexItemsAt(OsmandApplication app, List<String> names, DownloadActivityType type, boolean includeDownloaded, int limit) {
List<IndexItem> res = new ArrayList<>();
OsmandRegions regions = app.getRegions();
DownloadIndexesThread downloadThread = app.getDownloadThread();
for (String name : names) {
WorldRegion downloadRegion = regions.getRegionDataByDownloadName(name);
if (downloadRegion != null && (includeDownloaded || !isIndexItemDownloaded(downloadThread, type, downloadRegion, res))) {
addIndexItem(downloadThread, type, downloadRegion, res);
}
if (limit != -1 && res.size() == limit) {
break;
}
}
return res;
}
Aggregations