Search in sources :

Example 16 with AbstractPoiType

use of net.osmand.osm.AbstractPoiType in project Osmand by osmandapp.

the class SearchPoiFilterFragment method getFilters.

public List<Object> getFilters(String s) {
    List<Object> filters = new ArrayList<Object>();
    OsmandApplication app = getApp();
    if (app == null) {
        return filters;
    }
    PoiFiltersHelper poiFilters = app.getPoiFilters();
    if (Algorithms.isEmpty(s)) {
        filters.addAll(poiFilters.getTopDefinedPoiFilters());
    } else {
        for (PoiUIFilter pf : poiFilters.getTopDefinedPoiFilters()) {
            if (!pf.isStandardFilter() && pf.getName().toLowerCase().startsWith(s.toLowerCase())) {
                filters.add(pf);
            }
        }
        List<AbstractPoiType> res = app.getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE));
        final Collator inst = Collator.getInstance();
        Collections.sort(res, new Comparator<AbstractPoiType>() {

            @Override
            public int compare(AbstractPoiType lhs, AbstractPoiType rhs) {
                return inst.compare(lhs.getTranslation(), rhs.getTranslation());
            }
        });
        for (AbstractPoiType p : res) {
            filters.add(p);
        }
        filters.add(poiFilters.getSearchByNamePOIFilter());
        if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
            filters.add(poiFilters.getNominatimPOIFilter());
            filters.add(poiFilters.getNominatimAddressFilter());
        }
    }
    return filters;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) Collator(java.text.Collator) CollatorStringMatcher(net.osmand.CollatorStringMatcher) OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin)

Example 17 with AbstractPoiType

use of net.osmand.osm.AbstractPoiType in project Osmand by osmandapp.

the class PoiFiltersHelper method getFilterById.

public PoiUIFilter getFilterById(String filterId) {
    if (filterId == null) {
        return null;
    }
    for (PoiUIFilter f : getTopDefinedPoiFilters()) {
        if (f.getFilterId().equals(filterId)) {
            return f;
        }
    }
    PoiUIFilter ff = getFilterById(filterId, getCustomPOIFilter(), getSearchByNamePOIFilter(), getLocalWikiPOIFilter(), getShowAllPOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter());
    if (ff != null) {
        return ff;
    }
    if (filterId.startsWith(PoiUIFilter.STD_PREFIX)) {
        String typeId = filterId.substring(PoiUIFilter.STD_PREFIX.length());
        AbstractPoiType tp = application.getPoiTypes().getAnyPoiTypeByKey(typeId);
        if (tp != null) {
            PoiUIFilter lf = new PoiUIFilter(tp, application, "");
            ArrayList<PoiUIFilter> copy = new ArrayList<PoiUIFilter>(cacheTopStandardFilters);
            copy.add(lf);
            Collections.sort(copy);
            cacheTopStandardFilters = copy;
            return lf;
        }
        AbstractPoiType lt = application.getPoiTypes().getAnyPoiAdditionalTypeByKey(typeId);
        if (lt != null) {
            PoiUIFilter lf = new PoiUIFilter(lt, application, "");
            ArrayList<PoiUIFilter> copy = new ArrayList<PoiUIFilter>(cacheTopStandardFilters);
            copy.add(lf);
            Collections.sort(copy);
            cacheTopStandardFilters = copy;
            return lf;
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) AbstractPoiType(net.osmand.osm.AbstractPoiType)

Example 18 with AbstractPoiType

use of net.osmand.osm.AbstractPoiType in project Osmand by osmandapp.

the class AmenityMenuBuilder method buildInternal.

@Override
public void buildInternal(View view) {
    boolean hasWiki = false;
    MapPoiTypes poiTypes = app.getPoiTypes();
    String preferredLang = SampleApplication.LANGUAGE;
    List<AmenityInfoRow> infoRows = new LinkedList<>();
    List<AmenityInfoRow> descriptions = new LinkedList<>();
    for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
        int iconId;
        Drawable icon = null;
        int textColor = 0;
        String key = e.getKey();
        String vl = e.getValue();
        String textPrefix = "";
        View collapsableView = null;
        boolean collapsable = false;
        boolean isWiki = false;
        boolean isText = false;
        boolean isDescription = false;
        boolean needLinks = !"population".equals(key);
        boolean isPhoneNumber = false;
        boolean isUrl = false;
        int poiTypeOrder = 0;
        String poiTypeKeyName = "";
        AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key);
        if (pt == null && !Algorithms.isEmpty(vl) && vl.length() < 50) {
            pt = poiTypes.getAnyPoiAdditionalTypeByKey(key + "_" + vl);
        }
        PoiType pType = null;
        if (pt != null) {
            pType = (PoiType) pt;
            if (pType.isFilterOnly()) {
                continue;
            }
            poiTypeOrder = pType.getOrder();
            poiTypeKeyName = pType.getKeyName();
        }
        if (amenity.getType().isWiki()) {
            if (!hasWiki) {
                iconId = OsmandResources.getDrawableId("ic_action_note_dark");
                String lng = amenity.getContentLanguage("content", preferredLang, "en");
                if (Algorithms.isEmpty(lng)) {
                    lng = "en";
                }
                final String langSelected = lng;
                String content = amenity.getDescription(langSelected);
                vl = (content != null) ? Html.fromHtml(content).toString() : "";
                if (vl.length() > 300) {
                    vl = vl.substring(0, 300);
                }
                hasWiki = true;
                isWiki = true;
                needLinks = false;
            } else {
                continue;
            }
        } else if (key.startsWith("name:")) {
            continue;
        } else if (Amenity.OPENING_HOURS.equals(key)) {
            iconId = OsmandResources.getDrawableId("ic_action_time");
            collapsableView = getCollapsableTextView(view.getContext(), true, amenity.getOpeningHours());
            collapsable = true;
            OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
            if (rs != null) {
                vl = rs.toLocalString();
                Calendar inst = Calendar.getInstance();
                inst.setTimeInMillis(System.currentTimeMillis());
                boolean opened = rs.isOpenedForTime(inst);
                if (opened) {
                    textColor = R.color.color_ok;
                } else {
                    textColor = R.color.color_invalid;
                }
            }
            needLinks = false;
        } else if (Amenity.PHONE.equals(key)) {
            iconId = OsmandResources.getDrawableId("ic_action_call_dark");
            isPhoneNumber = true;
        } else if (Amenity.WEBSITE.equals(key)) {
            iconId = OsmandResources.getDrawableId("ic_world_globe_dark");
            isUrl = true;
        } else if (Amenity.CUISINE.equals(key)) {
            iconId = OsmandResources.getDrawableId("ic_action_cuisine");
            StringBuilder sb = new StringBuilder();
            for (String c : e.getValue().split(";")) {
                if (sb.length() > 0) {
                    sb.append(", ");
                } else {
                    sb.append(app.getString("poi_cuisine")).append(": ");
                }
                sb.append(poiTypes.getPoiTranslation("cuisine_" + c).toLowerCase());
            }
            vl = sb.toString();
        } else {
            if (key.contains(Amenity.DESCRIPTION)) {
                iconId = OsmandResources.getDrawableId("ic_action_note_dark");
            } else {
                iconId = OsmandResources.getDrawableId("ic_action_info_dark");
            }
            if (pType != null) {
                poiTypeOrder = pType.getOrder();
                poiTypeKeyName = pType.getKeyName();
                if (pType.getParentType() != null && pType.getParentType() instanceof PoiType) {
                    icon = getRowIcon(view.getContext(), ((PoiType) pType.getParentType()).getOsmTag() + "_" + pType.getOsmTag().replace(':', '_') + "_" + pType.getOsmValue());
                }
                if (!pType.isText()) {
                    if (!Algorithms.isEmpty(pType.getPoiAdditionalCategory())) {
                        vl = pType.getPoiAdditionalCategoryTranslation() + ": " + pType.getTranslation().toLowerCase();
                    } else {
                        vl = pType.getTranslation();
                    }
                } else {
                    isText = true;
                    isDescription = iconId == OsmandResources.getDrawableId("ic_action_note_dark");
                    textPrefix = pType.getTranslation();
                    vl = amenity.unzipContent(e.getValue());
                }
                if (!isDescription && icon == null) {
                    icon = getRowIcon(view.getContext(), pType.getIconKeyName());
                    if (isText && icon != null) {
                        textPrefix = "";
                    }
                }
                if (icon == null && isText) {
                    iconId = OsmandResources.getDrawableId("ic_action_note_dark");
                }
            } else {
                textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey());
                vl = amenity.unzipContent(e.getValue());
            }
        }
        if (vl.startsWith("http://") || vl.startsWith("https://") || vl.startsWith("HTTP://") || vl.startsWith("HTTPS://")) {
            isUrl = true;
        }
        if (isDescription) {
            descriptions.add(new AmenityInfoRow(key, OsmandResources.getDrawableId("ic_action_note_dark"), textPrefix, vl, collapsable, collapsableView, 0, false, true, true, 0, "", false, false));
        } else if (icon != null) {
            infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, collapsable, collapsableView, textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
        } else {
            infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, collapsable, collapsableView, textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
        }
    }
    Collections.sort(infoRows, new Comparator<AmenityInfoRow>() {

        @Override
        public int compare(AmenityInfoRow row1, AmenityInfoRow row2) {
            if (row1.order < row2.order) {
                return -1;
            } else if (row1.order == row2.order) {
                return row1.name.compareTo(row2.name);
            } else {
                return 1;
            }
        }
    });
    for (AmenityInfoRow info : infoRows) {
        buildAmenityRow(view, info);
    }
    String langSuffix = ":" + preferredLang;
    AmenityInfoRow descInPrefLang = null;
    for (AmenityInfoRow desc : descriptions) {
        if (desc.key.length() > langSuffix.length() && desc.key.substring(desc.key.length() - langSuffix.length(), desc.key.length()).equals(langSuffix)) {
            descInPrefLang = desc;
            break;
        }
    }
    if (descInPrefLang != null) {
        descriptions.remove(descInPrefLang);
        descriptions.add(0, descInPrefLang);
    }
    for (AmenityInfoRow info : descriptions) {
        buildAmenityRow(view, info);
    }
    if (processNearstWiki() && nearestWiki.size() > 0) {
        AmenityInfoRow wikiInfo = new AmenityInfoRow("nearest_wiki", OsmandResources.getDrawableId("ic_action_wikipedia"), null, app.getString("wiki_around") + " (" + nearestWiki.size() + ")", true, getCollapsableWikiView(view.getContext(), true), 0, false, false, false, 1000, null, false, false);
        buildAmenityRow(view, wikiInfo);
    }
    buildRow(view, OsmandResources.getDrawableId("ic_action_get_my_location"), PointDescription.getLocationName(app, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true).replaceAll("\n", " "), 0, false, null, false, 0, false, null);
}
Also used : Calendar(java.util.Calendar) Drawable(android.graphics.drawable.Drawable) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) SpannableString(android.text.SpannableString) AbstractPoiType(net.osmand.osm.AbstractPoiType) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OpeningHoursParser(net.osmand.util.OpeningHoursParser) MapPoiTypes(net.osmand.osm.MapPoiTypes) LinkedList(java.util.LinkedList) Map(java.util.Map)

Example 19 with AbstractPoiType

use of net.osmand.osm.AbstractPoiType in project Osmand by osmandapp.

the class SampleFormatter method getAmenityDescriptionContent.

public static String getAmenityDescriptionContent(SampleApplication ctx, Amenity amenity, boolean shortDescription) {
    StringBuilder d = new StringBuilder();
    if (amenity.getType().isWiki()) {
        return "";
    }
    MapPoiTypes poiTypes = ctx.getPoiTypes();
    for (Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
        String key = e.getKey();
        String vl = e.getValue();
        if (key.startsWith("name:")) {
            continue;
        } else if (vl.length() >= 150) {
            if (shortDescription) {
                continue;
            }
        } else if (Amenity.OPENING_HOURS.equals(key)) {
            d.append(ctx.getString("opening_hours") + ": ");
        } else if (Amenity.PHONE.equals(key)) {
            d.append(ctx.getString("phone") + ": ");
        } else if (Amenity.WEBSITE.equals(key)) {
            d.append(ctx.getString("website") + ": ");
        } else {
            AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey());
            if (pt != null) {
                if (pt instanceof PoiType && !((PoiType) pt).isText()) {
                    vl = pt.getTranslation();
                } else {
                    vl = pt.getTranslation() + ": " + amenity.unzipContent(e.getValue());
                }
            } else {
                vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) + ": " + amenity.unzipContent(e.getValue());
            }
        }
        d.append(vl).append('\n');
    }
    return d.toString().trim();
}
Also used : AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) AbstractPoiType(net.osmand.osm.AbstractPoiType) MapPoiTypes(net.osmand.osm.MapPoiTypes)

Example 20 with AbstractPoiType

use of net.osmand.osm.AbstractPoiType in project Osmand by osmandapp.

the class QuickSearchListAdapter method getView.

@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    final QuickSearchListItem listItem = getItem(position);
    QuickSearchListItemType type = listItem.getType();
    LinearLayout view;
    if (type == QuickSearchListItemType.SEARCH_MORE) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.search_more_list_item, null);
        } else {
            view = (LinearLayout) convertView;
        }
        if (listItem.getSpannableName() != null) {
            ((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
        } else {
            ((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
        }
        final QuickSearchMoreListItem searchMoreItem = (QuickSearchMoreListItem) listItem;
        int emptyDescId = searchMoreItem.isSearchMoreAvailable() ? R.string.nothing_found_descr : R.string.modify_the_search_query;
        ((TextView) view.findViewById(R.id.empty_search_description)).setText(emptyDescId);
        boolean emptySearchVisible = searchMoreItem.isEmptySearch() && !searchMoreItem.isInterruptedSearch();
        boolean moreDividerVisible = emptySearchVisible && searchMoreItem.isSearchMoreAvailable();
        view.findViewById(R.id.empty_search).setVisibility(emptySearchVisible ? View.VISIBLE : View.GONE);
        view.findViewById(R.id.more_divider).setVisibility(moreDividerVisible ? View.VISIBLE : View.GONE);
        SearchUICore searchUICore = app.getSearchUICore().getCore();
        String textTitle = app.getString(R.string.nothing_found_in_radius) + " " + OsmAndFormatter.getFormattedDistance(searchUICore.getMinimalSearchRadius(searchUICore.getPhrase()), app);
        ((TextView) view.findViewById(R.id.empty_search_title)).setText(textTitle);
        View increaseRadiusRow = view.findViewById(R.id.increase_radius_row);
        increaseRadiusRow.setVisibility(searchMoreItem.isSearchMoreAvailable() ? View.VISIBLE : View.GONE);
        increaseRadiusRow.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                ((QuickSearchMoreListItem) listItem).increaseRadiusOnClick();
            }
        });
        if (!searchMoreItem.isOnlineSearch()) {
            View onlineSearchRow = view.findViewById(R.id.online_search_row);
            onlineSearchRow.setVisibility(View.VISIBLE);
            onlineSearchRow.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    searchMoreItem.onlineSearchOnClick();
                }
            });
        }
    } else if (type == QuickSearchListItemType.BUTTON) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.search_custom_list_item, null);
        } else {
            view = (LinearLayout) convertView;
        }
        ((ImageView) view.findViewById(R.id.imageView)).setImageDrawable(listItem.getIcon());
        if (listItem.getSpannableName() != null) {
            ((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
        } else {
            ((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
        }
    } else if (type == QuickSearchListItemType.SELECT_ALL) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.select_all_list_item, null);
        } else {
            view = (LinearLayout) convertView;
        }
        final CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
        ch.setVisibility(View.VISIBLE);
        ch.setChecked(selectAll);
        ch.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                toggleCheckbox(position, ch);
            }
        });
    } else if (type == QuickSearchListItemType.HEADER) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.search_header_list_item, null);
        } else {
            view = (LinearLayout) convertView;
        }
        view.findViewById(R.id.top_divider).setVisibility(((QuickSearchHeaderListItem) listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
        if (listItem.getSpannableName() != null) {
            ((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
        } else {
            ((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
        }
    } else if (type == QuickSearchListItemType.TOP_SHADOW) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.list_shadow_header, null);
        } else {
            view = (LinearLayout) convertView;
        }
        return view;
    } else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.list_shadow_footer, null);
        } else {
            view = (LinearLayout) convertView;
        }
        return view;
    } else {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (LinearLayout) inflater.inflate(R.layout.search_list_item, null);
        } else {
            view = (LinearLayout) convertView;
        }
        final CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
        if (selectionMode) {
            ch.setVisibility(View.VISIBLE);
            ch.setChecked(selectedItems.contains(listItem));
            ch.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    toggleCheckbox(position, ch);
                }
            });
        } else {
            ch.setVisibility(View.GONE);
        }
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
        TextView title = (TextView) view.findViewById(R.id.title);
        TextView subtitle = (TextView) view.findViewById(R.id.subtitle);
        imageView.setImageDrawable(listItem.getIcon());
        String name = listItem.getName();
        if (listItem.getSpannableName() != null) {
            title.setText(listItem.getSpannableName());
        } else {
            title.setText(name);
        }
        String desc = listItem.getTypeName();
        Object searchResultObject = listItem.getSearchResult().object;
        if (searchResultObject instanceof AbstractPoiType) {
            AbstractPoiType abstractPoiType = (AbstractPoiType) searchResultObject;
            String[] synonyms = abstractPoiType.getSynonyms().split(";");
            QuickSearchHelper searchHelper = app.getSearchUICore();
            SearchUICore searchUICore = searchHelper.getCore();
            String searchPhrase = searchUICore.getPhrase().getText(true);
            SearchPhrase.NameStringMatcher nm = new SearchPhrase.NameStringMatcher(searchPhrase, CollatorStringMatcher.StringMatcherMode.CHECK_STARTS_FROM_SPACE);
            if (!searchPhrase.isEmpty() && !nm.matches(abstractPoiType.getTranslation())) {
                if (nm.matches(abstractPoiType.getEnTranslation())) {
                    desc = listItem.getTypeName() + " (" + abstractPoiType.getEnTranslation() + ")";
                } else {
                    for (String syn : synonyms) {
                        if (nm.matches(syn)) {
                            desc = listItem.getTypeName() + " (" + syn + ")";
                            break;
                        }
                    }
                }
            }
        }
        boolean hasDesc = false;
        if (!Algorithms.isEmpty(desc) && !desc.equals(name)) {
            subtitle.setText(desc);
            subtitle.setVisibility(View.VISIBLE);
            hasDesc = true;
        } else {
            subtitle.setVisibility(View.GONE);
        }
        Drawable typeIcon = listItem.getTypeIcon();
        ImageView group = (ImageView) view.findViewById(R.id.type_name_icon);
        if (typeIcon != null && hasDesc) {
            group.setImageDrawable(typeIcon);
            group.setVisibility(View.VISIBLE);
        } else {
            group.setVisibility(View.GONE);
        }
        LinearLayout timeLayout = (LinearLayout) view.findViewById(R.id.time_layout);
        TextView timeText = (TextView) view.findViewById(R.id.time);
        ImageView timeIcon = (ImageView) view.findViewById(R.id.time_icon);
        if (listItem.getSearchResult().object instanceof Amenity && ((Amenity) listItem.getSearchResult().object).getOpeningHours() != null) {
            Amenity amenity = (Amenity) listItem.getSearchResult().object;
            OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
            if (rs != null) {
                Calendar inst = Calendar.getInstance();
                inst.setTimeInMillis(System.currentTimeMillis());
                boolean worksNow = rs.isOpenedForTime(inst);
                // 30 minutes later
                inst.setTimeInMillis(System.currentTimeMillis() + 30 * 60 * 1000);
                boolean worksLater = rs.isOpenedForTime(inst);
                int colorId = worksNow ? worksLater ? R.color.color_ok : R.color.color_intermediate : R.color.color_warning;
                timeLayout.setVisibility(View.VISIBLE);
                timeIcon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_small_time, colorId));
                timeText.setTextColor(app.getResources().getColor(colorId));
                String rt = rs.getCurrentRuleTime(inst);
                timeText.setText(rt == null ? "" : rt);
            } else {
                timeLayout.setVisibility(View.GONE);
            }
        } else {
            timeLayout.setVisibility(View.GONE);
        }
        updateCompassVisibility(view, listItem);
    }
    view.setBackgroundColor(app.getResources().getColor(app.getSettings().isLightContent() ? R.color.bg_color_light : R.color.bg_color_dark));
    View divider = view.findViewById(R.id.divider);
    if (divider != null) {
        if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER || getItem(position + 1).getType() == QuickSearchListItemType.BOTTOM_SHADOW) {
            divider.setVisibility(View.GONE);
        } else {
            divider.setVisibility(View.VISIBLE);
            if (getItem(position + 1).getType() == QuickSearchListItemType.SEARCH_MORE || type == QuickSearchListItemType.SELECT_ALL) {
                LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp1);
                p.setMargins(0, 0, 0, 0);
                divider.setLayoutParams(p);
            } else {
                LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp1);
                p.setMargins(dp56, 0, 0, 0);
                divider.setLayoutParams(p);
            }
        }
    }
    ViewCompat.setAccessibilityDelegate(view, accessibilityAssistant);
    return view;
}
Also used : QuickSearchMoreListItem(net.osmand.plus.search.listitems.QuickSearchMoreListItem) SearchPhrase(net.osmand.search.core.SearchPhrase) QuickSearchListItemType(net.osmand.plus.search.listitems.QuickSearchListItemType) QuickSearchListItem(net.osmand.plus.search.listitems.QuickSearchListItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Amenity(net.osmand.data.Amenity) Calendar(java.util.Calendar) Drawable(android.graphics.drawable.Drawable) AbstractPoiType(net.osmand.osm.AbstractPoiType) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SearchUICore(net.osmand.search.SearchUICore) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout) NonNull(android.support.annotation.NonNull)

Aggregations

AbstractPoiType (net.osmand.osm.AbstractPoiType)22 PoiType (net.osmand.osm.PoiType)12 MapPoiTypes (net.osmand.osm.MapPoiTypes)10 Amenity (net.osmand.data.Amenity)6 Drawable (android.graphics.drawable.Drawable)5 View (android.view.View)5 TextView (android.widget.TextView)5 PoiCategory (net.osmand.osm.PoiCategory)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)4 SpannableString (android.text.SpannableString)3 File (java.io.File)3 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)3 City (net.osmand.data.City)3 FavouritePoint (net.osmand.data.FavouritePoint)3 LatLon (net.osmand.data.LatLon)3 PoiFilter (net.osmand.osm.PoiFilter)3 OsmandApplication (net.osmand.plus.OsmandApplication)3 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)3