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