@Test public void addBaseLayerShouldReturnFalseWhenBaseLayerIdIsSame() { BaseLayer satelliteLayer = new SatelliteBaseLayer(); ArrayList<BaseLayer> baseLayers = new ArrayList<>(); baseLayers.add(satelliteLayer); assertEquals(0, ((ArrayList<BaseLayer>) ReflectionHelpers.getField(baseLayerSwitcherPlugin, "baseLayers")).size()); ReflectionHelpers.setField(baseLayerSwitcherPlugin, "baseLayers", baseLayers); assertFalse(baseLayerSwitcherPlugin.addBaseLayer(new SatelliteBaseLayer(), true)); }
public boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault) { if (baseLayers.contains(baseLayer)) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } for (BaseLayer addedBaseLayer: baseLayers) { if (addedBaseLayer.getId().equals(baseLayer.getId())) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } } this.baseLayers.add(baseLayer); if (isDefault) { showBaseLayer(baseLayer); } return true; }
BaseLayerSwitcherPlugin implements PopupMenu.OnMenuItemClickListener { public boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault) { if (baseLayers.contains(baseLayer)) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } for (BaseLayer addedBaseLayer: baseLayers) { if (addedBaseLayer.getId().equals(baseLayer.getId())) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } } this.baseLayers.add(baseLayer); if (isDefault) { showBaseLayer(baseLayer); } return true; } }
BaseLayerSwitcherPlugin implements PopupMenu.OnMenuItemClickListener { public boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault) { if (baseLayers.contains(baseLayer)) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } for (BaseLayer addedBaseLayer: baseLayers) { if (addedBaseLayer.getId().equals(baseLayer.getId())) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } } this.baseLayers.add(baseLayer); if (isDefault) { showBaseLayer(baseLayer); } return true; } BaseLayerSwitcherPlugin(@NonNull KujakuMapView kujakuMapView, @NonNull Style style); }
BaseLayerSwitcherPlugin implements PopupMenu.OnMenuItemClickListener { public boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault) { if (baseLayers.contains(baseLayer)) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } for (BaseLayer addedBaseLayer: baseLayers) { if (addedBaseLayer.getId().equals(baseLayer.getId())) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } } this.baseLayers.add(baseLayer); if (isDefault) { showBaseLayer(baseLayer); } return true; } BaseLayerSwitcherPlugin(@NonNull KujakuMapView kujakuMapView, @NonNull Style style); boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault); boolean removeBaseLayerFromMap(@NonNull BaseLayer baseLayer); boolean removeBaseLayer(@NonNull BaseLayer baseLayer); @NonNull ArrayList<BaseLayer> getBaseLayers(); void show(); void showPluginSwitcherView(); void showPopup(@NonNull View anchorView); @Override boolean onMenuItemClick(MenuItem item); }
BaseLayerSwitcherPlugin implements PopupMenu.OnMenuItemClickListener { public boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault) { if (baseLayers.contains(baseLayer)) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } for (BaseLayer addedBaseLayer: baseLayers) { if (addedBaseLayer.getId().equals(baseLayer.getId())) { if (isDefault && currentBaseLayer != null && !currentBaseLayer.getId().equals(baseLayer.getId())) { showBaseLayer(baseLayer); } return false; } } this.baseLayers.add(baseLayer); if (isDefault) { showBaseLayer(baseLayer); } return true; } BaseLayerSwitcherPlugin(@NonNull KujakuMapView kujakuMapView, @NonNull Style style); boolean addBaseLayer(@NonNull BaseLayer baseLayer, boolean isDefault); boolean removeBaseLayerFromMap(@NonNull BaseLayer baseLayer); boolean removeBaseLayer(@NonNull BaseLayer baseLayer); @NonNull ArrayList<BaseLayer> getBaseLayers(); void show(); void showPluginSwitcherView(); void showPopup(@NonNull View anchorView); @Override boolean onMenuItemClick(MenuItem item);  }