Search in sources :

Example 21 with WorldRegion

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();
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources) WorldRegion(net.osmand.map.WorldRegion) SuppressLint(android.annotation.SuppressLint) CustomRegion(net.osmand.plus.download.CustomRegion)

Example 22 with WorldRegion

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);
    }
}
Also used : WorldRegion(net.osmand.map.WorldRegion) IndexItem(net.osmand.plus.download.IndexItem) CustomIndexItem(net.osmand.plus.download.CustomIndexItem)

Example 23 with WorldRegion

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);
        }
    }
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources) WorldRegion(net.osmand.map.WorldRegion) OsmandApplication(net.osmand.plus.OsmandApplication) CustomIndexItem(net.osmand.plus.download.CustomIndexItem) DownloadActivity(net.osmand.plus.download.DownloadActivity) CustomRegion(net.osmand.plus.download.CustomRegion)

Example 24 with WorldRegion

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);
        }
    }
}
Also used : WorldRegion(net.osmand.map.WorldRegion) LinkedList(java.util.LinkedList) AssetIndexItem(net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem)

Example 25 with WorldRegion

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;
}
Also used : OsmandRegions(net.osmand.map.OsmandRegions) WorldRegion(net.osmand.map.WorldRegion) ArrayList(java.util.ArrayList) AssetIndexItem(net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem)

Aggregations

WorldRegion (net.osmand.map.WorldRegion)77 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)27 ArrayList (java.util.ArrayList)22 OsmandRegions (net.osmand.map.OsmandRegions)21 LinkedList (java.util.LinkedList)16 LatLon (net.osmand.data.LatLon)16 LinkedHashMap (java.util.LinkedHashMap)15 IndexItem (net.osmand.plus.download.IndexItem)11 Paint (android.graphics.Paint)10 TextPaint (android.text.TextPaint)10 Location (net.osmand.Location)10 AssetIndexItem (net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem)10 CustomRegion (net.osmand.plus.download.CustomRegion)8 DownloadResources (net.osmand.plus.download.DownloadResources)8 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)7 HashMap (java.util.HashMap)7 NonNull (androidx.annotation.NonNull)6 IOException (java.io.IOException)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6