Search in sources :

Example 6 with MapTileLayer

use of net.osmand.plus.views.layers.MapTileLayer in project Osmand by osmandapp.

the class OsmandRasterMapsPlugin method registerMapContextMenuActions.

@Override
public void registerMapContextMenuActions(@NonNull MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, Object selectedObj, boolean configureMenu) {
    boolean mapTileLayer = mapActivity.getMapView().getMainLayer() instanceof MapTileLayer;
    if (configureMenu || mapTileLayer) {
        ContextMenuItem.ItemBuilder downloadMapItemBuilder = new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_download_map, mapActivity).setId(MAP_CONTEXT_MENU_DOWNLOAD_MAP).setIcon(R.drawable.ic_action_import).setOrder(DOWNLOAD_MAP_ITEM_ORDER);
        if (mapTileLayer) {
            final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
            ItemClickListener listener = (adptr, resId, pos, isChecked, viewCoordinates) -> {
                MapActivity mapActivity1 = mapActivityRef.get();
                if (AndroidUtils.isActivityNotDestroyed(mapActivity1)) {
                    OsmandApplication app = mapActivity1.getMyApplication();
                    if (DownloadTilesFragment.shouldShowDialog(app)) {
                        DownloadTilesFragment.showInstance(mapActivity1.getSupportFragmentManager());
                    } else {
                        app.showShortToastMessage(R.string.maps_could_not_be_downloaded);
                    }
                }
                return true;
            };
            downloadMapItemBuilder.setListener(listener);
        }
        adapter.addItem(downloadMapItemBuilder.createItem());
    }
}
Also used : Version(net.osmand.plus.Version) Context(android.content.Context) TileSourceManager(net.osmand.map.TileSourceManager) AlertDialog(androidx.appcompat.app.AlertDialog) OVERLAY_MAP(net.osmand.aidlapi.OsmAndCustomizationConstants.OVERLAY_MAP) NonNull(androidx.annotation.NonNull) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) TileSourceTemplate(net.osmand.map.TileSourceManager.TileSourceTemplate) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) R(net.osmand.plus.R) Drawable(android.graphics.drawable.Drawable) EditMapSourceDialogFragment(net.osmand.plus.mapsource.EditMapSourceDialogFragment) UNDERLAY_MAP(net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP) ArrayList(java.util.ArrayList) MAP_CONTEXT_MENU_DOWNLOAD_MAP(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_DOWNLOAD_MAP) ContextMenuAdapter.makeDeleteAction(net.osmand.plus.ContextMenuAdapter.makeDeleteAction) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) MapLayers(net.osmand.plus.views.MapLayers) Toast(android.widget.Toast) Map(java.util.Map) ContextThemeWrapper(android.view.ContextThemeWrapper) Fragment(androidx.fragment.app.Fragment) View(android.view.View) MapTileLayer(net.osmand.plus.views.layers.MapTileLayer) Algorithms(net.osmand.util.Algorithms) WeakReference(java.lang.ref.WeakReference) AndroidUtils(net.osmand.plus.utils.AndroidUtils) FragmentManager(androidx.fragment.app.FragmentManager) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) AsyncTask(android.os.AsyncTask) ITileSource(net.osmand.map.ITileSource) StateChangedListener(net.osmand.StateChangedListener) OsmandApplication(net.osmand.plus.OsmandApplication) ArrayAdapter(android.widget.ArrayAdapter) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin) List(java.util.List) BaseMapLayer(net.osmand.plus.views.layers.base.BaseMapLayer) Nullable(androidx.annotation.Nullable) DashboardType(net.osmand.plus.dashboard.DashboardOnMap.DashboardType) PLUGIN_RASTER_MAPS(net.osmand.aidlapi.OsmAndCustomizationConstants.PLUGIN_RASTER_MAPS) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ContextMenuItem(net.osmand.plus.ContextMenuItem) Activity(android.app.Activity) QuickActionType(net.osmand.plus.quickaction.QuickActionType) ResultMatcher(net.osmand.ResultMatcher) DialogListItemAdapter(net.osmand.plus.DialogListItemAdapter) MapActivity(net.osmand.plus.activities.MapActivity) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) OsmandApplication(net.osmand.plus.OsmandApplication) WeakReference(java.lang.ref.WeakReference) MapTileLayer(net.osmand.plus.views.layers.MapTileLayer) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

MapTileLayer (net.osmand.plus.views.layers.MapTileLayer)5 ITileSource (net.osmand.map.ITileSource)4 View (android.view.View)2 ArrayAdapter (android.widget.ArrayAdapter)2 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)2 ContextMenuItem (net.osmand.plus.ContextMenuItem)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)2 MapLayers (net.osmand.plus.views.MapLayers)2 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Drawable (android.graphics.drawable.Drawable)1 AsyncTask (android.os.AsyncTask)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 Toast (android.widget.Toast)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 StringRes (androidx.annotation.StringRes)1 AlertDialog (androidx.appcompat.app.AlertDialog)1