use of net.osmand.plus.download.DownloadItem in project Osmand by osmandapp.
the class VoiceLanguageBottomSheetFragment method getVoiceList.
public List<DownloadItem> getVoiceList(String type) {
DownloadResources indexes = downloadThread.getIndexes();
if (!indexes.isDownloadedFromInternet && settings.isInternetConnectionAvailable()) {
downloadThread.runReloadIndexFiles();
}
List<DownloadItem> suggestedVoice = new ArrayList<>();
if (indexes.isDownloadedFromInternet && !indexes.downloadFromInternetFailed) {
suggestedVoice.addAll(indexes.getDownloadItemsForGroup(type));
}
List<IndexItem> localItems = selectedVoiceType == InfoType.TTS ? listTtsVoiceIndexes(app) : listLocalRecordedVoiceIndexes(app);
for (IndexItem item : localItems) {
boolean contains = false;
for (DownloadItem suggestedItem : suggestedVoice) {
if (Algorithms.stringsEqual(item.getFileName(), suggestedItem.getFileName())) {
contains = true;
break;
}
}
if (!contains) {
suggestedVoice.add(item);
}
}
return suggestedVoice;
}
use of net.osmand.plus.download.DownloadItem in project Osmand by osmandapp.
the class DownloadResourceGroupAdapter method getChildView.
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final Object child = getChild(groupPosition, childPosition);
if (child instanceof DownloadItem) {
DownloadItem item = (DownloadItem) child;
DownloadResourceGroup group = getGroupObj(groupPosition);
ItemViewHolder viewHolder;
if (convertView != null && convertView.getTag() instanceof ItemViewHolder) {
viewHolder = (ItemViewHolder) convertView.getTag();
} else {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ItemViewHolder(convertView, ctx);
viewHolder.setShowRemoteDate(true);
convertView.setTag(viewHolder);
}
if (mainGroup.getType() == DownloadResourceGroup.DownloadResourceGroupType.REGION && group != null && group.getType() == DownloadResourceGroup.DownloadResourceGroupType.REGION_MAPS && !(item instanceof CustomIndexItem)) {
viewHolder.setShowTypeInName(true);
viewHolder.setShowTypeInDesc(false);
} else if (group != null && (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.SRTM_HEADER || group.getType() == DownloadResourceGroup.DownloadResourceGroupType.HILLSHADE_HEADER)) {
viewHolder.setShowTypeInName(false);
viewHolder.setShowTypeInDesc(false);
} else {
viewHolder.setShowTypeInDesc(true);
}
viewHolder.bindDownloadItem(item);
} else {
DownloadResourceGroup group = (DownloadResourceGroup) child;
DownloadGroupViewHolder viewHolder;
if (convertView != null && convertView.getTag() instanceof DownloadGroupViewHolder) {
viewHolder = (DownloadGroupViewHolder) convertView.getTag();
} else {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.simple_list_menu_item, parent, false);
viewHolder = new DownloadGroupViewHolder(ctx, convertView);
convertView.setTag(viewHolder);
}
viewHolder.bindItem(group);
}
return convertView;
}
Aggregations