@Override
    public View getView(final int position, final View rowView, @NonNull final ViewGroup parent) {
        if (inflater == null) {
            inflater = LayoutInflater.from(getContext());
        }

        if (position > getCount()) {
            Log.w("CacheListAdapter.getView: Attempt to access missing item #" + position);
            return null;
        }

        final Geocache cache = getItem(position);

        View v = rowView;

        final ViewHolder holder;
        if (v == null) {
            v = inflater.inflate(R.layout.cacheslist_item, parent, false);
            holder = new ViewHolder(v);
        } else {
            holder = (ViewHolder) v.getTag();
        }
        holder.cache = cache;

        final TouchListener touchListener = new TouchListener(cache, this);
        v.setOnClickListener(touchListener);
        v.setOnLongClickListener(touchListener);
        v.setOnTouchListener(touchListener);

        holder.binding.checkbox.setVisibility(selectMode ? View.VISIBLE : View.GONE);
        holder.binding.checkbox.setChecked(cache.isStatusChecked());
        holder.binding.checkbox.setOnClickListener(new SelectionCheckBoxListener(cache, this));

        distances.add(holder.binding.distance);
        holder.binding.distance.setCacheData(cache.getCoords(), cache.getDistance());

        Geopoint targetCoords = sortContext.getSort().getTargetCoords();
        if (null == targetCoords) {
            targetCoords = coords;
        } else {
            holder.binding.distance.setTypeface(Typeface.BOLD_ITALIC);
        }
        holder.binding.distance.update(targetCoords);

        compasses.add(holder.binding.direction);
        holder.binding.direction.setTargetCoords(cache.getCoords());
        holder.binding.text.setText(TextUtils.coloredCacheText(getContext(), cache, StringUtils.defaultIfBlank(cache.getName(), "")), TextView.BufferType.SPANNABLE);
        holder.cacheListType = cacheListType;
        updateViewHolder(holder, cache, res);

        final int inventorySize = cache.getInventoryItems();
        if (inventorySize > 0) {
            holder.binding.inventory.setText(String.format(Locale.getDefault(), "%d", inventorySize));
            holder.binding.inventory.setVisibility(View.VISIBLE);
        } else {
            holder.binding.inventory.setVisibility(View.GONE);
        }

        // only show the direction if this is enabled in the settings
        if (isLiveList) {
            if (cache.getCoords() != null) {
                holder.binding.direction.setVisibility(View.VISIBLE);
                holder.binding.dirimg.setVisibility(View.GONE);
                holder.binding.direction.updateAzimuth(azimuth);

                if (targetCoords != null) {
                    holder.binding.direction.updateCurrentCoords(targetCoords);
                }
            } else if (cache.getDirection() != null) {
                holder.binding.direction.setVisibility(View.VISIBLE);
                holder.binding.dirimg.setVisibility(View.GONE);
                holder.binding.direction.updateAzimuth(azimuth);
                holder.binding.direction.updateHeading(cache.getDirection());
            } else if (StringUtils.isNotBlank(cache.getDirectionImg())) {
                holder.binding.dirimg.setVisibility(View.INVISIBLE);
                holder.binding.direction.setVisibility(View.GONE);
                DirectionImage.fetchDrawable(cache.getDirectionImg()).observeOn(AndroidSchedulers.mainThread()).subscribe(bitmapDrawable -> {
                    if (cache == holder.cache) {
                        holder.binding.dirimg.setImageDrawable(bitmapDrawable);
                        holder.binding.dirimg.setVisibility(View.VISIBLE);
                    }
                });
            } else {
                holder.binding.dirimg.setVisibility(View.GONE);
                holder.binding.direction.setVisibility(View.GONE);
            }
        }

        final int favCount = cache.getFavoritePoints();
        holder.binding.favorite.setText(Formatter.formatFavCount(favCount));
        final float rating = cache.getRating();
        holder.binding.favorite.setBackgroundResource(rating >= 3.5 ? R.drawable.favorite_background_green : rating >= 2.1 ? R.drawable.favorite_background_orange : rating > 0.0 ? R.drawable.favorite_background_red : R.drawable.favorite_background);

        if (isHistory() && cache.getVisitedDate() > 0) {
            holder.binding.info.setText(Formatter.formatCacheInfoHistory(cache));
        } else {
            holder.binding.info.setText(Formatter.formatCacheInfoLong(cache, storedLists, currentListTitle));
        }

        return v;
    }
Apply a new filter to the adapter (e.g. after filter was changed by user in menu)
main/src/main/java/cgeo/geocaching/ui/CacheListAdapter.java