Search in sources :

Example 1 with DownloadTilesDialog

use of net.osmand.plus.activities.DownloadTilesDialog in project Osmand by osmandapp.

the class OsmandRasterMapsPlugin method registerMapContextMenuActions.

@Override
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, Object selectedObj) {
    final OsmandMapTileView mapView = mapActivity.getMapView();
    if (mapView.getMainLayer() instanceof MapTileLayer) {
        ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {

            @Override
            public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) {
                if (resId == R.string.context_menu_item_update_map) {
                    mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
                } else if (resId == R.string.shared_string_download_map) {
                    DownloadTilesDialog dlg = new DownloadTilesDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), mapView);
                    dlg.openDialog();
                }
                return true;
            }
        };
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_update_map, mapActivity).setIcon(R.drawable.ic_action_refresh_dark).setOrder(UPDATE_MAP_ITEM_ORDER).setListener(listener).createItem());
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_download_map, mapActivity).setIcon(R.drawable.ic_action_import).setOrder(DOWNLOAD_MAP_ITEM_ORDER).setListener(listener).createItem());
    }
}
Also used : ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) DownloadTilesDialog(net.osmand.plus.activities.DownloadTilesDialog) OsmandApplication(net.osmand.plus.OsmandApplication) MapTileLayer(net.osmand.plus.views.MapTileLayer) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ArrayAdapter (android.widget.ArrayAdapter)1 ItemClickListener (net.osmand.plus.ContextMenuAdapter.ItemClickListener)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 DownloadTilesDialog (net.osmand.plus.activities.DownloadTilesDialog)1 MapTileLayer (net.osmand.plus.views.MapTileLayer)1 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)1