use of net.osmand.plus.download.CustomRegion in project Osmand by osmandapp.
the class CustomOsmandPlugin method writeAdditionalDataToJson.
public void writeAdditionalDataToJson(JSONObject json) throws JSONException {
JsonUtils.writeLocalizedMapToJson("icon", json, iconNames);
JsonUtils.writeLocalizedMapToJson("image", json, imageNames);
JsonUtils.writeLocalizedMapToJson("name", json, names);
JsonUtils.writeLocalizedMapToJson("description", json, descriptions);
JSONArray regionsJson = new JSONArray();
for (WorldRegion region : getFlatCustomRegions()) {
if (region instanceof CustomRegion) {
regionsJson.put(((CustomRegion) region).toJson());
}
}
json.put("regionsJson", regionsJson);
}
use of net.osmand.plus.download.CustomRegion 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.plus.download.CustomRegion in project Osmand by osmandapp.
the class DownloadGroupViewHolder method getIconForGroup.
private Drawable getIconForGroup(DownloadResourceGroup group) {
Drawable iconStart;
OsmandApplication app = ctx.getMyApplication();
UiUtilities cache = app.getUIUtilities();
if (group.getType() == DownloadResourceGroupType.VOICE_REC || group.getType() == DownloadResourceGroupType.VOICE_TTS) {
iconStart = cache.getThemedIcon(R.drawable.ic_action_volume_up);
} else if (group.getType() == DownloadResourceGroupType.FONTS) {
iconStart = cache.getThemedIcon(R.drawable.ic_action_map_language);
} else {
if (group.getRegion() instanceof CustomRegion) {
String iconName = ((CustomRegion) group.getRegion()).getIconName(ctx);
int iconId = AndroidUtils.getDrawableId(app, iconName);
if (iconId != 0) {
iconStart = getIconForDownloadedItems(group, iconId);
return iconStart != null ? iconStart : cache.getThemedIcon(iconId);
}
}
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
iconStart = cache.getThemedIcon(R.drawable.ic_world_globe_dark);
} else {
iconStart = getIconForDownloadedItems(group, R.drawable.ic_map);
if (iconStart == null) {
iconStart = cache.getThemedIcon(R.drawable.ic_map);
}
}
}
return iconStart;
}
use of net.osmand.plus.download.CustomRegion 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.plus.download.CustomRegion in project Osmand by osmandapp.
the class CustomOsmandPlugin method collectRegionsFromJson.
public static List<CustomRegion> collectRegionsFromJson(@NonNull Context ctx, JSONArray jsonArray) throws JSONException {
List<CustomRegion> customRegions = new ArrayList<>();
Map<String, CustomRegion> flatRegions = new LinkedHashMap<>();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject regionJson = jsonArray.getJSONObject(i);
CustomRegion region = CustomRegion.fromJson(ctx, regionJson);
flatRegions.put(region.getPath(), region);
}
for (CustomRegion region : flatRegions.values()) {
if (!Algorithms.isEmpty(region.getParentPath())) {
CustomRegion parentReg = flatRegions.get(region.getParentPath());
if (parentReg != null) {
parentReg.addSubregion(region);
}
} else {
customRegions.add(region);
}
}
return customRegions;
}
Aggregations