Search in sources :

Example 6 with DownloadItem

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;
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources) ArrayList(java.util.ArrayList) DownloadItem(net.osmand.plus.download.DownloadItem) IndexItem(net.osmand.plus.download.IndexItem)

Example 7 with DownloadItem

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;
}
Also used : DownloadResourceGroup(net.osmand.plus.download.DownloadResourceGroup) DownloadItem(net.osmand.plus.download.DownloadItem) CustomIndexItem(net.osmand.plus.download.CustomIndexItem)

Aggregations

DownloadItem (net.osmand.plus.download.DownloadItem)7 ArrayList (java.util.ArrayList)3 IndexItem (net.osmand.plus.download.IndexItem)3 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 ProgressBar (android.widget.ProgressBar)2 TextView (android.widget.TextView)2 NonNull (androidx.annotation.NonNull)2 SelectableItem (net.osmand.plus.base.SelectionBottomSheet.SelectableItem)2 CustomIndexItem (net.osmand.plus.download.CustomIndexItem)2 DownloadResourceGroup (net.osmand.plus.download.DownloadResourceGroup)2 Intent (android.content.Intent)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 DateFormat (java.text.DateFormat)1 List (java.util.List)1 WorldRegion (net.osmand.map.WorldRegion)1 R (net.osmand.plus.R)1 MapActivity (net.osmand.plus.activities.MapActivity)1 MultipleSelectionBottomSheet (net.osmand.plus.base.MultipleSelectionBottomSheet)1