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());
}
}
Aggregations