@Override
    public void onCreateContextMenu(final ContextMenu menu, final View view, final ContextMenu.ContextMenuInfo info) {
        super.onCreateContextMenu(menu, view, info);

        AdapterContextMenuInfo adapterInfo = null;
        try {
            adapterInfo = (AdapterContextMenuInfo) info;
        } catch (final Exception e) {
            Log.w("CacheListActivity.onCreateContextMenu", e);
        }

        if (adapterInfo == null || adapterInfo.position >= adapter.getCount()) {
            return;
        }
        final Geocache cache = adapter.getItem(adapterInfo.position);
        assert cache != null;

        menu.setHeaderTitle(StringUtils.defaultIfBlank(cache.getName(), cache.getShortGeocode()));

        contextMenuGeocode = cache.getGeocode();

        getMenuInflater().inflate(R.menu.cache_list_context, menu);

        menu.findItem(R.id.menu_default_navigation).setTitle(NavigationAppFactory.getDefaultNavigationApplication().getName());
        final boolean hasCoords = cache.getCoords() != null;
        MenuUtils.setVisible(menu.findItem(R.id.menu_default_navigation), hasCoords);
        MenuUtils.setVisible(menu.findItem(R.id.menu_navigate), hasCoords);
        MenuUtils.setVisible(menu.findItem(R.id.menu_cache_details), hasCoords);
        final boolean isOffline = cache.isOffline();
        MenuUtils.setVisible(menu.findItem(R.id.menu_drop_cache), isOffline);
        MenuUtils.setVisible(menu.findItem(R.id.menu_move_to_list), isOffline);
        MenuUtils.setVisible(menu.findItem(R.id.menu_copy_to_list), isOffline);
        MenuUtils.setVisible(menu.findItem(R.id.menu_refresh), isOffline);
        MenuUtils.setVisible(menu.findItem(R.id.menu_store_cache), !isOffline);

        LoggingUI.onPrepareOptionsMenu(menu, cache);
    }
called from the filter bar view
main/src/main/java/cgeo/geocaching/CacheListActivity.java