Fix issues
This commit is contained in:
parent
5e2d159a6a
commit
b9d3a71d02
4 changed files with 75 additions and 13 deletions
|
@ -29,9 +29,12 @@ public class DownloadResourceGroup {
|
||||||
|
|
||||||
public enum DownloadResourceGroupType {
|
public enum DownloadResourceGroupType {
|
||||||
// headers
|
// headers
|
||||||
WORLD_MAPS(R.string.world_maps), REGION_MAPS(R.string.region_maps), VOICE_GROUP(R.string.voices), SUBREGIONS(
|
WORLD_MAPS(R.string.world_maps), REGION_MAPS(R.string.region_maps),
|
||||||
R.string.regions), VOICE_HEADER_REC(R.string.index_name_voice), VOICE_HEADER_TTS(
|
SRTM_HEADER(R.string.download_srtm_maps), HILLSHADE_HEADER(R.string.download_hillshade_maps),
|
||||||
R.string.index_name_tts_voice),
|
// headers with voice items
|
||||||
|
VOICE_HEADER_REC(R.string.index_name_voice), VOICE_HEADER_TTS(R.string.index_name_tts_voice),
|
||||||
|
// headers with resources
|
||||||
|
VOICE_GROUP(R.string.voices), SUBREGIONS(R.string.regions),
|
||||||
// screen items
|
// screen items
|
||||||
VOICE_REC(R.string.index_name_voice), VOICE_TTS(R.string.index_name_tts_voice), WORLD(-1), REGION(-1);
|
VOICE_REC(R.string.index_name_voice), VOICE_TTS(R.string.index_name_tts_voice), WORLD(-1), REGION(-1);
|
||||||
|
|
||||||
|
@ -59,7 +62,7 @@ public class DownloadResourceGroup {
|
||||||
|
|
||||||
public boolean isHeader() {
|
public boolean isHeader() {
|
||||||
return this == VOICE_HEADER_REC || this == VOICE_HEADER_TTS || this == SUBREGIONS || this == WORLD_MAPS
|
return this == VOICE_HEADER_REC || this == VOICE_HEADER_TTS || this == SUBREGIONS || this == WORLD_MAPS
|
||||||
|| this == REGION_MAPS || this == VOICE_GROUP;
|
|| this == REGION_MAPS || this == VOICE_GROUP || this == HILLSHADE_HEADER || this == SRTM_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,6 +101,42 @@ public class DownloadResourceGroup {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createHillshadeSRTMGroups() {
|
||||||
|
if(getType().isScreen()) {
|
||||||
|
DownloadResourceGroup regionMaps = getSubGroupById(DownloadResourceGroupType.REGION_MAPS.getDefaultId());
|
||||||
|
if(regionMaps != null && regionMaps.size() == 1 && parentGroup != null && parentGroup.getParentGroup() != null) {
|
||||||
|
IndexItem item = regionMaps.individualResources.get(0);
|
||||||
|
DownloadResourceGroup screenParent = parentGroup.getParentGroup();
|
||||||
|
if(item.getType() == DownloadActivityType.HILLSHADE_FILE) {
|
||||||
|
DownloadResourceGroup hillshades =
|
||||||
|
screenParent.getSubGroupById(DownloadResourceGroupType.HILLSHADE_HEADER.getDefaultId());
|
||||||
|
if(hillshades == null) {
|
||||||
|
hillshades = new DownloadResourceGroup(screenParent, DownloadResourceGroupType.HILLSHADE_HEADER);
|
||||||
|
screenParent.addGroup(hillshades);
|
||||||
|
}
|
||||||
|
hillshades.addItem(item);
|
||||||
|
regionMaps.individualResources.remove(0);
|
||||||
|
} else if (item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||||
|
DownloadResourceGroup hillshades = screenParent
|
||||||
|
.getSubGroupById(DownloadResourceGroupType.SRTM_HEADER.getDefaultId());
|
||||||
|
if (hillshades == null) {
|
||||||
|
hillshades = new DownloadResourceGroup(screenParent, DownloadResourceGroupType.SRTM_HEADER);
|
||||||
|
screenParent.addGroup(hillshades);
|
||||||
|
}
|
||||||
|
hillshades.addItem(item);
|
||||||
|
regionMaps.individualResources.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
DownloadResourceGroup subregs = getSubGroupById(DownloadResourceGroupType.SUBREGIONS.getDefaultId());
|
||||||
|
if(subregs != null) {
|
||||||
|
for(DownloadResourceGroup g : subregs.getGroups()) {
|
||||||
|
g.createHillshadeSRTMGroups();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addGroup(DownloadResourceGroup g) {
|
public void addGroup(DownloadResourceGroup g) {
|
||||||
if(type.isScreen()) {
|
if(type.isScreen()) {
|
||||||
if(!g.type.isHeader()) {
|
if(!g.type.isHeader()) {
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
// 3. if hillshade/srtm is disabled, all maps from inner level could be combined into 1
|
// 3. if hillshade/srtm is disabled, all maps from inner level could be combined into 1
|
||||||
addGroup(worldMaps);
|
addGroup(worldMaps);
|
||||||
addGroup(voiceGroup);
|
addGroup(voiceGroup);
|
||||||
|
createHillshadeSRTMGroups();
|
||||||
trimEmptyGroups();
|
trimEmptyGroups();
|
||||||
initAlreadyLoadedFiles();
|
initAlreadyLoadedFiles();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -324,6 +324,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
|
|
||||||
private List<DownloadResourceGroup> data = new ArrayList<DownloadResourceGroup>();
|
private List<DownloadResourceGroup> data = new ArrayList<DownloadResourceGroup>();
|
||||||
private DownloadActivity ctx;
|
private DownloadActivity ctx;
|
||||||
|
private DownloadResourceGroup mainGroup;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,12 +334,8 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
data.clear();
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(DownloadResourceGroup mainGroup) {
|
public void update(DownloadResourceGroup mainGroup) {
|
||||||
|
this.mainGroup = mainGroup;
|
||||||
data = mainGroup.getGroups();
|
data = mainGroup.getGroups();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -362,7 +359,9 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
View convertView, ViewGroup parent) {
|
View convertView, ViewGroup parent) {
|
||||||
final Object child = getChild(groupPosition, childPosition);
|
final Object child = getChild(groupPosition, childPosition);
|
||||||
if (child instanceof IndexItem) {
|
if (child instanceof IndexItem) {
|
||||||
|
|
||||||
IndexItem item = (IndexItem) child;
|
IndexItem item = (IndexItem) child;
|
||||||
|
DownloadResourceGroup group = getGroupObj(groupPosition);
|
||||||
ItemViewHolder viewHolder;
|
ItemViewHolder viewHolder;
|
||||||
if (convertView != null && convertView.getTag() instanceof ItemViewHolder) {
|
if (convertView != null && convertView.getTag() instanceof ItemViewHolder) {
|
||||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||||
|
@ -371,9 +370,19 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
R.layout.two_line_with_images_list_item, parent, false);
|
R.layout.two_line_with_images_list_item, parent, false);
|
||||||
viewHolder = new ItemViewHolder(convertView, ctx);
|
viewHolder = new ItemViewHolder(convertView, ctx);
|
||||||
viewHolder.setShowRemoteDate(true);
|
viewHolder.setShowRemoteDate(true);
|
||||||
viewHolder.setShowTypeInDesc(true);
|
|
||||||
convertView.setTag(viewHolder);
|
convertView.setTag(viewHolder);
|
||||||
}
|
}
|
||||||
|
if(mainGroup.getType() == DownloadResourceGroupType.REGION &&
|
||||||
|
group != null && group.getType() == DownloadResourceGroupType.REGION_MAPS) {
|
||||||
|
viewHolder.setShowTypeInName(true);
|
||||||
|
viewHolder.setShowTypeInDesc(false);
|
||||||
|
} else if(group != null && (group.getType() == DownloadResourceGroupType.SRTM_HEADER ||
|
||||||
|
group.getType() == DownloadResourceGroupType.HILLSHADE_HEADER)) {
|
||||||
|
viewHolder.setShowTypeInName(false);
|
||||||
|
viewHolder.setShowTypeInDesc(false);
|
||||||
|
} else {
|
||||||
|
viewHolder.setShowTypeInDesc(true);
|
||||||
|
}
|
||||||
viewHolder.bindIndexItem(item);
|
viewHolder.bindIndexItem(item);
|
||||||
} else {
|
} else {
|
||||||
DownloadResourceGroup group = (DownloadResourceGroup) child;
|
DownloadResourceGroup group = (DownloadResourceGroup) child;
|
||||||
|
|
|
@ -46,9 +46,11 @@ public class ItemViewHolder {
|
||||||
private int textColorSecondary;
|
private int textColorSecondary;
|
||||||
|
|
||||||
boolean showTypeInDesc;
|
boolean showTypeInDesc;
|
||||||
|
boolean showTypeInName;
|
||||||
boolean showRemoteDate;
|
boolean showRemoteDate;
|
||||||
boolean silentCancelDownload;
|
boolean silentCancelDownload;
|
||||||
boolean showProgressInDesc;
|
boolean showProgressInDesc;
|
||||||
|
|
||||||
private DateFormat dateFormat;
|
private DateFormat dateFormat;
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,6 +99,10 @@ public class ItemViewHolder {
|
||||||
this.showTypeInDesc = showTypeInDesc;
|
this.showTypeInDesc = showTypeInDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowTypeInName(boolean showTypeInName) {
|
||||||
|
this.showTypeInName = showTypeInName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME don't initialize on every row
|
// FIXME don't initialize on every row
|
||||||
private void initAppStatusVariables() {
|
private void initAppStatusVariables() {
|
||||||
|
@ -116,7 +122,11 @@ public class ItemViewHolder {
|
||||||
}
|
}
|
||||||
boolean disabled = checkDisabledAndClickAction(indexItem);
|
boolean disabled = checkDisabledAndClickAction(indexItem);
|
||||||
/// name and left item
|
/// name and left item
|
||||||
nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions(), false));
|
if(showTypeInName) {
|
||||||
|
nameTextView.setText(indexItem.getType().getString(context));
|
||||||
|
} else {
|
||||||
|
nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions(), false));
|
||||||
|
}
|
||||||
if(!disabled) {
|
if(!disabled) {
|
||||||
nameTextView.setTextColor(textColorPrimary);
|
nameTextView.setTextColor(textColorPrimary);
|
||||||
} else {
|
} else {
|
||||||
|
@ -143,7 +153,11 @@ public class ItemViewHolder {
|
||||||
descrTextView.setVisibility(View.VISIBLE);
|
descrTextView.setVisibility(View.VISIBLE);
|
||||||
if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
|
if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
|
||||||
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
|
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
|
||||||
descrTextView.setText(indexItem.getType().getString(context));
|
if(showTypeInName) {
|
||||||
|
descrTextView.setText("");
|
||||||
|
} else {
|
||||||
|
descrTextView.setText(indexItem.getType().getString(context));
|
||||||
|
}
|
||||||
} else if (showTypeInDesc) {
|
} else if (showTypeInDesc) {
|
||||||
descrTextView.setText(indexItem.getType().getString(context) +
|
descrTextView.setText(indexItem.getType().getString(context) +
|
||||||
" • " + indexItem.getSizeDescription(context) +
|
" • " + indexItem.getSizeDescription(context) +
|
||||||
|
|
Loading…
Reference in a new issue