This commit is contained in:
Victor Shcherb 2020-08-05 12:41:30 +02:00
parent 7c45f6cc68
commit 1a269e802d

View file

@ -52,10 +52,7 @@ public class DownloadGroupViewHolder {
} }
} }
if (isParentWorld(group) || isParentWorld(group.getParentGroup())) { if (isParentWorld(group) || isParentWorld(group.getParentGroup())) {
iconStart = getIconForDownloadedItems(group, R.drawable.ic_world_globe_dark); iconStart = cache.getThemedIcon(R.drawable.ic_world_globe_dark);
if (iconStart == null) {
iconStart = cache.getThemedIcon(R.drawable.ic_world_globe_dark);
}
} else { } else {
iconStart = getIconForDownloadedItems(group, R.drawable.ic_map); iconStart = getIconForDownloadedItems(group, R.drawable.ic_map);
if (iconStart == null) { if (iconStart == null) {
@ -67,46 +64,33 @@ public class DownloadGroupViewHolder {
} }
private Drawable getIconForDownloadedItems(DownloadResourceGroup group, @DrawableRes int iconId) { private Drawable getIconForDownloadedItems(DownloadResourceGroup group, @DrawableRes int iconId) {
DownloadResourceGroup ggr = group.getSubGroupById(DownloadResourceGroupType.REGION_MAPS.getDefaultId()); int ic = getIconColorForOutdatedItems(group);
if (ggr != null && ggr.getIndividualResources() != null) { if (ic != 0) {
IndexItem item = null; return ctx.getMyApplication().getUIUtilities().getIcon(iconId, ic);
for (IndexItem ii : ggr.getIndividualResources()) {
if (ii.getType() == DownloadActivityType.NORMAL_FILE
|| ii.getType() == DownloadActivityType.ROADS_FILE) {
if (ii.isDownloaded() || ii.isOutdated()) {
item = ii;
break;
}
}
}
if (item != null) {
int color = item.isOutdated() ? R.color.color_distance : R.color.color_ok;
return ctx.getMyApplication().getUIUtilities().getIcon(iconId, color);
}
} }
return getIconForOutdatedItems(group, iconId); return null;
} }
private Drawable getIconForOutdatedItems(DownloadResourceGroup group, @DrawableRes int iconId) { private int getIconColorForOutdatedItems(DownloadResourceGroup group) {
if (group.getIndividualResources() != null) { if (group.getIndividualResources() != null) {
for (IndexItem ii : group.getIndividualResources()) { for (IndexItem ii : group.getIndividualResources()) {
if (ii.getType() == DownloadActivityType.NORMAL_FILE if (ii.getType() == DownloadActivityType.NORMAL_FILE
|| ii.getType() == DownloadActivityType.ROADS_FILE) { || ii.getType() == DownloadActivityType.ROADS_FILE) {
if (ii.isOutdated()) { if (ii.isOutdated()) {
return ctx.getMyApplication().getUIUtilities().getIcon(iconId, R.color.color_distance); return R.color.color_distance;
} }
} }
} }
} }
if (group.getGroups() != null) { if (group.getGroups() != null) {
for (DownloadResourceGroup g : group.getGroups()) { for (DownloadResourceGroup g : group.getGroups()) {
Drawable d = getIconForOutdatedItems(g, iconId); int d = getIconColorForOutdatedItems(g);
if (d != null) { if (d == R.color.color_distance) {
return d; return d;
} }
} }
} }
return null; return R.color.color_ok;
} }
public void bindItem(DownloadResourceGroup group) { public void bindItem(DownloadResourceGroup group) {