public void onClick(View v) { if (v == selectAllButton) { Tool currentTool = EditManager.INSTANCE.getActiveTool(); if (currentTool != null && currentTool instanceof InfoTool) { // if the same tool is re-selected, it is disabled EditManager.INSTANCE.setActiveTool(null); } else { // check maps enablement try { final Collection<SpatialVectorTable> spatialTables = SpatialiteSourcesManager.INSTANCE.getSpatialiteMaps2TablesMap().values(); boolean atLeastOneEnabled = false; for (SpatialVectorTable spatialVectorTable : spatialTables) { if (spatialVectorTable.getStyle().enabled == 1) { atLeastOneEnabled = true; break; } } if (!atLeastOneEnabled) { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); if (parent != null) { Context context = parent.getContext(); GPDialogs.warningDialog( context, context.getString(R.string.no_queriable_layer_is_visible), null); } return; } } catch (Exception e) { GPLog.error(this, null, e); } Tool activeTool = new InfoTool(this, mapView); EditManager.INSTANCE.setActiveTool(activeTool); } } else if (v == selectEditableButton) { Tool currentTool = EditManager.INSTANCE.getActiveTool(); if (currentTool != null && currentTool instanceof SelectionTool) { // if the same tool is re-selected, it is disabled EditManager.INSTANCE.setActiveTool(null); } else { Tool activeTool = new SelectionTool(mapView); EditManager.INSTANCE.setActiveTool(activeTool); } } else if (v == createFeatureButton) { ToolGroup createFeatureToolGroup = new LineCreateFeatureToolGroup(mapView, null); EditManager.INSTANCE.setActiveToolGroup(createFeatureToolGroup); } else if (v == undoButton) { // if (cutExtendProcessedFeature != null) { // EditManager.INSTANCE.setActiveTool(null); // commitButton.setVisibility(View.GONE); // undoButton.setVisibility(View.GONE); // EditManager.INSTANCE.invalidateEditingView(); // } } handleToolIcons(v); }
@SuppressWarnings("deprecation") private void handleToolIcons(View activeToolButton) { Context context = activeToolButton.getContext(); Tool currentTool = EditManager.INSTANCE.getActiveTool(); if (selectEditableButton != null) { if (currentTool != null && activeToolButton == selectEditableButton) { selectEditableButton.setBackground( Compat.getDrawable(context, R.drawable.editing_select_editable_active)); } else { selectEditableButton.setBackground( Compat.getDrawable(context, R.drawable.editing_select_editable)); } } if (selectAllButton != null) if (currentTool != null && activeToolButton == selectAllButton) { selectAllButton.setBackground( Compat.getDrawable(context, R.drawable.editing_select_all_active)); } else { selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.editing_select_all)); } }