diff options
author | Cameron Mace <cameron@mapbox.com> | 2016-12-16 16:19:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-16 16:19:15 -0500 |
commit | 20b958301eb208fe9ed0ae8edfb14b6f3741d8f2 (patch) | |
tree | 94ae0ce250cda159be13f9a21cc70c92d4908974 /platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java | |
parent | f95b4838ea816b9da0c151a953a1f98f97c79a39 (diff) | |
download | qtlocation-mapboxgl-20b958301eb208fe9ed0ae8edfb14b6f3741d8f2.tar.gz |
Adds checkstyle to CI (#7442)
* adds checkstyle to CI
* fixed gradlew path
* resolved testapp checkstyle violations
* added back mapboxMap variable for test
* checkstyle annotations
* checkstyle SDK round 1
* maps package checkstyle
* rest of SDK checkstyle
* checkstyle gesture library
* checkstyle test
* finished rest of test checkstyle
* resolved all checkstyle errors
* fixed class name
* removed old test file
* fixed camera postion test
* fixed native crash
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java | 321 |
1 files changed, 161 insertions, 160 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java index ae4f6042ce..be71e58eba 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java @@ -18,7 +18,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.layers.SymbolLayer; import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; import com.mapbox.mapboxsdk.testapp.R; @@ -29,8 +28,6 @@ import com.mapbox.services.commons.geojson.Point; import java.util.Arrays; import java.util.List; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize; @@ -44,171 +41,175 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; */ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.OnMapClickListener { - public static final String MARKER_SOURCE = "marker-source"; - public static final String MARKER_LAYER = "marker-layer"; - private MapboxMap mapboxMap; - private MapView mapView; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_symbollayer); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(@NonNull final MapboxMap map) { - mapboxMap = map; - - //Add a image for the makers - mapboxMap.addImage("my-marker-image", BitmapFactory.decodeResource(SymbolLayerActivity.this.getResources(), R.drawable.mapbox_marker_icon_default)); - - //Add a source - FeatureCollection markers = FeatureCollection.fromFeatures(new Feature[]{ - Feature.fromGeometry(Point.fromCoordinates(new double[]{4.91638, 52.35673}), featureProperties("Marker 1")), - Feature.fromGeometry(Point.fromCoordinates(new double[]{4.91638, 52.34673}), featureProperties("Marker 2")) - }); - mapboxMap.addSource(new GeoJsonSource(MARKER_SOURCE, markers)); - - //Add the symbol-layer - mapboxMap.addLayer( - new SymbolLayer(MARKER_LAYER, MARKER_SOURCE) - .withProperties( - iconImage("my-marker-image"), - iconAllowOverlap(true), - textField("{title}"), - textColor(Color.RED), - textSize(10f) - ) - ); - - //Show - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.35273, 4.91638), 14)); - - //Set a click-listener so we can manipulate the map - mapboxMap.setOnMapClickListener(SymbolLayerActivity.this); - } - }); - } - - @Override - public void onMapClick(@NonNull LatLng point) { - //Query which features are clicked - PointF screenLoc = mapboxMap.getProjection().toScreenLocation(point); - List<Feature> features = mapboxMap.queryRenderedFeatures(screenLoc, MARKER_LAYER); - - SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); - if (features.size() == 0) { - //Reset - layer.setProperties(iconSize(1f)); - } else { - layer.setProperties(iconSize(3f)); - } - } - - private void toggleTextSize() { - SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); - layer.setProperties(layer.getTextSize().getValue() > 10 ? textSize(10f) : textSize(20f)); - } - - private void toggleTextField() { - SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); - layer.setProperties("{title}".equals(layer.getTextField().getValue()) ? textField("āA") : textField("{title}")); - } - - private void toggleTextFont() { - SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); + public static final String MARKER_SOURCE = "marker-source"; + public static final String MARKER_LAYER = "marker-layer"; + private MapboxMap mapboxMap; + private MapView mapView; - String[] fonts = layer.getTextFont().getValue(); - if (fonts == null || fonts.length == 0 || Arrays.asList(fonts).contains("Arial Unicode MS Regular")) { - layer.setProperties(textFont(new String[]{"DIN Offc Pro Bold", "Arial Unicode MS Bold"})); - } else { - layer.setProperties(textFont(new String[]{"DIN Offc Pro Medium", "Arial Unicode MS Regular"})); - } - } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_symbollayer); - private JsonObject featureProperties(String title) { - JsonObject object = new JsonObject(); - object.add("title", new JsonPrimitive(title)); - return object; - } + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); } - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(@NonNull final MapboxMap map) { + mapboxMap = map; + + //Add a image for the makers + mapboxMap.addImage( + "my-marker-image", + BitmapFactory.decodeResource(SymbolLayerActivity.this.getResources(), + R.drawable.mapbox_marker_icon_default) + ); + + //Add a source + FeatureCollection markers = FeatureCollection.fromFeatures(new Feature[] { + Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.35673}), featureProperties("Marker 1")), + Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.34673}), featureProperties("Marker 2")) + }); + mapboxMap.addSource(new GeoJsonSource(MARKER_SOURCE, markers)); + + //Add the symbol-layer + mapboxMap.addLayer( + new SymbolLayer(MARKER_LAYER, MARKER_SOURCE) + .withProperties( + iconImage("my-marker-image"), + iconAllowOverlap(true), + textField("{title}"), + textColor(Color.RED), + textSize(10f) + ) + ); + + //Show + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.35273, 4.91638), 14)); + + //Set a click-listener so we can manipulate the map + mapboxMap.setOnMapClickListener(SymbolLayerActivity.this); + } + }); + } + + @Override + public void onMapClick(@NonNull LatLng point) { + //Query which features are clicked + PointF screenLoc = mapboxMap.getProjection().toScreenLocation(point); + List<Feature> features = mapboxMap.queryRenderedFeatures(screenLoc, MARKER_LAYER); + + SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); + if (features.size() == 0) { + //Reset + layer.setProperties(iconSize(1f)); + } else { + layer.setProperties(iconSize(3f)); } - - @Override - public void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); + } + + private void toggleTextSize() { + SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); + layer.setProperties(layer.getTextSize().getValue() > 10 ? textSize(10f) : textSize(20f)); + } + + private void toggleTextField() { + SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); + layer.setProperties("{title}".equals(layer.getTextField().getValue()) ? textField("āA") : textField("{title}")); + } + + private void toggleTextFont() { + SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); + + String[] fonts = layer.getTextFont().getValue(); + if (fonts == null || fonts.length == 0 || Arrays.asList(fonts).contains("Arial Unicode MS Regular")) { + layer.setProperties(textFont(new String[] {"DIN Offc Pro Bold", "Arial Unicode MS Bold"})); + } else { + layer.setProperties(textFont(new String[] {"DIN Offc Pro Medium", "Arial Unicode MS Regular"})); } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_symbol_layer, menu); + } + + private JsonObject featureProperties(String title) { + JsonObject object = new JsonObject(); + object.add("title", new JsonPrimitive(title)); + return object; + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_symbol_layer, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); return true; + case R.id.action_toggle_text_size: + toggleTextSize(); + return true; + case R.id.action_toggle_text_field: + toggleTextField(); + return true; + case R.id.action_toggle_text_font: + toggleTextFont(); + return true; + default: + return super.onOptionsItemSelected(item); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - case R.id.action_toggle_text_size: - toggleTextSize(); - return true; - case R.id.action_toggle_text_field: - toggleTextField(); - return true; - case R.id.action_toggle_text_font: - toggleTextFont(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } + } }
\ No newline at end of file |