Source:
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); AirMapInterface airMapInterface = null; if (id == R.id.action_native_map) { try { airMapInterface = mapViewBuilder.builder(AirMapViewTypes.NATIVE).build(); } catch (UnsupportedOperationException e) { Toast.makeText(this, "Sorry, native Google Maps are not supported by this device. " + "Please make sure you have Google Play Services installed.", Toast.LENGTH_SHORT).show(); } } else if (id == R.id.action_web_map) { airMapInterface = mapViewBuilder.builder(AirMapViewTypes.WEB).build(); } else if (id == R.id.action_web_map_no_touch) { airMapInterface = mapViewBuilder.builder(AirMapViewTypes.WEB).build(); final AirMapInterface finalAirMapInterface = airMapInterface; airMapInterface.setOnMapLoadedListener(new OnMapLoadedListener() { @Override public void onMapLoaded() { finalAirMapInterface.setTouchEnabled(false); } }); } else if (id == R.id.action_native_map_no_touch) { try { airMapInterface = mapViewBuilder.builder(AirMapViewTypes.NATIVE).build(); final AirMapInterface finalAirMapInterface1 = airMapInterface; airMapInterface.setOnMapLoadedListener(new OnMapLoadedListener() { @Override public void onMapLoaded() { finalAirMapInterface1.setTouchEnabled(false); } }); } catch (UnsupportedOperationException e) { Toast.makeText(this, "Sorry, native Google Maps are not supported by this device. " + "Please make sure you have Google Play Services installed.", Toast.LENGTH_SHORT).show(); } } else if (id == R.id.action_clear_logs) { textLogs.setText(""); } if (airMapInterface != null) { map.initialize(getSupportFragmentManager(), airMapInterface); } return super.onOptionsItemSelected(item); }

Target:
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); AirMapInterface airMapInterface = null; switch (id) { case R.id.action_native_map: try { airMapInterface = mapViewBuilder.builder(AirMapViewTypes.NATIVE).build(); } catch (UnsupportedOperationException e) { Toast.makeText(this, "Sorry, native Google Maps are not supported by this device. " + "Please make sure you have Google Play Services installed.", Toast.LENGTH_SHORT).show(); } break; case R.id.action_mapbox_map: airMapInterface = mapViewBuilder.builder(AirMapViewTypes.WEB).build(); break; case R.id.action_google_web_map: airMapInterface = new WebAirMapViewBuilder().build(); break; case R.id.action_google_china_web_map: airMapInterface = new WebAirMapViewBuilder().withOptions(new GoogleChinaMapType()).build(); break; case R.id.action_clear_logs: textLogs.setText(""); break; case R.id.add_geojson_layer: String geoJsonString = Util.readFromRawResource(this, R.raw.google); AirMapGeoJsonLayer layer = new AirMapGeoJsonLayer.Builder(geoJsonString) .strokeColor(getResources().getColor(android.R.color.holo_green_dark)) .strokeWidth(10) .fillColor(getResources().getColor(android.R.color.holo_green_light)) .build(); try { map.getMapInterface().setGeoJsonLayer(layer); } catch (JSONException e) { Log.e(TAG, "Failed to add GeoJson layer", e); } break; case R.id.remove_geojson_layer: map.getMapInterface().clearGeoJsonLayer(); break; default: break; } if (airMapInterface != null) { map.initialize(getSupportFragmentManager(), airMapInterface); } return super.onOptionsItemSelected(item); }