summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp
diff options
context:
space:
mode:
authorCameron Mace <cameron@mapbox.com>2016-12-16 16:19:15 -0500
committerGitHub <noreply@github.com>2016-12-16 16:19:15 -0500
commit20b958301eb208fe9ed0ae8edfb14b6f3741d8f2 (patch)
tree94ae0ce250cda159be13f9a21cc70c92d4908974 /platform/android/MapboxGLAndroidSDKTestApp
parentf95b4838ea816b9da0c151a953a1f98f97c79a39 (diff)
downloadqtlocation-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')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle17
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java36
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java1535
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java78
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java180
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java191
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java129
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java120
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java405
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java404
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java167
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java169
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java405
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java55
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java75
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java73
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java55
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java218
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java200
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java84
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java318
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java168
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java168
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java40
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java432
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java603
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java473
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java473
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java734
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java734
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java388
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java389
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java71
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java278
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java43
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java2330
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java2330
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java75
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java189
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java63
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java336
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java270
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java434
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java446
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java230
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java808
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java260
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java210
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java299
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java376
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java229
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java342
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java329
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java220
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java202
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java152
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java228
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java270
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java317
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java106
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java256
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java239
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java269
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java400
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java106
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java109
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java138
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java308
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java182
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java192
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java267
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java348
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java250
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java222
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java268
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java199
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java250
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java384
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java126
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java294
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java738
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java602
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java264
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java222
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java237
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java274
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java198
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java922
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java108
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java152
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java321
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java282
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java390
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java265
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java586
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java66
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java265
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java112
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarkerOptions.java88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerOptions.java98
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java166
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java110
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java130
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/constants/AppConstant.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java78
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java59
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java25
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/GeoParseUtil.java88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java138
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/OfflineUtils.java41
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java209
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java58
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java122
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java80
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java130
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java282
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java517
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java106
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java104
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java211
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java363
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java356
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java161
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java336
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java77
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java634
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java159
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FilterTest.java170
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java33
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java15
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java399
147 files changed, 19050 insertions, 18644 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index dbb8f5f487..b4d5548ae5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -90,5 +90,6 @@ apply from: 'gradle-make.gradle'
apply from: 'gradle-config.gradle'
apply from: 'gradle-device-farm.gradle'
apply from: 'gradle-spoon.gradle'
+apply from: 'gradle-checkstyle.gradle'
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle b/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle
new file mode 100644
index 0000000000..cdcc7f1e23
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/gradle-checkstyle.gradle
@@ -0,0 +1,17 @@
+apply plugin: 'checkstyle'
+
+checkstyle {
+ toolVersion = "7.1.1" // 7.3
+ configFile = "../checkstyle.xml" as File
+}
+
+task checkstyle(type: Checkstyle) {
+ description 'Checks if the code adheres to coding standards'
+ group 'verification'
+ configFile file("../checkstyle.xml")
+ source 'src'
+ include '**/*.java'
+ exclude '**/gen/**'
+ classpath = files()
+ ignoreFailures = false
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java
index 427d7ff21d..38d5297291 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapViewUtils.java
@@ -7,27 +7,27 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
*/
public class MapViewUtils {
- public static void setDirection(MapboxMap mapboxMap, float direction) {
- mapboxMap.getTransform().setBearing(direction);
- }
+ public static void setDirection(MapboxMap mapboxMap, float direction) {
+ mapboxMap.getTransform().setBearing(direction);
+ }
- public static float getDirection(MapboxMap mapboxMap) {
- return (float) mapboxMap.getTransform().getBearing();
- }
+ public static float getDirection(MapboxMap mapboxMap) {
+ return (float) mapboxMap.getTransform().getBearing();
+ }
- public static void setTilt(MapboxMap mapboxMap, float tilt) {
- mapboxMap.getTransform().setTilt((double) tilt);
- }
+ public static void setTilt(MapboxMap mapboxMap, float tilt) {
+ mapboxMap.getTransform().setTilt((double) tilt);
+ }
- public static float getTilt(MapboxMap mapboxMap) {
- return (float) mapboxMap.getTransform().getTilt();
- }
+ public static float getTilt(MapboxMap mapboxMap) {
+ return (float) mapboxMap.getTransform().getTilt();
+ }
- public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) {
- mapboxMap.getTransform().setCenterCoordinate(latLng);
- }
+ public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) {
+ mapboxMap.getTransform().setCenterCoordinate(latLng);
+ }
- public static LatLng getLatLng(MapboxMap mapboxMap) {
- return mapboxMap.getTransform().getCenterCoordinate();
- }
+ public static LatLng getLatLng(MapboxMap mapboxMap) {
+ return mapboxMap.getTransform().getCenterCoordinate();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
index 347113ce34..330de1e9c8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
@@ -54,770 +54,773 @@ import static org.junit.Assert.assertTrue;
*/
public class MapboxMapTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
- private EspressoTestActivity activity;
-
- @Before
- public void beforeTest() {
- activity = rule.getActivity();
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- idlingResource = new OnMapReadyIdlingResource(activity);
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testSanity() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = activity.getMapboxMap();
- assertNotNull("mapboxMap should not be null", mapboxMap);
- }
-
- //
- // MinZoomLevel
- //
-
- @Test
- public void testMinZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.setMinZoomPreference(10);
- assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10);
- }
- }));
- }
-
- @Test
- public void testMaxZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- final double zoom = 10;
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.setMaxZoomPreference(zoom);
- assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10);
- }
- }));
- }
-
- @Test
- public void testInitialZoomLevels() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(), TestConstants.ZOOM_DELTA);
- assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(), TestConstants.ZOOM_DELTA);
- }
- }));
- }
-
- //
- // TrackingSettings
- //
-
- @Test
- public void testTrackingSettings() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = activity.getMapboxMap();
- assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings());
- }
-
- //
- // InfoWindow
- //
-
- @Test
- public void testConcurrentInfoWindowEnabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
- assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
- }
- }));
- }
-
- @Test
- public void testConcurrentInfoWindowDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false);
- assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
- }
- }));
- }
-
- @Test
- public void testInfoWindowAdapter() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MapboxMap.InfoWindowAdapter infoWindowAdapter = new MapboxMap.InfoWindowAdapter() {
- @Nullable
- @Override
- public View getInfoWindow(@NonNull Marker marker) {
- return null;
- }
- };
- mapboxMap.setInfoWindowAdapter(infoWindowAdapter);
- assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter());
- }
- }));
- }
-
- //
- // Location
- //
-
- @Test
- @Ignore /* disabled due to enabling permissions during test #7177 */
- public void testMyLocationEnabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.setMyLocationEnabled(true);
- assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled());
- }
- }));
- }
-
- @Test
- @Ignore /* can't create handler inside thread that not called Looper.prepare() */
- public void testMyLocationDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.setMyLocationEnabled(false);
- assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled());
- }
- }));
- }
-
- //
- // setters/getters interfaces
- //
-
- @Test
- public void testFpsListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MapboxMap.OnFpsChangedListener fpsChangedListener = new MapboxMap.OnFpsChangedListener() {
- @Override
- public void onFpsChanged(double fps) {
-
- }
- };
- mapboxMap.setOnFpsChangedListener(fpsChangedListener);
- assertEquals("FpsListener should match", fpsChangedListener, mapboxMap.getOnFpsChangedListener());
- }
- }));
- }
-
- @Test
- public void testInfoWindowClickListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MapboxMap.OnInfoWindowClickListener clickListener = new MapboxMap.OnInfoWindowClickListener() {
- @Override
- public boolean onInfoWindowClick(@NonNull Marker marker) {
- return false;
- }
- };
- mapboxMap.setOnInfoWindowClickListener(clickListener);
- assertEquals("InfoWidowClickListener should match", clickListener, mapboxMap.getOnInfoWindowClickListener());
- }
- }));
- }
-
- @Test
- public void testInfoWindowCloseListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MapboxMap.OnInfoWindowCloseListener listener = new MapboxMap.OnInfoWindowCloseListener() {
- @Override
- public void onInfoWindowClose(Marker marker) {
-
- }
- };
- mapboxMap.setOnInfoWindowCloseListener(listener);
- assertEquals("InfoWindowCloseListener should match", listener, mapboxMap.getOnInfoWindowCloseListener());
- }
- }));
- }
-
- @Test
- public void testInfoWindowLongClickListener() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MapboxMap.OnInfoWindowLongClickListener listener = new MapboxMap.OnInfoWindowLongClickListener() {
- @Override
- public void onInfoWindowLongClick(Marker marker) {
-
- }
- };
- mapboxMap.setOnInfoWindowLongClickListener(listener);
- assertEquals("InfoWindowLongClickListener should match", listener, mapboxMap.getOnInfoWindowLongClickListener());
- }
- }));
- }
-
- //
- // Annotations
- //
-
- @Test
- public void testAddMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker marker = mapboxMap.addMarker(markerOptions);
- assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker));
- }
- }));
- }
-
- @Test(expected = InvalidMarkerPositionException.class)
- public void testAddMarkerInvalidPosition() {
- new MarkerOptions().getMarker();
- }
-
- @Test
- public void testAddMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a");
- MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b");
- markerList.add(markerOptions1);
- markerList.add(markerOptions2);
- List<Marker> markers = mapboxMap.addMarkers(markerList);
- assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size());
- assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
- assertTrue(mapboxMap.getMarkers().contains(markers.get(1)));
- }
- }));
- }
-
- @Test
- public void testAddMarkersEmpty() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- mapboxMap.addMarkers(markerList);
- assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size());
- }
- }));
- }
-
- @Test
- public void testAddMarkersSingleMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng());
- markerList.add(markerOptions);
- List<Marker> markers = mapboxMap.addMarkers(markerList);
- assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size());
- assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
- }
- }));
- }
-
- @Test
- public void testAddPolygon() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng());
- Polygon polygon = mapboxMap.addPolygon(polygonOptions);
- assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon));
- }
- }));
- }
-
- @Test
- public void testAddEmptyPolygon() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- PolygonOptions polygonOptions = new PolygonOptions();
- Polygon polygon = mapboxMap.addPolygon(polygonOptions);
- assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon));
- }
- }));
- }
-
- @Test
- public void testAddPolygons() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<PolygonOptions> polygonList = new ArrayList<>();
- PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
- PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng());
- PolygonOptions polygonOptions3 = new PolygonOptions();
- polygonList.add(polygonOptions1);
- polygonList.add(polygonOptions2);
- polygonList.add(polygonOptions3);
- mapboxMap.addPolygons(polygonList);
- assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size());
- assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon()));
- assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon()));
- assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon()));
- }
- }));
- }
-
- @Test
- public void addPolygonsEmpty() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.addPolygons(new ArrayList<PolygonOptions>());
- assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size());
- }
- }));
- }
-
- @Test
- public void addPolygonsSingle() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<PolygonOptions> polygonList = new ArrayList<>();
- PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
- polygonList.add(polygonOptions);
- mapboxMap.addPolygons(polygonList);
- assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size());
- assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon()));
- }
- }));
- }
-
- @Test
- public void testAddPolyline() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng());
- Polyline polyline = mapboxMap.addPolyline(polylineOptions);
- assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline));
- }
- }));
- }
-
- @Test
- public void testAddEmptyPolyline() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- PolylineOptions polylineOptions = new PolylineOptions();
- Polyline polyline = mapboxMap.addPolyline(polylineOptions);
- assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline));
- }
- }));
- }
-
- @Test
- public void testAddPolylines() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<PolylineOptions> polylineList = new ArrayList<>();
- PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng());
- PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng());
- PolylineOptions polygonOptions3 = new PolylineOptions();
- polylineList.add(polygonOptions1);
- polylineList.add(polygonOptions2);
- polylineList.add(polygonOptions3);
- mapboxMap.addPolylines(polylineList);
- assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size());
- assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline()));
- assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline()));
- assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline()));
- }
- }));
- }
-
- @Test
- public void testAddPolylinesEmpty() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- mapboxMap.addPolylines(new ArrayList<PolylineOptions>());
- assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size());
- }
- }));
- }
-
- @Test
- public void testAddPolylinesSingle() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<PolylineOptions> polylineList = new ArrayList<>();
- PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng());
- polylineList.add(polygonOptions);
- mapboxMap.addPolylines(polylineList);
- assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size());
- assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline()));
- }
- }));
- }
-
- @Test
- public void testRemoveMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker marker = mapboxMap.addMarker(markerOptions);
- mapboxMap.removeMarker(marker);
- assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty());
- }
- }));
- }
-
- @Test
- public void testRemovePolygon() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- PolygonOptions polygonOptions = new PolygonOptions();
- Polygon polygon = mapboxMap.addPolygon(polygonOptions);
- mapboxMap.removePolygon(polygon);
- assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty());
- }
- }));
- }
-
- @Test
- public void testRemovePolyline() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- PolylineOptions polylineOptions = new PolylineOptions();
- Polyline polyline = mapboxMap.addPolyline(polylineOptions);
- mapboxMap.removePolyline(polyline);
- assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty());
- }
- }));
- }
-
- @Test
- public void testRemoveAnnotation() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker marker = mapboxMap.addMarker(markerOptions);
- mapboxMap.removeAnnotation(marker);
- assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
- }
- }));
- }
-
- @Test
- public void testRemoveAnnotationById() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- mapboxMap.addMarker(markerOptions);
- // id will always be 0 in unit tests
- mapboxMap.removeAnnotation(0);
- assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
- }
- }));
- }
-
- @Test
- public void testRemoveAnnotations() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
- MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
- markerList.add(markerOptions1);
- markerList.add(markerOptions2);
- mapboxMap.addMarkers(markerList);
- mapboxMap.removeAnnotations();
- assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
- }
- }));
- }
-
- @Test
- public void testClear() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
- MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
- markerList.add(markerOptions1);
- markerList.add(markerOptions2);
- mapboxMap.addMarkers(markerList);
- mapboxMap.clear();
- assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
- }
- }));
- }
-
- @Test
- public void testRemoveAnnotationsByList() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
- MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
- markerList.add(markerOptions1);
- markerList.add(markerOptions2);
- List<Marker> markers = mapboxMap.addMarkers(markerList);
- Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c"));
- mapboxMap.removeAnnotations(markers);
- assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1);
- assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker));
- }
- }));
- }
-
- @Test
- public void testGetAnnotationById() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker initialMarker = mapboxMap.addMarker(markerOptions);
- Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0);
- assertEquals("Markers should match", initialMarker, retrievedMarker);
- }
- }));
- }
-
- @Test
- public void testGetAnnotations() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- assertNotNull("Annotations should be non null", mapboxMap.getAnnotations());
- }
- }));
- }
-
- @Test
- public void testGetMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- assertNotNull("Markers should be non null", mapboxMap.getMarkers());
- }
- }));
- }
-
- @Test
- public void testGetPolygons() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- assertNotNull("Polygons should be non null", mapboxMap.getPolygons());
- }
- }));
- }
-
- @Test
- public void testGetPolylines() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- assertNotNull("Polylines should be non null", mapboxMap.getPolylines());
- }
- }));
- }
-
- @Test
- public void testGetSelectedMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers());
- }
- }));
- }
-
- @Test
- public void testSelectMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker marker = mapboxMap.addMarker(markerOptions);
- mapboxMap.selectMarker(marker);
- assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker));
- }
- }));
- }
-
- @Test
- public void testDeselectMarker() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker marker = mapboxMap.addMarker(markerOptions);
- mapboxMap.selectMarker(marker);
- mapboxMap.deselectMarker(marker);
- assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
- }
- }));
- }
-
- @Test
- public void testDeselectMarkers() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = activity.getMapboxMap();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
- @Override
- public void onViewAction(UiController uiController, View view) {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- Marker marker1 = mapboxMap.addMarker(markerOptions);
- Marker marker2 = mapboxMap.addMarker(markerOptions);
- mapboxMap.selectMarker(marker1);
- mapboxMap.selectMarker(marker2);
- mapboxMap.deselectMarkers();
- assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
- }
- }));
- }
-
- @After
- public void afterTest() {
- Timber.e("@After test: unregister idle resource");
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private class MapboxMapAction implements ViewAction{
-
- private InvokeViewAction invokeViewAction;
-
- MapboxMapAction(InvokeViewAction invokeViewAction) {
- this.invokeViewAction = invokeViewAction;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- invokeViewAction.onViewAction(uiController, view);
- }
- }
-
- interface InvokeViewAction {
- void onViewAction(UiController uiController, View view);
- }
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+ private EspressoTestActivity activity;
+
+ @Before
+ public void beforeTest() {
+ activity = rule.getActivity();
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ idlingResource = new OnMapReadyIdlingResource(activity);
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testSanity() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = activity.getMapboxMap();
+ assertNotNull("mapboxMap should not be null", mapboxMap);
+ }
+
+ //
+ // MinZoomLevel
+ //
+
+ @Test
+ public void testMinZoom() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.setMinZoomPreference(10);
+ assertEquals("MinZoom should match", 10, mapboxMap.getMinZoomLevel(), 10);
+ }
+ }));
+ }
+
+ @Test
+ public void testMaxZoom() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ final double zoom = 10;
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.setMaxZoomPreference(zoom);
+ assertEquals("MaxZoom should match", zoom, mapboxMap.getMaxZoomLevel(), 10);
+ }
+ }));
+ }
+
+ @Test
+ public void testInitialZoomLevels() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ assertEquals("MaxZoom should match", MapboxConstants.MAXIMUM_ZOOM, mapboxMap.getMaxZoomLevel(),
+ TestConstants.ZOOM_DELTA);
+ assertEquals("MinZoom should match", MapboxConstants.MINIMUM_ZOOM, mapboxMap.getMinZoomLevel(),
+ TestConstants.ZOOM_DELTA);
+ }
+ }));
+ }
+
+ //
+ // TrackingSettings
+ //
+
+ @Test
+ public void testTrackingSettings() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = activity.getMapboxMap();
+ assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings());
+ }
+
+ //
+ // InfoWindow
+ //
+
+ @Test
+ public void testConcurrentInfoWindowEnabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
+ assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
+ }
+ }));
+ }
+
+ @Test
+ public void testConcurrentInfoWindowDisabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false);
+ assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
+ }
+ }));
+ }
+
+ @Test
+ public void testInfoWindowAdapter() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MapboxMap.InfoWindowAdapter infoWindowAdapter = new MapboxMap.InfoWindowAdapter() {
+ @Nullable
+ @Override
+ public View getInfoWindow(@NonNull Marker marker) {
+ return null;
+ }
+ };
+ mapboxMap.setInfoWindowAdapter(infoWindowAdapter);
+ assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter());
+ }
+ }));
+ }
+
+ //
+ // Location
+ //
+
+ @Test
+ @Ignore /* disabled due to enabling permissions during test #7177 */
+ public void testMyLocationEnabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.setMyLocationEnabled(true);
+ assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled());
+ }
+ }));
+ }
+
+ @Test
+ @Ignore /* can't create handler inside thread that not called Looper.prepare() */
+ public void testMyLocationDisabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.setMyLocationEnabled(false);
+ assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled());
+ }
+ }));
+ }
+
+ //
+ // setters/getters interfaces
+ //
+
+ @Test
+ public void testFpsListener() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MapboxMap.OnFpsChangedListener fpsChangedListener = new MapboxMap.OnFpsChangedListener() {
+ @Override
+ public void onFpsChanged(double fps) {
+
+ }
+ };
+ mapboxMap.setOnFpsChangedListener(fpsChangedListener);
+ assertEquals("FpsListener should match", fpsChangedListener, mapboxMap.getOnFpsChangedListener());
+ }
+ }));
+ }
+
+ @Test
+ public void testInfoWindowClickListener() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MapboxMap.OnInfoWindowClickListener clickListener = new MapboxMap.OnInfoWindowClickListener() {
+ @Override
+ public boolean onInfoWindowClick(@NonNull Marker marker) {
+ return false;
+ }
+ };
+ mapboxMap.setOnInfoWindowClickListener(clickListener);
+ assertEquals("InfoWidowClickListener should match", clickListener, mapboxMap.getOnInfoWindowClickListener());
+ }
+ }));
+ }
+
+ @Test
+ public void testInfoWindowCloseListener() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MapboxMap.OnInfoWindowCloseListener listener = new MapboxMap.OnInfoWindowCloseListener() {
+ @Override
+ public void onInfoWindowClose(Marker marker) {
+
+ }
+ };
+ mapboxMap.setOnInfoWindowCloseListener(listener);
+ assertEquals("InfoWindowCloseListener should match", listener, mapboxMap.getOnInfoWindowCloseListener());
+ }
+ }));
+ }
+
+ @Test
+ public void testInfoWindowLongClickListener() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MapboxMap.OnInfoWindowLongClickListener listener = new MapboxMap.OnInfoWindowLongClickListener() {
+ @Override
+ public void onInfoWindowLongClick(Marker marker) {
+
+ }
+ };
+ mapboxMap.setOnInfoWindowLongClickListener(listener);
+ assertEquals("InfoWindowLongClickListener should match", listener,
+ mapboxMap.getOnInfoWindowLongClickListener());
+ }
+ }));
+ }
+
+ //
+ // Annotations
+ //
+
+ @Test
+ public void testAddMarker() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker marker = mapboxMap.addMarker(markerOptions);
+ assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker));
+ }
+ }));
+ }
+
+ @Test(expected = InvalidMarkerPositionException.class)
+ public void testAddMarkerInvalidPosition() {
+ new MarkerOptions().getMarker();
+ }
+
+ @Test
+ public void testAddMarkers() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<BaseMarkerOptions> markerList = new ArrayList<>();
+ MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a");
+ MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b");
+ markerList.add(markerOptions1);
+ markerList.add(markerOptions2);
+ List<Marker> markers = mapboxMap.addMarkers(markerList);
+ assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size());
+ assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
+ assertTrue(mapboxMap.getMarkers().contains(markers.get(1)));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddMarkersEmpty() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<BaseMarkerOptions> markerList = new ArrayList<>();
+ mapboxMap.addMarkers(markerList);
+ assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size());
+ }
+ }));
+ }
+
+ @Test
+ public void testAddMarkersSingleMarker() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<BaseMarkerOptions> markerList = new ArrayList<>();
+ MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng());
+ markerList.add(markerOptions);
+ List<Marker> markers = mapboxMap.addMarkers(markerList);
+ assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size());
+ assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddPolygon() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng());
+ Polygon polygon = mapboxMap.addPolygon(polygonOptions);
+ assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddEmptyPolygon() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ PolygonOptions polygonOptions = new PolygonOptions();
+ Polygon polygon = mapboxMap.addPolygon(polygonOptions);
+ assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddPolygons() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<PolygonOptions> polygonList = new ArrayList<>();
+ PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
+ PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng());
+ PolygonOptions polygonOptions3 = new PolygonOptions();
+ polygonList.add(polygonOptions1);
+ polygonList.add(polygonOptions2);
+ polygonList.add(polygonOptions3);
+ mapboxMap.addPolygons(polygonList);
+ assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size());
+ assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon()));
+ assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon()));
+ assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon()));
+ }
+ }));
+ }
+
+ @Test
+ public void addPolygonsEmpty() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.addPolygons(new ArrayList<PolygonOptions>());
+ assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size());
+ }
+ }));
+ }
+
+ @Test
+ public void addPolygonsSingle() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<PolygonOptions> polygonList = new ArrayList<>();
+ PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
+ polygonList.add(polygonOptions);
+ mapboxMap.addPolygons(polygonList);
+ assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size());
+ assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon()));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddPolyline() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng());
+ Polyline polyline = mapboxMap.addPolyline(polylineOptions);
+ assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddEmptyPolyline() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ PolylineOptions polylineOptions = new PolylineOptions();
+ Polyline polyline = mapboxMap.addPolyline(polylineOptions);
+ assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddPolylines() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<PolylineOptions> polylineList = new ArrayList<>();
+ PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng());
+ PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng());
+ PolylineOptions polygonOptions3 = new PolylineOptions();
+ polylineList.add(polygonOptions1);
+ polylineList.add(polygonOptions2);
+ polylineList.add(polygonOptions3);
+ mapboxMap.addPolylines(polylineList);
+ assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size());
+ assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline()));
+ assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline()));
+ assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline()));
+ }
+ }));
+ }
+
+ @Test
+ public void testAddPolylinesEmpty() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ mapboxMap.addPolylines(new ArrayList<PolylineOptions>());
+ assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size());
+ }
+ }));
+ }
+
+ @Test
+ public void testAddPolylinesSingle() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<PolylineOptions> polylineList = new ArrayList<>();
+ PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng());
+ polylineList.add(polygonOptions);
+ mapboxMap.addPolylines(polylineList);
+ assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size());
+ assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline()));
+ }
+ }));
+ }
+
+ @Test
+ public void testRemoveMarker() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker marker = mapboxMap.addMarker(markerOptions);
+ mapboxMap.removeMarker(marker);
+ assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testRemovePolygon() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ PolygonOptions polygonOptions = new PolygonOptions();
+ Polygon polygon = mapboxMap.addPolygon(polygonOptions);
+ mapboxMap.removePolygon(polygon);
+ assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testRemovePolyline() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ PolylineOptions polylineOptions = new PolylineOptions();
+ Polyline polyline = mapboxMap.addPolyline(polylineOptions);
+ mapboxMap.removePolyline(polyline);
+ assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testRemoveAnnotation() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker marker = mapboxMap.addMarker(markerOptions);
+ mapboxMap.removeAnnotation(marker);
+ assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testRemoveAnnotationById() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ mapboxMap.addMarker(markerOptions);
+ // id will always be 0 in unit tests
+ mapboxMap.removeAnnotation(0);
+ assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testRemoveAnnotations() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<BaseMarkerOptions> markerList = new ArrayList<>();
+ MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
+ MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
+ markerList.add(markerOptions1);
+ markerList.add(markerOptions2);
+ mapboxMap.addMarkers(markerList);
+ mapboxMap.removeAnnotations();
+ assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testClear() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<BaseMarkerOptions> markerList = new ArrayList<>();
+ MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
+ MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
+ markerList.add(markerOptions1);
+ markerList.add(markerOptions2);
+ mapboxMap.addMarkers(markerList);
+ mapboxMap.clear();
+ assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testRemoveAnnotationsByList() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ List<BaseMarkerOptions> markerList = new ArrayList<>();
+ MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
+ MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
+ markerList.add(markerOptions1);
+ markerList.add(markerOptions2);
+ List<Marker> markers = mapboxMap.addMarkers(markerList);
+ Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c"));
+ mapboxMap.removeAnnotations(markers);
+ assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1);
+ assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker));
+ }
+ }));
+ }
+
+ @Test
+ public void testGetAnnotationById() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker initialMarker = mapboxMap.addMarker(markerOptions);
+ Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0);
+ assertEquals("Markers should match", initialMarker, retrievedMarker);
+ }
+ }));
+ }
+
+ @Test
+ public void testGetAnnotations() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ assertNotNull("Annotations should be non null", mapboxMap.getAnnotations());
+ }
+ }));
+ }
+
+ @Test
+ public void testGetMarkers() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ assertNotNull("Markers should be non null", mapboxMap.getMarkers());
+ }
+ }));
+ }
+
+ @Test
+ public void testGetPolygons() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ assertNotNull("Polygons should be non null", mapboxMap.getPolygons());
+ }
+ }));
+ }
+
+ @Test
+ public void testGetPolylines() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ assertNotNull("Polylines should be non null", mapboxMap.getPolylines());
+ }
+ }));
+ }
+
+ @Test
+ public void testGetSelectedMarkers() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers());
+ }
+ }));
+ }
+
+ @Test
+ public void testSelectMarker() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker marker = mapboxMap.addMarker(markerOptions);
+ mapboxMap.selectMarker(marker);
+ assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker));
+ }
+ }));
+ }
+
+ @Test
+ public void testDeselectMarker() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker marker = mapboxMap.addMarker(markerOptions);
+ mapboxMap.selectMarker(marker);
+ mapboxMap.deselectMarker(marker);
+ assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
+ }
+ }));
+ }
+
+ @Test
+ public void testDeselectMarkers() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = activity.getMapboxMap();
+ onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() {
+ @Override
+ public void onViewAction(UiController uiController, View view) {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ Marker marker1 = mapboxMap.addMarker(markerOptions);
+ Marker marker2 = mapboxMap.addMarker(markerOptions);
+ mapboxMap.selectMarker(marker1);
+ mapboxMap.selectMarker(marker2);
+ mapboxMap.deselectMarkers();
+ assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
+ }
+ }));
+ }
+
+ @After
+ public void afterTest() {
+ Timber.e("@After test: unregister idle resource");
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class MapboxMapAction implements ViewAction {
+
+ private InvokeViewAction invokeViewAction;
+
+ MapboxMapAction(InvokeViewAction invokeViewAction) {
+ this.invokeViewAction = invokeViewAction;
+ }
+
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
+
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ invokeViewAction.onViewAction(uiController, view);
+ }
+ }
+
+ interface InvokeViewAction {
+ void onViewAction(UiController uiController, View view);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
index 44a98ad664..2f51140cd1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
@@ -4,6 +4,7 @@ import android.app.Activity;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResourceTimeoutException;
import android.support.test.rule.ActivityTestRule;
+
import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -22,49 +23,50 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
public abstract class BaseActivityTest {
- @Rule
- public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
- protected MapboxMap mapboxMap;
- protected OnMapReadyIdlingResource idlingResource;
+ @Rule
+ public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
+ protected MapboxMap mapboxMap;
+ protected OnMapReadyIdlingResource idlingResource;
- @Before
- public void beforeTest() {
- try {
- Timber.e("@Before test: register idle resource");
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- checkViewIsDisplayed(R.id.mapView);
- mapboxMap = idlingResource.getMapboxMap();
- } catch (IdlingResourceTimeoutException e) {
- Timber.e("Idling resource timed out. Couldn't not validate if map is ready.");
- throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n" +
- "The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n" +
- "the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n" +
- "You can resolve this issue be implementing the requirements above or\n add " + getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n");
- }
+ @Before
+ public void beforeTest() {
+ try {
+ Timber.e("@Before test: register idle resource");
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ checkViewIsDisplayed(R.id.mapView);
+ mapboxMap = idlingResource.getMapboxMap();
+ } catch (IdlingResourceTimeoutException idlingResourceTimeoutException) {
+ Timber.e("Idling resource timed out. Couldn't not validate if map is ready.");
+ throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n"
+ + "The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n"
+ + "the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n"
+ + "You can resolve this issue be implementing the requirements above or\n add "
+ + getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n");
}
+ }
- protected abstract Class getActivityClass();
+ protected abstract Class getActivityClass();
- protected void checkViewIsDisplayed(int id) {
- onView(withId(id))
- .check(matches(isDisplayed()));
- }
+ protected void checkViewIsDisplayed(int id) {
+ onView(withId(id))
+ .check(matches(isDisplayed()));
+ }
- protected void takeScreenshot(final String name) {
- final Activity activity = rule.getActivity();
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ScreenshotUtil.take(activity, name);
- }
- });
- }
+ protected void takeScreenshot(final String name) {
+ final Activity activity = rule.getActivity();
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ScreenshotUtil.take(activity, name);
+ }
+ });
+ }
- @After
- public void afterTest() {
- Timber.e("@After test: unregister idle resource");
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void afterTest() {
+ Timber.e("@After test: unregister idle resource");
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java
index 36e943b7ff..77025c8fa5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerTest.java
@@ -32,111 +32,111 @@ import static org.junit.Assert.assertEquals;
public class MarkerTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
- private Marker marker;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+ private Marker marker;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ @Ignore
+ public void addMarkerTest() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
+
+ MarkerOptions options = new MarkerOptions();
+ options.setPosition(new LatLng());
+ options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
+ options.setTitle(TestConstants.TEXT_MARKER_TITLE);
+
+ onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options));
+ assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size());
+ assertEquals("Marker id should be 0", 0, marker.getId());
+ assertEquals("Marker target should match", new LatLng(), marker.getPosition());
+ assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
+ assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
+ mapboxMap.clear();
+ assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
+ }
+
+ @Test
+ @Ignore
+ public void showInfoWindowTest() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final MarkerOptions options = new MarkerOptions();
+ options.setPosition(new LatLng());
+ options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
+ options.setTitle(TestConstants.TEXT_MARKER_TITLE);
+
+ onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options));
+ onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap));
+ onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
+ onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
+ }
+
+ private class AddMarkerAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private MarkerOptions options;
+
+ AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) {
+ mapboxMap = map;
+ options = markerOptions;
}
- @Test
- @Ignore
- public void addMarkerTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
-
- MarkerOptions options = new MarkerOptions();
- options.setPosition(new LatLng());
- options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
- options.setTitle(TestConstants.TEXT_MARKER_TITLE);
-
- onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options));
- assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size());
- assertEquals("Marker id should be 0", 0, marker.getId());
- assertEquals("Marker target should match", new LatLng(), marker.getPosition());
- assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
- assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
- mapboxMap.clear();
- assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- @Ignore
- public void showInfoWindowTest(){
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final MarkerOptions options = new MarkerOptions();
- options.setPosition(new LatLng());
- options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
- options.setTitle(TestConstants.TEXT_MARKER_TITLE);
-
- onView(withId(R.id.mapView)).perform(new AddMarkerAction(mapboxMap, options));
- onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap));
- onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
- onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- private class AddMarkerAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private MarkerOptions options;
-
- AddMarkerAction(MapboxMap map, MarkerOptions markerOptions) {
- mapboxMap = map;
- options = markerOptions;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- marker = mapboxMap.addMarker(options);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ marker = mapboxMap.addMarker(options);
}
+ }
- private class ShowInfoWindowAction implements ViewAction {
+ private class ShowInfoWindowAction implements ViewAction {
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- ShowInfoWindowAction(MapboxMap map) {
- mapboxMap = map;
- }
+ ShowInfoWindowAction(MapboxMap map) {
+ mapboxMap = map;
+ }
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.selectMarker(marker);
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.selectMarker(marker);
- }
}
+ }
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java
index 09f707c4b5..9351ed1c10 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java
@@ -33,114 +33,115 @@ import static org.junit.Assert.assertEquals;
public class MarkerViewTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
- private Marker marker;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+ private Marker marker;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ @Ignore
+ public void addMarkerViewTest() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
+
+ TextMarkerViewOptions options = new TextMarkerViewOptions();
+ options.text(TestConstants.TEXT_MARKER_TEXT);
+ options.position(new LatLng());
+ options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
+ options.title(TestConstants.TEXT_MARKER_TITLE);
+
+ onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options));
+ assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size());
+ assertEquals("Marker id should be 0", 0, marker.getId());
+ assertEquals("Marker target should match", new LatLng(), marker.getPosition());
+ assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
+ assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
+ onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
+ }
+
+ @Test
+ @Ignore
+ public void showInfoWindowTest() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final TextMarkerViewOptions options = new TextMarkerViewOptions();
+ options.position(new LatLng());
+ options.text(TestConstants.TEXT_MARKER_TEXT);
+ options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
+ options.title(TestConstants.TEXT_MARKER_TITLE);
+
+ onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options));
+ onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
+ onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap));
+ onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
+ onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
+ }
+
+ private class AddTextMarkerViewAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private TextMarkerViewOptions options;
+
+ AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) {
+ mapboxMap = map;
+ options = markerOptions;
}
- @Test
- @Ignore
- public void addMarkerViewTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
-
- TextMarkerViewOptions options = new TextMarkerViewOptions();
- options.text(TestConstants.TEXT_MARKER_TEXT);
- options.position(new LatLng());
- options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
- options.title(TestConstants.TEXT_MARKER_TITLE);
-
- onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options));
- assertEquals("Markers sze should be 1, ", 1, mapboxMap.getMarkers().size());
- assertEquals("Marker id should be 0", 0, marker.getId());
- assertEquals("Marker target should match", new LatLng(), marker.getPosition());
- assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
- assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
- onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- @Ignore
- public void showInfoWindowTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final TextMarkerViewOptions options = new TextMarkerViewOptions();
- options.position(new LatLng());
- options.text(TestConstants.TEXT_MARKER_TEXT);
- options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
- options.title(TestConstants.TEXT_MARKER_TITLE);
-
- onView(withId(R.id.mapView)).perform(new AddTextMarkerViewAction(mapboxMap, options));
- onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
- onView(withId(R.id.mapView)).perform(new ShowInfoWindowAction(mapboxMap));
- onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
- onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- private class AddTextMarkerViewAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private TextMarkerViewOptions options;
-
- AddTextMarkerViewAction(MapboxMap map, TextMarkerViewOptions markerOptions) {
- mapboxMap = map;
- options = markerOptions;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getMarkerViewManager().addMarkerViewAdapter(new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap));
- marker = mapboxMap.addMarker(options);
- uiController.loopMainThreadForAtLeast(250);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
+ new MarkerViewActivity.TextAdapter(view.getContext(), mapboxMap));
+ marker = mapboxMap.addMarker(options);
+ uiController.loopMainThreadForAtLeast(250);
}
+ }
- private class ShowInfoWindowAction implements ViewAction {
-
- private MapboxMap mapboxMap;
+ private class ShowInfoWindowAction implements ViewAction {
- ShowInfoWindowAction(MapboxMap map) {
- mapboxMap = map;
- }
+ private MapboxMap mapboxMap;
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ ShowInfoWindowAction(MapboxMap map) {
+ mapboxMap = map;
+ }
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.selectMarker(marker);
- uiController.loopMainThreadForAtLeast(250);
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.selectMarker(marker);
+ uiController.loopMainThreadForAtLeast(250);
}
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java
index 366e1851b8..24b9b3bf01 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolygonTest.java
@@ -30,75 +30,76 @@ import static org.junit.Assert.assertEquals;
public class PolygonTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
- private Polygon polygon;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+ private Polygon polygon;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ @Ignore
+ /** native crash **/
+ public void addPolygonTest() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ LatLng latLngOne = new LatLng();
+ LatLng latLngTwo = new LatLng(1, 0);
+ LatLng latLngThree = new LatLng(1, 1);
+
+ assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
+
+ final PolygonOptions options = new PolygonOptions();
+ options.strokeColor(Color.BLUE);
+ options.fillColor(Color.RED);
+ options.add(latLngOne);
+ options.add(latLngTwo);
+ options.add(latLngThree);
+
+ onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options));
+
+ assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
+ assertEquals("Polygon id should be 0", 0, polygon.getId());
+ assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
+ assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
+ assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
+ mapboxMap.clear();
+ assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
+ }
+
+ private class AddPolygonAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private PolygonOptions options;
+
+ AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) {
+ mapboxMap = map;
+ options = polygonOptions;
}
- @Test
- @Ignore /** native crash **/
- public void addPolygonTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- LatLng latLngOne = new LatLng();
- LatLng latLngTwo = new LatLng(1, 0);
- LatLng latLngThree = new LatLng(1, 1);
-
- assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
-
- final PolygonOptions options = new PolygonOptions();
- options.strokeColor(Color.BLUE);
- options.fillColor(Color.RED);
- options.add(latLngOne);
- options.add(latLngTwo);
- options.add(latLngThree);
-
- onView(withId(R.id.mapView)).perform(new AddPolygonAction(mapboxMap, options));
-
- assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
- assertEquals("Polygon id should be 0", 0, polygon.getId());
- assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
- assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
- assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
- mapboxMap.clear();
- assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- private class AddPolygonAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private PolygonOptions options;
-
- AddPolygonAction(MapboxMap map, PolygonOptions polygonOptions) {
- mapboxMap = map;
- options = polygonOptions;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- polygon = mapboxMap.addPolygon(options);
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
+ @Override
+ public void perform(UiController uiController, View view) {
+ polygon = mapboxMap.addPolygon(options);
}
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java
index eb273b8cf9..607a4ad263 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/PolylineTest.java
@@ -30,71 +30,71 @@ import static org.junit.Assert.assertEquals;
public class PolylineTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
- private Polyline polyline;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+ private Polyline polyline;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Ignore
+ @Test
+ public void addPolylineTest() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ LatLng latLngOne = new LatLng();
+ LatLng latLngTwo = new LatLng(1, 0);
+
+ assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
+
+ final PolylineOptions options = new PolylineOptions();
+ options.color(Color.BLUE);
+ options.add(latLngOne);
+ options.add(latLngTwo);
+
+ onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options));
+
+ assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
+ assertEquals("Polyline id should be 0", 0, polyline.getId());
+ assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
+ assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
+ mapboxMap.clear();
+ assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
+ }
+
+ private class AddPolyLineAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private PolylineOptions options;
+
+ AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) {
+ mapboxMap = map;
+ options = polylineOptions;
}
- @Ignore
- @Test
- public void addPolylineTest() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- LatLng latLngOne = new LatLng();
- LatLng latLngTwo = new LatLng(1, 0);
-
- assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
-
- final PolylineOptions options = new PolylineOptions();
- options.color(Color.BLUE);
- options.add(latLngOne);
- options.add(latLngTwo);
-
- onView(withId(R.id.mapView)).perform(new AddPolyLineAction(mapboxMap, options));
-
- assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
- assertEquals("Polyline id should be 0", 0, polyline.getId());
- assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
- assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
- mapboxMap.clear();
- assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- private class AddPolyLineAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private PolylineOptions options;
-
- AddPolyLineAction(MapboxMap map, PolylineOptions polylineOptions) {
- mapboxMap = map;
- options = polylineOptions;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- polyline = mapboxMap.addPolyline(options);
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
+ @Override
+ public void perform(UiController uiController, View view) {
+ polyline = mapboxMap.addPolyline(options);
}
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java
index 73e3c8559f..5ead54eb7b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java
@@ -10,7 +10,6 @@ import android.view.View;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -33,206 +32,222 @@ import static org.junit.Assert.assertEquals;
public class CameraAnimateTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testAnimateToCameraPositionTarget() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO remove zoom #6474*/
- float zoom = 1.0f;
- LatLng moveTarget = new LatLng(1, 1);
-
- CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Default camera position should match default", cameraPosition, initialPosition);
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
- cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- }
-
- @Test
- public void testAnimateToCameraPositionTargetZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final float moveZoom = 15.5f;
- final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testAnimateToCameraPosition() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
- final float moveZoom = 15.5f;
- final float moveTilt = 45.5f;
- final float moveBearing = 12.5f;
-
- onView(withId(R.id.mapView)).perform(
- new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(moveTarget)
- .zoom(moveZoom)
- .tilt(moveTilt)
- .bearing(moveBearing)
- .build()))
- );
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
- assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
- }
-
- @Test
- public void testAnimateToBounds() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final LatLng centerBounds = new LatLng(1, 1);
- LatLng cornerOne = new LatLng();
- LatLng cornerTwo = new LatLng(2, 2);
-
- final LatLngBounds.Builder builder = new LatLngBounds.Builder();
- builder.include(cornerOne);
- builder.include(cornerTwo);
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match center bounds",
- cameraPosition.target.getLatitude(),
- centerBounds.getLatitude(),
- TestConstants.LAT_LNG_DELTA);
-
- assertEquals("Moved camera position longitude should match center bounds",
- cameraPosition.target.getLongitude(),
- centerBounds.getLongitude(),
- TestConstants.LAT_LNG_DELTA);
- }
-
- @Test
- public void testAnimateToMoveBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
- final LatLng moveTarget = new LatLng(2, 2);
- final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
- moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testAnimateToCameraPositionTarget() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO remove zoom #6474*/
+ float zoom = 1.0f;
+ LatLng moveTarget = new LatLng(1, 1);
+
+ CameraPosition initialPosition = new CameraPosition.Builder().target(
+ new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Default camera position should match default", cameraPosition, initialPosition);
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
+ cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ }
+
+ @Test
+ public void testAnimateToCameraPositionTargetZoom() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final float moveZoom = 15.5f;
+ final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testAnimateToCameraPosition() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
+ final float moveZoom = 15.5f;
+ final float moveTilt = 45.5f;
+ final float moveBearing = 12.5f;
+
+ onView(withId(R.id.mapView)).perform(
+ new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(moveTarget)
+ .zoom(moveZoom)
+ .tilt(moveTilt)
+ .bearing(moveBearing)
+ .build()))
+ );
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
+ assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
+ }
+
+ @Test
+ public void testAnimateToBounds() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final LatLng centerBounds = new LatLng(1, 1);
+ LatLng cornerOne = new LatLng();
+ LatLng cornerTwo = new LatLng(2, 2);
+
+ final LatLngBounds.Builder builder = new LatLngBounds.Builder();
+ builder.include(cornerOne);
+ builder.include(cornerTwo);
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match center bounds",
+ cameraPosition.target.getLatitude(),
+ centerBounds.getLatitude(),
+ TestConstants.LAT_LNG_DELTA);
+
+ assertEquals("Moved camera position longitude should match center bounds",
+ cameraPosition.target.getLongitude(),
+ centerBounds.getLongitude(),
+ TestConstants.LAT_LNG_DELTA);
+ }
+
+ @Test
+ public void testAnimateToMoveBy() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
+ final LatLng moveTarget = new LatLng(2, 2);
+ final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
+ moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ }
+
+ @Test
+ public void testAnimateToZoomIn() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 1.0f;
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testAnimateToZoomOut() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 10.0f;
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testAnimateToZoomBy() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 1.0f;
+ final float zoomBy = 2.45f;
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testAnimateToZoomTo() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ final float zoomTo = 2.45f;
+
+ onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class AnimateCameraAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private CameraUpdate cameraUpdate;
+
+ AnimateCameraAction(MapboxMap map, CameraUpdate update) {
+ mapboxMap = map;
+ cameraUpdate = update;
}
- @Test
- public void testAnimateToZoomIn() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 1.0f;
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA);
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- public void testAnimateToZoomOut() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 10.0f;
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, TestConstants.ZOOM_DELTA);
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @Test
- public void testAnimateToZoomBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 1.0f;
- final float zoomBy = 2.45f;
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testAnimateToZoomTo() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- final float zoomTo = 2.45f;
-
- onView(withId(R.id.mapView)).perform(new AnimateCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA);
- }
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private class AnimateCameraAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private CameraUpdate cameraUpdate;
-
- AnimateCameraAction(MapboxMap map, CameraUpdate update) {
- mapboxMap = map;
- cameraUpdate = update;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.animateCamera(cameraUpdate);
- uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.animateCamera(cameraUpdate);
+ uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java
index 4f27703b18..22af72cebb 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java
@@ -10,7 +10,6 @@ import android.view.View;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -33,206 +32,221 @@ import static org.junit.Assert.assertEquals;
public class CameraEaseTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testEaseToCameraPositionTarget() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO remove zoom #6474*/
- float zoom = 1.0f;
- LatLng moveTarget = new LatLng(1, 1);
-
- CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Default camera position should match default", cameraPosition, initialPosition);
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
- cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- }
-
- @Test
- public void testEaseToCameraPositionTargetZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final float moveZoom = 15.5f;
- final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testEaseToCameraPosition() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
- final float moveZoom = 15.5f;
- final float moveTilt = 45.5f;
- final float moveBearing = 12.5f;
-
- onView(withId(R.id.mapView)).perform(
- new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(moveTarget)
- .zoom(moveZoom)
- .tilt(moveTilt)
- .bearing(moveBearing)
- .build()))
- );
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
- assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
- }
-
- @Test
- public void testEaseToBounds() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final LatLng centerBounds = new LatLng(1, 1);
- LatLng cornerOne = new LatLng();
- LatLng cornerTwo = new LatLng(2, 2);
-
- final LatLngBounds.Builder builder = new LatLngBounds.Builder();
- builder.include(cornerOne);
- builder.include(cornerTwo);
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match center bounds",
- cameraPosition.target.getLatitude(),
- centerBounds.getLatitude(),
- TestConstants.LAT_LNG_DELTA);
-
- assertEquals("Moved camera position longitude should match center bounds",
- cameraPosition.target.getLongitude(),
- centerBounds.getLongitude(),
- TestConstants.LAT_LNG_DELTA);
- }
-
- @Test
- public void testEaseToMoveBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
- final LatLng moveTarget = new LatLng(2, 2);
- final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
- moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testEaseToCameraPositionTarget() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO remove zoom #6474*/
+ float zoom = 1.0f;
+ LatLng moveTarget = new LatLng(1, 1);
+
+ CameraPosition initialPosition = new CameraPosition.Builder().target(
+ new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Default camera position should match default", cameraPosition, initialPosition);
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
+ cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ }
+
+ @Test
+ public void testEaseToCameraPositionTargetZoom() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final float moveZoom = 15.5f;
+ final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testEaseToCameraPosition() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
+ final float moveZoom = 15.5f;
+ final float moveTilt = 45.5f;
+ final float moveBearing = 12.5f;
+
+ onView(withId(R.id.mapView)).perform(
+ new EaseCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(moveTarget)
+ .zoom(moveZoom)
+ .tilt(moveTilt)
+ .bearing(moveBearing)
+ .build()))
+ );
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
+ assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
+ }
+
+ @Test
+ public void testEaseToBounds() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final LatLng centerBounds = new LatLng(1, 1);
+ LatLng cornerOne = new LatLng();
+ LatLng cornerTwo = new LatLng(2, 2);
+
+ final LatLngBounds.Builder builder = new LatLngBounds.Builder();
+ builder.include(cornerOne);
+ builder.include(cornerTwo);
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match center bounds",
+ cameraPosition.target.getLatitude(),
+ centerBounds.getLatitude(),
+ TestConstants.LAT_LNG_DELTA);
+
+ assertEquals("Moved camera position longitude should match center bounds",
+ cameraPosition.target.getLongitude(),
+ centerBounds.getLongitude(),
+ TestConstants.LAT_LNG_DELTA);
+ }
+
+ @Test
+ public void testEaseToMoveBy() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
+ final LatLng moveTarget = new LatLng(2, 2);
+ final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
+ moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ }
+
+ @Test
+ public void testEaseToZoomIn() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 1.0f;
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testEaseToZoomOut() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 10.0f;
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testEaseToZoomBy() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 1.0f;
+ final float zoomBy = 2.45f;
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testEaseToZoomTo() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ final float zoomTo = 2.45f;
+
+ onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class EaseCameraAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private CameraUpdate cameraUpdate;
+
+ EaseCameraAction(MapboxMap map, CameraUpdate update) {
+ mapboxMap = map;
+ cameraUpdate = update;
}
- @Test
- public void testEaseToZoomIn() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 1.0f;
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA);
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- public void testEaseToZoomOut() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 10.0f;
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", 9, cameraPosition.zoom, TestConstants.ZOOM_DELTA);
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @Test
- public void testEaseToZoomBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 1.0f;
- final float zoomBy = 2.45f;
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testEaseToZoomTo() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- final float zoomTo = 2.45f;
-
- onView(withId(R.id.mapView)).perform(new EaseCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA);
- }
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private class EaseCameraAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private CameraUpdate cameraUpdate;
-
- EaseCameraAction(MapboxMap map, CameraUpdate update) {
- mapboxMap = map;
- cameraUpdate = update;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.easeCamera(cameraUpdate);
- uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.easeCamera(cameraUpdate);
+ uiController.loopMainThreadForAtLeast(TestConstants.ANIMATION_TEST_TIME);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java
deleted file mode 100644
index e180ab77b2..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalAPITest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.camera;
-
-import android.support.test.espresso.Espresso;
-import android.support.test.espresso.UiController;
-import android.support.test.espresso.ViewAction;
-import android.support.test.rule.ActivityTestRule;
-import android.view.View;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.MapViewUtils;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
-import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
-import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
-
-import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withId;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests camera transformations that aren't part of our public API
- */
-public class CameraInternalAPITest {
-
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testBearing() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- EspressoTestActivity activity = rule.getActivity();
- MapboxMap mapboxMap = activity.getMapboxMap();
-
- CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build();
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Default camera position should match default", cameraPosition, initialPosition);
-
- onView(withId(R.id.mapView)).perform(new BearingAction(mapboxMap));
- assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA);
- }
-
- @Test
- public void testTilt() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- EspressoTestActivity activity = rule.getActivity();
- MapboxMap mapboxMap = activity.getMapboxMap();
-
- CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build();
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Default camera position should match default", cameraPosition, initialPosition);
-
- onView(withId(R.id.mapView)).perform(new TiltAction(mapboxMap));
- assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA);
- }
-
- @Test
- public void testLatLng() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- EspressoTestActivity activity = rule.getActivity();
- MapboxMap mapboxMap = activity.getMapboxMap();
-
- CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build();
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Default camera position should match default", cameraPosition, initialPosition);
-
- onView(withId(R.id.mapView)).perform(new LatLngAction(mapboxMap));
- LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap);
- assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA);
- }
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private class BearingAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- BearingAction(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- MapViewUtils.setDirection(mapboxMap, -45.1f);
- }
- }
-
- private class TiltAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- TiltAction(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- MapViewUtils.setTilt(mapboxMap, 40.0f);
- }
- }
-
- private class LatLngAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- LatLngAction(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2));
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java
new file mode 100644
index 0000000000..1b40e265d2
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java
@@ -0,0 +1,169 @@
+package com.mapbox.mapboxsdk.testapp.camera;
+
+import android.support.test.espresso.Espresso;
+import android.support.test.espresso.UiController;
+import android.support.test.espresso.ViewAction;
+import android.support.test.rule.ActivityTestRule;
+import android.view.View;
+
+import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapViewUtils;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
+import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
+import com.mapbox.mapboxsdk.testapp.utils.ViewUtils;
+
+import org.hamcrest.Matcher;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests camera transformations that aren't part of our public API
+ */
+public class CameraInternalApiTest {
+
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testBearing() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ EspressoTestActivity activity = rule.getActivity();
+ MapboxMap mapboxMap = activity.getMapboxMap();
+
+ CameraPosition initialPosition = new
+ CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build();
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Default camera position should match default", cameraPosition, initialPosition);
+
+ onView(withId(R.id.mapView)).perform(new BearingAction(mapboxMap));
+ assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA);
+ }
+
+ @Test
+ public void testTilt() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ EspressoTestActivity activity = rule.getActivity();
+ MapboxMap mapboxMap = activity.getMapboxMap();
+
+ CameraPosition initialPosition = new CameraPosition.Builder().target(
+ new LatLng()).zoom(1).bearing(0).tilt(0).build();
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Default camera position should match default", cameraPosition, initialPosition);
+
+ onView(withId(R.id.mapView)).perform(new TiltAction(mapboxMap));
+ assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA);
+ }
+
+ @Test
+ public void testLatLng() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ EspressoTestActivity activity = rule.getActivity();
+ MapboxMap mapboxMap = activity.getMapboxMap();
+
+ CameraPosition initialPosition = new CameraPosition.Builder().target(
+ new LatLng()).zoom(1).bearing(0).tilt(0).build();
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Default camera position should match default", cameraPosition, initialPosition);
+
+ onView(withId(R.id.mapView)).perform(new LatLngAction(mapboxMap));
+ LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap);
+ assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class BearingAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+
+ BearingAction(MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ }
+
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
+
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapViewUtils.setDirection(mapboxMap, -45.1f);
+ }
+ }
+
+ private class TiltAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+
+ TiltAction(MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ }
+
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
+
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapViewUtils.setTilt(mapboxMap, 40.0f);
+ }
+ }
+
+ private class LatLngAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+
+ LatLngAction(MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ }
+
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
+
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2));
+ }
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java
index 80f5dda77e..b3a7fe0d11 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java
@@ -29,209 +29,224 @@ import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
public class CameraMoveTest {
-
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testMoveToCameraPositionTarget() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO remove zoom #6474*/
+ float zoom = 1.0f;
+ LatLng moveTarget = new LatLng(1, 1);
+
+ CameraPosition initialPosition = new CameraPosition.Builder().target(
+ new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Default camera position should match default", cameraPosition, initialPosition);
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
+ cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ }
+
+ @Test
+ public void testMoveToCameraPositionTargetZoom() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final float moveZoom = 15.5f;
+ final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testMoveToCameraPosition() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
+ final float moveZoom = 15.5f;
+ final float moveTilt = 45.5f;
+ final float moveBearing = 12.5f;
+
+ onView(withId(R.id.mapView)).perform(
+ new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(moveTarget)
+ .zoom(moveZoom)
+ .tilt(moveTilt)
+ .bearing(moveBearing)
+ .build()))
+ );
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
+ assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
+ }
+
+ @Test
+ public void testMoveToBounds() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final LatLng centerBounds = new LatLng(1, 1);
+ LatLng cornerOne = new LatLng();
+ LatLng cornerTwo = new LatLng(2, 2);
+
+ final LatLngBounds.Builder builder = new LatLngBounds.Builder();
+ builder.include(cornerOne);
+ builder.include(cornerTwo);
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match center bounds",
+ cameraPosition.target.getLatitude(),
+ centerBounds.getLatitude(),
+ TestConstants.LAT_LNG_DELTA);
+
+ assertEquals("Moved camera position longitude should match center bounds",
+ cameraPosition.target.getLongitude(),
+ centerBounds.getLongitude(),
+ TestConstants.LAT_LNG_DELTA);
+ }
+
+ @Test
+ public void testMoveToMoveBy() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
+ final LatLng moveTarget = new LatLng(2, 2);
+ final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
+ moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
+ moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),
+ moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
+ }
+
+ @Test
+ public void testMoveToZoomIn() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 1.0f;
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testMoveToZoomOut() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 10.0f;
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
+ CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testMoveToZoomBy() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ float zoom = 1.0f;
+ final float zoomBy = 2.45f;
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @Test
+ public void testMoveToZoomTo() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ /*TODO fix zoom #6474*/
+ final float zoomTo = 2.45f;
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo,
+ TestConstants.ZOOM_DELTA);
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class MoveCameraAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private CameraUpdate cameraUpdate;
+
+ MoveCameraAction(MapboxMap map, CameraUpdate update) {
+ mapboxMap = map;
+ cameraUpdate = update;
}
- @Test
- public void testMoveToCameraPositionTarget() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO remove zoom #6474*/
- float zoom = 1.0f;
- LatLng moveTarget = new LatLng(1, 1);
-
- CameraPosition initialPosition = new CameraPosition.Builder().target(new LatLng()).zoom(zoom).bearing(0).tilt(0).build();
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Default camera position should match default", cameraPosition, initialPosition);
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLng(moveTarget)));
- cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- public void testMoveToCameraPositionTargetZoom() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final float moveZoom = 15.5f;
- final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @Test
- public void testMoveToCameraPosition() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
- final float moveZoom = 15.5f;
- final float moveTilt = 45.5f;
- final float moveBearing = 12.5f;
-
- onView(withId(R.id.mapView)).perform(
- new MoveCameraAction(mapboxMap, CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(moveTarget)
- .zoom(moveZoom)
- .tilt(moveTilt)
- .bearing(moveBearing)
- .build()))
- );
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.zoom, moveZoom, TestConstants.ZOOM_DELTA);
- assertEquals("Moved zoom should match", cameraPosition.tilt, moveTilt, TestConstants.TILT_DELTA);
- assertEquals("Moved bearing should match", cameraPosition.bearing, moveBearing, TestConstants.BEARING_DELTA);
- }
-
- @Test
- public void testMoveToBounds() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final LatLng centerBounds = new LatLng(1, 1);
- LatLng cornerOne = new LatLng();
- LatLng cornerTwo = new LatLng(2, 2);
-
- final LatLngBounds.Builder builder = new LatLngBounds.Builder();
- builder.include(cornerOne);
- builder.include(cornerTwo);
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngBounds(builder.build(), 0)));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match center bounds",
- cameraPosition.target.getLatitude(),
- centerBounds.getLatitude(),
- TestConstants.LAT_LNG_DELTA);
-
- assertEquals("Moved camera position longitude should match center bounds",
- cameraPosition.target.getLongitude(),
- centerBounds.getLongitude(),
- TestConstants.LAT_LNG_DELTA);
- }
-
- @Test
- public void testMoveToMoveBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- final PointF centerPoint = mapboxMap.getProjection().toScreenLocation(mapboxMap.getCameraPosition().target);
- final LatLng moveTarget = new LatLng(2, 2);
- final PointF moveTargetPoint = mapboxMap.getProjection().toScreenLocation(moveTarget);
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.scrollBy(
- moveTargetPoint.x - centerPoint.x, moveTargetPoint.y - centerPoint.y)));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(), moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA_LARGE);
- assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(), moveTarget.getLongitude(), TestConstants.LAT_LNG_DELTA_LARGE);
- }
-
- @Test
- public void testMoveToZoomIn() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 1.0f;
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomIn()));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + 1, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testMoveToZoomOut() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 10.0f;
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom)));
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomOut()));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom - 1, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testMoveToZoomBy() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- float zoom = 1.0f;
- final float zoomBy = 2.45f;
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomBy(zoomBy)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoom + zoomBy, TestConstants.ZOOM_DELTA);
- }
-
- @Test
- public void testMoveToZoomTo() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- final MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- /*TODO fix zoom #6474*/
- final float zoomTo = 2.45f;
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap, CameraUpdateFactory.zoomTo(zoomTo)));
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Moved camera zoom should match moved camera zoom", cameraPosition.zoom, zoomTo, TestConstants.ZOOM_DELTA);
- }
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private class MoveCameraAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private CameraUpdate cameraUpdate;
-
- MoveCameraAction(MapboxMap map, CameraUpdate update) {
- mapboxMap = map;
- cameraUpdate = update;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.moveCamera(cameraUpdate);
- uiController.loopMainThreadForAtLeast(100);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.moveCamera(cameraUpdate);
+ uiController.loopMainThreadForAtLeast(100);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java
index 7ee5c04e4a..b4be73be7a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java
@@ -29,32 +29,33 @@ import static org.hamcrest.Matchers.not;
*/
public class QueryRenderedFeaturesBoxCountTest {
- @Rule
- public final ActivityTestRule<QueryRenderedFeaturesBoxCountActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- @Ignore
- public void testCountFeatures() {
- // click on box to query map
- onView(withId(R.id.selection_box)).perform(click());
-
- // validate if toast is shown
- onView(withText("149 features in box"))
- .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
- .check(matches(isDisplayed()));
- }
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @Rule
+ public final ActivityTestRule<QueryRenderedFeaturesBoxCountActivity> rule =
+ new ActivityTestRule<>(QueryRenderedFeaturesBoxCountActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ @Ignore
+ public void testCountFeatures() {
+ // click on box to query map
+ onView(withId(R.id.selection_box)).perform(click());
+
+ // validate if toast is shown
+ onView(withText("149 features in box"))
+ .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
+ .check(matches(isDisplayed()));
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java
index 30cabd9753..b8cd46e612 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java
@@ -34,47 +34,48 @@ import static org.hamcrest.Matchers.not;
*/
public class QueryRenderedFeaturesHighlightTest {
- @Rule
- public final ActivityTestRule<QueryRenderedFeaturesBoxHighlightActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class);
+ @Rule
+ public final ActivityTestRule<QueryRenderedFeaturesBoxHighlightActivity> rule =
+ new ActivityTestRule<>(QueryRenderedFeaturesBoxHighlightActivity.class);
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- @Ignore
- public void testCountFeatures() {
- // click on box to query map
- onView(withId(R.id.selection_box)).perform(click());
+ @Test
+ @Ignore
+ public void testCountFeatures() {
+ // click on box to query map
+ onView(withId(R.id.selection_box)).perform(click());
- // validate if toast is shown
- onView(withText("50 features in box"))
- .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
- .check(matches(isDisplayed()));
- }
+ // validate if toast is shown
+ onView(withText("50 features in box"))
+ .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
+ .check(matches(isDisplayed()));
+ }
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
- private static ViewAction clickXY(final float x, final float y) {
- return new GeneralClickAction(
- Tap.SINGLE,
- new CoordinatesProvider() {
- @Override
- public float[] calculateCoordinates(View view) {
- final int[] screenPos = new int[2];
- view.getLocationOnScreen(screenPos);
- final float screenX = screenPos[0] + x;
- final float screenY = screenPos[1] + y;
- return new float[]{screenX, screenY};
- }
- },
- Press.FINGER);
- }
+ private static ViewAction clickXY(final float x, final float y) {
+ return new GeneralClickAction(
+ Tap.SINGLE,
+ new CoordinatesProvider() {
+ @Override
+ public float[] calculateCoordinates(View view) {
+ final int[] screenPos = new int[2];
+ view.getLocationOnScreen(screenPos);
+ final float screenX = screenPos[0] + x;
+ final float screenY = screenPos[1] + y;
+ return new float[] {screenX, screenY};
+ }
+ },
+ Press.FINGER);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java
index 800ad05891..3b86397603 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java
@@ -33,45 +33,46 @@ import static android.support.test.espresso.matcher.ViewMatchers.withText;
*/
public class QueryRenderedFeaturesPropertiesTest {
- @Rule
- public final ActivityTestRule<QueryRenderedFeaturesPropertiesActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class);
+ @Rule
+ public final ActivityTestRule<QueryRenderedFeaturesPropertiesActivity> rule =
+ new ActivityTestRule<>(QueryRenderedFeaturesPropertiesActivity.class);
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- @Ignore
- public void testCountFeatures() {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- LatLng centerScreen = mapboxMap.getCameraPosition().target;
- PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen);
- onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y));
- onView(withText("Found 4 features")).check(matches(isDisplayed()));
- }
+ @Test
+ @Ignore
+ public void testCountFeatures() {
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ LatLng centerScreen = mapboxMap.getCameraPosition().target;
+ PointF centerPixel = mapboxMap.getProjection().toScreenLocation(centerScreen);
+ onView(withId(R.id.mapView)).perform(clickXY(centerPixel.x, centerPixel.y));
+ onView(withText("Found 4 features")).check(matches(isDisplayed()));
+ }
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
- private static ViewAction clickXY(final float x, final float y) {
- return new GeneralClickAction(
- Tap.SINGLE,
- new CoordinatesProvider() {
- @Override
- public float[] calculateCoordinates(View view) {
- final int[] screenPos = new int[2];
- view.getLocationOnScreen(screenPos);
- final float screenX = screenPos[0] + x;
- final float screenY = screenPos[1] + y;
- return new float[]{screenX, screenY};
- }
- },
- Press.FINGER);
- }
+ private static ViewAction clickXY(final float x, final float y) {
+ return new GeneralClickAction(
+ Tap.SINGLE,
+ new CoordinatesProvider() {
+ @Override
+ public float[] calculateCoordinates(View view) {
+ final int[] screenPos = new int[2];
+ view.getLocationOnScreen(screenPos);
+ final float screenX = screenPos[0] + x;
+ final float screenY = screenPos[1] + y;
+ return new float[] {screenX, screenY};
+ }
+ },
+ Press.FINGER);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java
index afb0c607ad..ea80e8689a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedSymbolBoxCountTest.java
@@ -29,33 +29,34 @@ import static org.hamcrest.Matchers.not;
*/
public class QueryRenderedSymbolBoxCountTest {
- @Rule
- public final ActivityTestRule<QueryRenderedFeaturesBoxSymbolCountActivity> rule = new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- @Ignore
- public void testCountSymbols() {
- // click on box to query map
- onView(withId(R.id.selection_box)).perform(click());
-
- // validate if toast is shown
- onView(withText("2 features in box"))
- .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
- .check(matches(isDisplayed()));
- }
-
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @Rule
+ public final ActivityTestRule<QueryRenderedFeaturesBoxSymbolCountActivity> rule =
+ new ActivityTestRule<>(QueryRenderedFeaturesBoxSymbolCountActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ @Ignore
+ public void testCountSymbols() {
+ // click on box to query map
+ onView(withId(R.id.selection_box)).perform(click());
+
+ // validate if toast is shown
+ onView(withText("2 features in box"))
+ .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView()))))
+ .check(matches(isDisplayed()));
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
index 1af957dac6..fa1451092a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
@@ -37,120 +37,120 @@ import static org.hamcrest.core.IsNot.not;
public class AttributionTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- private String[] dialogTexts;
- private String[] dialogLinks;
-
- @Before
- public void beforeTest() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- Intents.init();
- dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names);
- dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links);
- }
-
- @Test
- public void testDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- // Default
- onView(withId(R.id.attributionView)).check(matches(isDisplayed()));
-
- // Disabled
- onView(withId(R.id.attributionView))
- .perform(new DisableAction(mapboxMap))
- .check(matches(not(isDisplayed())));
- }
-
- @Test
- public void testMapboxLink() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
-
- // click on View to open dialog
- onView(withId(R.id.attributionView)).perform(click());
- onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
-
- // click on link and validate browser opening
- Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0])));
- intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
- onView(withText(dialogTexts[0])).perform(click());
- intended(expectedIntent);
- }
-
- @Test
- public void testOpenStreetMapLink() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
-
- // click on View to open dialog
- onView(withId(R.id.attributionView)).perform(click());
- onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
-
- // click on link and validate browser opening
- Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1])));
- intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
- onView(withText(dialogTexts[1])).perform(click());
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ private String[] dialogTexts;
+ private String[] dialogLinks;
+
+ @Before
+ public void beforeTest() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ Intents.init();
+ dialogTexts = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_names);
+ dialogLinks = rule.getActivity().getResources().getStringArray(R.array.mapbox_attribution_links);
+ }
+
+ @Test
+ public void testDisabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ // Default
+ onView(withId(R.id.attributionView)).check(matches(isDisplayed()));
+
+ // Disabled
+ onView(withId(R.id.attributionView))
+ .perform(new DisableAction(mapboxMap))
+ .check(matches(not(isDisplayed())));
+ }
+
+ @Test
+ public void testMapboxLink() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+
+ // click on View to open dialog
+ onView(withId(R.id.attributionView)).perform(click());
+ onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
+
+ // click on link and validate browser opening
+ Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[0])));
+ intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
+ onView(withText(dialogTexts[0])).perform(click());
+ intended(expectedIntent);
+ }
+
+ @Test
+ public void testOpenStreetMapLink() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+
+ // click on View to open dialog
+ onView(withId(R.id.attributionView)).perform(click());
+ onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
+
+ // click on link and validate browser opening
+ Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[1])));
+ intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
+ onView(withText(dialogTexts[1])).perform(click());
+ }
+
+ @Test
+ public void testImproveMapLink() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+
+ // click on View to open dialog
+ onView(withId(R.id.attributionView)).perform(click());
+ onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
+
+ // click on Mapbox link and validate browser opening
+ Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3])));
+ intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
+ onView(withText(dialogTexts[3])).perform(click());
+ }
+
+ @Test
+ public void testTelemetryDialog() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+
+ // click on View to open dialog
+ onView(withId(R.id.attributionView)).perform(click());
+ onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
+
+ // click on item to open second dialog
+ onView(withText(dialogTexts[3])).perform(click());
+ onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed()));
+ }
+
+ @After
+ public void afterTest() {
+ Intents.release();
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class DisableAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+
+ DisableAction(MapboxMap map) {
+ mapboxMap = map;
}
- @Test
- public void testImproveMapLink() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
-
- // click on View to open dialog
- onView(withId(R.id.attributionView)).perform(click());
- onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
-
- // click on Mapbox link and validate browser opening
- Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_VIEW), hasData(Uri.parse(dialogLinks[3])));
- intending(expectedIntent).respondWith(new Instrumentation.ActivityResult(0, null));
- onView(withText(dialogTexts[3])).perform(click());
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- public void testTelemetryDialog() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
-
- // click on View to open dialog
- onView(withId(R.id.attributionView)).perform(click());
- onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
-
- // click on item to open second dialog
- onView(withText(dialogTexts[3])).perform(click());
- onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed()));
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @After
- public void afterTest() {
- Intents.release();
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
- private class DisableAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- DisableAction(MapboxMap map) {
- mapboxMap = map;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getUiSettings().setAttributionEnabled(false);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.getUiSettings().setAttributionEnabled(false);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
index 0dfe07bfa2..02fec41f65 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
@@ -34,120 +34,120 @@ import static org.junit.Assert.assertEquals;
public class CompassViewTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testDefault() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testDefault() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
+ }
+
+ @Test
+ public void testVisible() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
+ CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .bearing(45)
+ .zoom(1)
+ .target(new LatLng())
+ .build()
+ )
+ )
+ );
+
+ onView(withId(R.id.compassView)).check(matches(isDisplayed()));
+ }
+
+ @Test
+ @Ignore // 10-31-2016 click action is not working
+ public void testClick() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
+ CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .bearing(45)
+ .zoom(1)
+ .target(new LatLng())
+ .build()
+ )
+ )
+ );
+
+ onView(withId(R.id.compassView)).perform(click());
+ onView(withId(R.id.mapView)).perform(new WaitAction(3000));
+ onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
+
+ CameraPosition cameraPosition = mapboxMap.getCameraPosition();
+ assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
+ }
+
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class WaitAction implements ViewAction {
+
+ private long waitTime;
+
+ WaitAction(long waitTime) {
+ this.waitTime = waitTime;
}
- @Test
- public void testVisible(){
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
- CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .bearing(45)
- .zoom(1)
- .target(new LatLng())
- .build()
- )
- )
- );
-
- onView(withId(R.id.compassView)).check(matches(isDisplayed()));
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- @Ignore // 10-31-2016 click action is not working
- public void testClick() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- onView(withId(R.id.mapView)).perform(new MoveCameraAction(mapboxMap,
- CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .bearing(45)
- .zoom(1)
- .target(new LatLng())
- .build()
- )
- )
- );
-
- onView(withId(R.id.compassView)).perform(click());
- onView(withId(R.id.mapView)).perform(new WaitAction(3000));
- onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
+ @Override
+ public void perform(UiController uiController, View view) {
+ uiController.loopMainThreadForAtLeast(waitTime);
}
+ }
- private class WaitAction implements ViewAction {
-
- private long waitTime;
-
- WaitAction(long waitTime) {
- this.waitTime = waitTime;
- }
+ private class MoveCameraAction implements ViewAction {
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ private MapboxMap mapboxMap;
+ private CameraUpdate cameraUpdate;
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- uiController.loopMainThreadForAtLeast(waitTime);
- }
+ MoveCameraAction(MapboxMap map, CameraUpdate update) {
+ mapboxMap = map;
+ cameraUpdate = update;
}
- private class MoveCameraAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private CameraUpdate cameraUpdate;
-
- MoveCameraAction(MapboxMap map, CameraUpdate update) {
- mapboxMap = map;
- cameraUpdate = update;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.moveCamera(cameraUpdate);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.moveCamera(cameraUpdate);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java
index 8be5e6b694..f12b2bf160 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/LogoTest.java
@@ -26,59 +26,59 @@ import static org.hamcrest.Matchers.not;
public class LogoTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testDefault() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- onView(withId(R.id.logoView)).check(matches(isDisplayed()));
- }
+ @Test
+ public void testDefault() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ onView(withId(R.id.logoView)).check(matches(isDisplayed()));
+ }
- @Test
- public void testDisabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ @Test
+ public void testDisabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- onView(withId(R.id.logoView))
- .perform(new DisableAction(mapboxMap))
- .check(matches(not(isDisplayed())));
- }
+ onView(withId(R.id.logoView))
+ .perform(new DisableAction(mapboxMap))
+ .check(matches(not(isDisplayed())));
+ }
- @After
- public void unregisterIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
- private class DisableAction implements ViewAction {
+ private class DisableAction implements ViewAction {
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- DisableAction(MapboxMap map) {
- mapboxMap = map;
- }
+ DisableAction(MapboxMap map) {
+ mapboxMap = map;
+ }
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getUiSettings().setLogoEnabled(false);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.getUiSettings().setLogoEnabled(false);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
index 05892dfc41..ac10d11922 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
@@ -51,192 +51,196 @@ import static org.hamcrest.Matchers.not;
*/
public class MyLocationViewTest {
- @Rule
- public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void beforeTest() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Rule
+ public final ActivityTestRule<EspressoTestActivity> rule = new ActivityTestRule<>(EspressoTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void beforeTest() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ @Ignore // requires runtime permissions, disabled for CI
+ public void testEnabled() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
+ onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
+ onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
+ onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false));
+ onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
+ }
+
+ @Test
+ @Ignore
+ // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException:
+ // Looped for 5049 iterations over 60 SECONDS.
+ public void testTracking() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
+ onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
+ onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
+ onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
+ R.drawable.mapbox_mylocation_icon_default, false)));
+ onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap));
+ onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
+ R.drawable.mapbox_mylocation_icon_bearing, true)));
+ }
+
+ @After
+ public void afterTest() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+
+ private class ToggleLocationAction implements ViewAction {
+
+ private MapboxMap mapboxMap;
+ private boolean isEnabled;
+
+ ToggleLocationAction(MapboxMap map, boolean enable) {
+ mapboxMap = map;
+ isEnabled = enable;
}
- @Test
- @Ignore // requires runtime permissions, disabled for CI
- public void testEnabled() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
- onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
- onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
- onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false));
- onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- @Ignore // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: Looped for 5049 iterations over 60 SECONDS.
- public void testTracking() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
- onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
- onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
- onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_default, false)));
- onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap));
- onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, R.drawable.mapbox_mylocation_icon_bearing, true)));
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @After
- public void afterTest() {
- Espresso.unregisterIdlingResources(idlingResource);
+ @Override
+ public void perform(UiController uiController, View view) {
+ if (isEnabled) {
+ // move camera above user location
+ mapboxMap.moveCamera(
+ CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation()))
+ .build()
+ )
+ );
+ }
+
+ // show loction on screen
+ mapboxMap.setMyLocationEnabled(isEnabled);
}
+ }
- private class ToggleLocationAction implements ViewAction {
+ private class EnableLocationTrackingAction implements ViewAction {
- private MapboxMap mapboxMap;
- private boolean isEnabled;
+ private MapboxMap mapboxMap;
- ToggleLocationAction(MapboxMap map, boolean enable) {
- mapboxMap = map;
- isEnabled = enable;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- if (isEnabled) {
- // move camera above user location
- mapboxMap.moveCamera(
- CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation()))
- .build()
- )
- );
- }
-
- // show loction on screen
- mapboxMap.setMyLocationEnabled(isEnabled);
- }
+ EnableLocationTrackingAction(MapboxMap map) {
+ mapboxMap = map;
}
- private class EnableLocationTrackingAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- EnableLocationTrackingAction(MapboxMap map) {
- mapboxMap = map;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
}
+ }
- private class EnableCompassBearingTrackingAction implements ViewAction {
+ private class EnableCompassBearingTrackingAction implements ViewAction {
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- EnableCompassBearingTrackingAction(MapboxMap map) {
- mapboxMap = map;
- }
+ EnableCompassBearingTrackingAction(MapboxMap map) {
+ mapboxMap = map;
+ }
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
+ }
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
+ }
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
- // wait for next compass update cycle
- uiController.loopMainThreadForAtLeast(500);
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
+ // wait for next compass update cycle
+ uiController.loopMainThreadForAtLeast(500);
}
+ }
- private class DrawableMatcher extends TypeSafeMatcher<View> {
+ private class DrawableMatcher extends TypeSafeMatcher<View> {
- private MapboxMap mapboxMap;
- private boolean isBearingDrawable;
- private final int expectedId;
+ private MapboxMap mapboxMap;
+ private boolean isBearingDrawable;
+ private final int expectedId;
- DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) {
- super(MyLocationView.class);
- this.mapboxMap = mapboxMap;
- this.expectedId = expectedId;
- this.isBearingDrawable = isBearingDrawable;
- }
+ DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) {
+ super(MyLocationView.class);
+ this.mapboxMap = mapboxMap;
+ this.expectedId = expectedId;
+ this.isBearingDrawable = isBearingDrawable;
+ }
- @Override
- protected boolean matchesSafely(View target) {
- Drawable currentDrawable = isBearingDrawable ?
- mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() :
- mapboxMap.getMyLocationViewSettings().getForegroundDrawable();
+ @Override
+ protected boolean matchesSafely(View target) {
+ Drawable currentDrawable = isBearingDrawable
+ ? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() :
+ mapboxMap.getMyLocationViewSettings().getForegroundDrawable();
- Resources resources = target.getContext().getResources();
- Drawable expectedDrawable = resources.getDrawable(expectedId);
- return areDrawablesIdentical(currentDrawable, expectedDrawable);
- }
+ Resources resources = target.getContext().getResources();
+ Drawable expectedDrawable = resources.getDrawable(expectedId);
+ return areDrawablesIdentical(currentDrawable, expectedDrawable);
+ }
- @Override
- public void describeTo(Description description) {
- description.appendText("trying to match MyLocationView drawable to " + expectedId);
- }
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("trying to match MyLocationView drawable to " + expectedId);
+ }
- boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
- Drawable.ConstantState stateA = drawableA.getConstantState();
- Drawable.ConstantState stateB = drawableB.getConstantState();
- return (stateA != null && stateB != null && stateA.equals(stateB))
- || getBitmap(drawableA).sameAs(getBitmap(drawableB));
- }
+ boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
+ Drawable.ConstantState stateA = drawableA.getConstantState();
+ Drawable.ConstantState stateB = drawableB.getConstantState();
+ return (stateA != null && stateB != null && stateA.equals(stateB))
+ || getBitmap(drawableA).sameAs(getBitmap(drawableB));
+ }
- Bitmap getBitmap(Drawable drawable) {
- Bitmap result;
- if (drawable instanceof BitmapDrawable) {
- result = ((BitmapDrawable) drawable).getBitmap();
- } else {
- int width = drawable.getIntrinsicWidth();
- int height = drawable.getIntrinsicHeight();
- // Some drawables have no intrinsic width - e.g. solid colours.
- if (width <= 0) {
- width = 1;
- }
- if (height <= 0) {
- height = 1;
- }
-
- result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(result);
- drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- drawable.draw(canvas);
- }
- return result;
- }
+ Bitmap getBitmap(Drawable drawable) {
+ Bitmap result;
+ if (drawable instanceof BitmapDrawable) {
+ result = ((BitmapDrawable) drawable).getBitmap();
+ } else {
+ int width = drawable.getIntrinsicWidth();
+ int height = drawable.getIntrinsicHeight();
+ // Some drawables have no intrinsic width - e.g. solid colours.
+ if (width <= 0) {
+ width = 1;
+ }
+ if (height <= 0) {
+ height = 1;
+ }
+
+ result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(result);
+ drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ drawable.draw(canvas);
+ }
+ return result;
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java
index 1b954259f6..68ed5cb05d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
@@ -19,9 +18,16 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for BackgroundLayer
@@ -29,107 +35,107 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class BackgroundLayerStyleTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private BackgroundLayer layer;
+ private BackgroundLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("visibility");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("visibility");
+ assertNotNull(layer);
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
- @Test
- public void testBackgroundColor() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundColor() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-color");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-color");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
- }
+ //Set and Get
+ layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
- @Test
- public void testBackgroundColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-color");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-color");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundColor(Color.RED));
- assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
- }
+ //Set and Get
+ layer.setProperties(backgroundColor(Color.RED));
+ assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
+ }
- @Test
- public void testBackgroundPattern() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundPattern() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-pattern");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-pattern");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundPattern("pedestrian-polygon"));
- assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
- }
+ //Set and Get
+ layer.setProperties(backgroundPattern("pedestrian-polygon"));
+ assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
+ }
- @Test
- public void testBackgroundOpacity() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-opacity");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-opacity");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundOpacity(0.3f));
- assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
- }
+ //Set and Get
+ layer.setProperties(backgroundOpacity(0.3f));
+ assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
index 393e4fdd2b..ab53ae0487 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
@@ -19,9 +18,16 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for BackgroundLayer
@@ -29,107 +35,107 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class BackgroundLayerTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private BackgroundLayer layer;
+ private BackgroundLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("visibility");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("visibility");
+ assertNotNull(layer);
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
- @Test
- public void testBackgroundColor() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundColor() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-color");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-color");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
- }
+ //Set and Get
+ layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
- @Test
- public void testBackgroundColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-color");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-color");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundColor(Color.RED));
- assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
- }
+ //Set and Get
+ layer.setProperties(backgroundColor(Color.RED));
+ assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
+ }
- @Test
- public void testBackgroundPattern() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundPattern() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-pattern");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-pattern");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundPattern("pedestrian-polygon"));
- assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
- }
+ //Set and Get
+ layer.setProperties(backgroundPattern("pedestrian-polygon"));
+ assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
+ }
- @Test
- public void testBackgroundOpacity() {
- checkViewIsDisplayed(R.id.mapView);
+ @Test
+ public void testBackgroundOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
- mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap = rule.getActivity().getMapboxMap();
- Timber.i("Retrieving layer");
- layer = mapboxMap.getLayerAs("background");
- Timber.i("background-opacity");
- assertNotNull(layer);
+ Timber.i("Retrieving layer");
+ layer = mapboxMap.getLayerAs("background");
+ Timber.i("background-opacity");
+ assertNotNull(layer);
- //Set and Get
- layer.setProperties(backgroundOpacity(0.3f));
- assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
- }
+ //Set and Get
+ layer.setProperties(backgroundOpacity(0.3f));
+ assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
index 5ec4e5437b..620e15579f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
@@ -14,31 +14,31 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
*/
public class BaseStyleTest {
- protected final static String HOME_BUTTON_STRING = "Navigate up";
+ protected static final String HOME_BUTTON_STRING = "Navigate up";
- /*
- * Shortcuts for common UI tests
- */
+ /*
+ * Shortcuts for common UI tests
+ */
- protected void checkViewIsDisplayed(int id) {
- onView(withId(id))
- .check(matches(isDisplayed()));
- }
+ protected void checkViewIsDisplayed(int id) {
+ onView(withId(id))
+ .check(matches(isDisplayed()));
+ }
- /*
- * Screenshots logic
- */
+ /*
+ * Screenshots logic
+ */
- protected void takeNamedScreenshot(final Activity activity, final String name) {
+ protected void takeNamedScreenshot(final Activity activity, final String name) {
- // Screenshots need to be taken on the UI thread
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ScreenshotUtil.take(activity, name);
- }
- });
+ // Screenshots need to be taken on the UI thread
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ScreenshotUtil.take(activity, name);
+ }
+ });
- }
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java
index 635c88fccf..58fda51f07 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
@@ -19,9 +18,22 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for CircleLayer
@@ -29,225 +41,225 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class CircleLayerStyleTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private CircleLayer layer;
+ private CircleLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testCircleRadius() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-radius");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleRadius(0.3f));
- assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testCircleColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleColor(Color.RED));
- assertEquals(layer.getCircleColorAsInt(), Color.RED);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testCircleRadius() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleBlur(0.3f));
- assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
+ Timber.i("circle-radius");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleRadius(0.3f));
+ assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleOpacity(0.3f));
- assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
+ Timber.i("circle-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testCircleColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("circle-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleColor(Color.RED));
+ assertEquals(layer.getCircleColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testCircleBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
+ Timber.i("circle-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleBlur(0.3f));
+ assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCirclePitchScale() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-pitch-scale");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
- assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
+ Timber.i("circle-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleOpacity(0.3f));
+ assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("circle-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testCircleTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("circle-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testCirclePitchScale() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("circle-pitch-scale");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
+ assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
index e7be929d24..782598a0b2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
@@ -19,9 +18,25 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for CircleLayer
@@ -29,313 +44,313 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class CircleLayerTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private CircleLayer layer;
+ private CircleLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testCircleRadius() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-radius");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleRadius(0.3f));
- assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testCircleColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleColor(Color.RED));
- assertEquals(layer.getCircleColorAsInt(), Color.RED);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testCircleRadius() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleBlur(0.3f));
- assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
+ Timber.i("circle-radius");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleRadius(0.3f));
+ assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleOpacity(0.3f));
- assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
+ Timber.i("circle-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testCircleColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("circle-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleColor(Color.RED));
+ assertEquals(layer.getCircleColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testCircleBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
+ Timber.i("circle-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleBlur(0.3f));
+ assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCirclePitchScale() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-pitch-scale");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
- assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
+ Timber.i("circle-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleOpacity(0.3f));
+ assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleStrokeWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-stroke-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleStrokeWidth(0.3f));
- assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f);
+ Timber.i("circle-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testCircleTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleStrokeColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-stroke-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("circle-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testCirclePitchScale() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleStrokeColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-stroke-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleStrokeColor(Color.RED));
- assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
+ Timber.i("circle-pitch-scale");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
+ assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
+ }
+
+ @Test
+ public void testCircleStrokeWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testCircleStrokeOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new CircleLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("circle-stroke-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(circleStrokeOpacity(0.3f));
- assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f);
+ Timber.i("circle-stroke-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleStrokeWidth(0.3f));
+ assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testCircleStrokeColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("circle-stroke-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testCircleStrokeColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("circle-stroke-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleStrokeColor(Color.RED));
+ assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testCircleStrokeOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new CircleLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("circle-stroke-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(circleStrokeOpacity(0.3f));
+ assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java
index 4043b07789..c8668fa407 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
@@ -19,9 +18,21 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for FillLayer
@@ -29,247 +40,247 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class FillLayerStyleTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private FillLayer layer;
+ private FillLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testFillAntialias() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-antialias");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillAntialias(true));
- assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testFillOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillOpacity(0.3f));
- assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testFillAntialias() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillColor(Color.RED));
- assertEquals(layer.getFillColorAsInt(), Color.RED);
+ Timber.i("fill-antialias");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillAntialias(true));
+ assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testFillOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillOutlineColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-outline-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillOpacity(0.3f));
+ assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testFillColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillOutlineColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-outline-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillOutlineColor(Color.RED));
- assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testFillColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillColor(Color.RED));
+ assertEquals(layer.getFillColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testFillOutlineColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testFillOutlineColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillPattern() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-pattern");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillPattern("pedestrian-polygon"));
- assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillOutlineColor(Color.RED));
+ assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testFillTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("fill-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testFillTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("fill-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testFillPattern() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("fill-pattern");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillPattern("pedestrian-polygon"));
+ assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
index 5a4a1f7154..95360e1273 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
@@ -19,9 +18,21 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for FillLayer
@@ -29,247 +40,247 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class FillLayerTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private FillLayer layer;
+ private FillLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testFillAntialias() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-antialias");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillAntialias(true));
- assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testFillOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillOpacity(0.3f));
- assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testFillAntialias() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillColor(Color.RED));
- assertEquals(layer.getFillColorAsInt(), Color.RED);
+ Timber.i("fill-antialias");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillAntialias(true));
+ assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testFillOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillOutlineColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-outline-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("fill-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillOpacity(0.3f));
+ assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testFillColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillOutlineColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-outline-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillOutlineColor(Color.RED));
- assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testFillColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("fill-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillColor(Color.RED));
+ assertEquals(layer.getFillColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testFillOutlineColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testFillOutlineColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testFillPattern() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new FillLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("fill-pattern");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(fillPattern("pedestrian-polygon"));
- assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
+ Timber.i("fill-outline-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillOutlineColor(Color.RED));
+ assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testFillTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("fill-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testFillTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("fill-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testFillPattern() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new FillLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("fill-pattern");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(fillPattern("pedestrian-polygon"));
+ assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java
index e4401c088a..47a38a11ab 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
@@ -19,9 +18,30 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT;
+import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL;
+import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for LineLayer
@@ -29,379 +49,379 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class LineLayerStyleTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private LineLayer layer;
+ private LineLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testLineCap() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-cap");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineCap(LINE_CAP_BUTT));
- assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testLineJoin() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-join");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
- assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineMiterLimit() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-miter-limit");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineMiterLimit(0.3f));
- assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testLineCap() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineRoundLimit() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-round-limit");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineRoundLimit(0.3f));
- assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
+ Timber.i("line-cap");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineCap(LINE_CAP_BUTT));
+ assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
+ }
+
+ @Test
+ public void testLineJoin() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineOpacity(0.3f));
- assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
+ Timber.i("line-join");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
+ assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
+ }
+
+ @Test
+ public void testLineMiterLimit() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("line-miter-limit");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineMiterLimit(0.3f));
+ assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineRoundLimit() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineColor(Color.RED));
- assertEquals(layer.getLineColorAsInt(), Color.RED);
+ Timber.i("line-round-limit");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineRoundLimit(0.3f));
+ assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("line-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineOpacity(0.3f));
+ assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
+ Timber.i("line-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testLineColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineWidth(0.3f));
- assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
+ Timber.i("line-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineColor(Color.RED));
+ assertEquals(layer.getLineColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testLineTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineGapWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-gap-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineGapWidth(0.3f));
- assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
+ Timber.i("line-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testLineTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineOffset() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-offset");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineOffset(0.3f));
- assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
+ Timber.i("line-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testLineWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineBlur(0.3f));
- assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
+ Timber.i("line-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineWidth(0.3f));
+ assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineGapWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineDasharray() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-dasharray");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineDasharray(new Float[]{}));
- assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{});
+ Timber.i("line-gap-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineGapWidth(0.3f));
+ assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineOffset() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLinePattern() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-pattern");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(linePattern("pedestrian-polygon"));
- assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
+ Timber.i("line-offset");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineOffset(0.3f));
+ assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("line-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineBlur(0.3f));
+ assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineDasharray() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("line-dasharray");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineDasharray(new Float[] {}));
+ assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {});
+ }
+
+ @Test
+ public void testLinePattern() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("line-pattern");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(linePattern("pedestrian-polygon"));
+ assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
index 6280476a3d..ad091c78b3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
@@ -19,9 +18,30 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT;
+import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL;
+import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for LineLayer
@@ -29,379 +49,379 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class LineLayerTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private LineLayer layer;
+ private LineLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testLineCap() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-cap");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineCap(LINE_CAP_BUTT));
- assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testLineJoin() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-join");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
- assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineMiterLimit() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-miter-limit");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineMiterLimit(0.3f));
- assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testLineCap() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineRoundLimit() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-round-limit");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineRoundLimit(0.3f));
- assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
+ Timber.i("line-cap");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineCap(LINE_CAP_BUTT));
+ assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
+ }
+
+ @Test
+ public void testLineJoin() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineOpacity(0.3f));
- assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
+ Timber.i("line-join");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
+ assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
+ }
+
+ @Test
+ public void testLineMiterLimit() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("line-miter-limit");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineMiterLimit(0.3f));
+ assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineRoundLimit() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineColor(Color.RED));
- assertEquals(layer.getLineColorAsInt(), Color.RED);
+ Timber.i("line-round-limit");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineRoundLimit(0.3f));
+ assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("line-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineOpacity(0.3f));
+ assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
+ Timber.i("line-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testLineColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineWidth(0.3f));
- assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
+ Timber.i("line-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineColor(Color.RED));
+ assertEquals(layer.getLineColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testLineTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineGapWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-gap-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineGapWidth(0.3f));
- assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
+ Timber.i("line-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testLineTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineOffset() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-offset");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineOffset(0.3f));
- assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
+ Timber.i("line-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testLineWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineBlur(0.3f));
- assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
+ Timber.i("line-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineWidth(0.3f));
+ assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineGapWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLineDasharray() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-dasharray");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(lineDasharray(new Float[]{}));
- assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{});
+ Timber.i("line-gap-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineGapWidth(0.3f));
+ assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineOffset() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testLinePattern() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new LineLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("line-pattern");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(linePattern("pedestrian-polygon"));
- assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
+ Timber.i("line-offset");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineOffset(0.3f));
+ assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("line-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineBlur(0.3f));
+ assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testLineDasharray() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("line-dasharray");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(lineDasharray(new Float[] {}));
+ assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {});
+ }
+
+ @Test
+ public void testLinePattern() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new LineLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("line-pattern");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(linePattern("pedestrian-polygon"));
+ assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java
index 589c07c129..eb67b48f7a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java
@@ -1,10 +1,9 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
@@ -18,9 +17,20 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for RasterLayer
@@ -28,203 +38,203 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class RasterLayerStyleTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private RasterLayer layer;
+ private RasterLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testRasterOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterOpacity(0.3f));
- assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testRasterHueRotate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-hue-rotate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterHueRotate(0.3f));
- assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterBrightnessMin() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-brightness-min");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterBrightnessMin(0.3f));
- assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testRasterOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterBrightnessMax() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-brightness-max");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterBrightnessMax(0.3f));
- assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
+ Timber.i("raster-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterOpacity(0.3f));
+ assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterHueRotate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterSaturation() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-saturation");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterSaturation(0.3f));
- assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
+ Timber.i("raster-hue-rotate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterHueRotate(0.3f));
+ assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterBrightnessMin() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterContrast() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-contrast");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterContrast(0.3f));
- assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
+ Timber.i("raster-brightness-min");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterBrightnessMin(0.3f));
+ assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterBrightnessMax() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterFadeDuration() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-fade-duration");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterFadeDuration(0.3f));
- assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
+ Timber.i("raster-brightness-max");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterBrightnessMax(0.3f));
+ assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterSaturation() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("raster-saturation");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterSaturation(0.3f));
+ assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterContrast() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("raster-contrast");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterContrast(0.3f));
+ assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterFadeDuration() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("raster-fade-duration");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterFadeDuration(0.3f));
+ assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
index 7cd36076d3..169d747b9c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
@@ -1,11 +1,9 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
-import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
@@ -19,9 +17,20 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for RasterLayer
@@ -29,203 +38,203 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class RasterLayerTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private RasterLayer layer;
+ private RasterLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testRasterOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterOpacity(0.3f));
- assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testRasterHueRotate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-hue-rotate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterHueRotate(0.3f));
- assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterBrightnessMin() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-brightness-min");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterBrightnessMin(0.3f));
- assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testRasterOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterBrightnessMax() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-brightness-max");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterBrightnessMax(0.3f));
- assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
+ Timber.i("raster-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterOpacity(0.3f));
+ assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterHueRotate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterSaturation() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-saturation");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterSaturation(0.3f));
- assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
+ Timber.i("raster-hue-rotate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterHueRotate(0.3f));
+ assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterBrightnessMin() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterContrast() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-contrast");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterContrast(0.3f));
- assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
+ Timber.i("raster-brightness-min");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterBrightnessMin(0.3f));
+ assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterBrightnessMax() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testRasterFadeDuration() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new RasterLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("raster-fade-duration");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(rasterFadeDuration(0.3f));
- assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
+ Timber.i("raster-brightness-max");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterBrightnessMax(0.3f));
+ assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterSaturation() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("raster-saturation");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterSaturation(0.3f));
+ assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterContrast() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("raster-contrast");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterContrast(0.3f));
+ assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testRasterFadeDuration() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new RasterLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("raster-fade-duration");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(rasterFadeDuration(0.3f));
+ assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java
index de6e9b5a06..762ae4f846 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;
+
import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -22,39 +23,39 @@ import org.junit.runner.RunWith;
*/
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleBackgroundLayerTest
- extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
-
- public RuntimeStyleBackgroundLayerTest() {
- super(RuntimeStyleTestActivity.class);
- }
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- injectInstrumentation(InstrumentationRegistry.getInstrumentation());
- }
-
- @Test
- public void testSetVisibility() {
- getActivity().mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- Timber.i("visibility");
- BackgroundLayer layer = mapboxMap.getLayerAs("background");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);
-
- //Set
- layer.setProperties(PropertyFactory.visibility(Property.NONE));
- assertEquals(layer.getVisibility().getValue(), Property.NONE);
- }
- });
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
+ extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
+
+ public RuntimeStyleBackgroundLayerTest() {
+ super(RuntimeStyleTestActivity.class);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ injectInstrumentation(InstrumentationRegistry.getInstrumentation());
+ }
+
+ @Test
+ public void testSetVisibility() {
+ getActivity().mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ Timber.i("visibility");
+ BackgroundLayer layer = mapboxMap.getLayerAs("background");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);
+
+ //Set
+ layer.setProperties(PropertyFactory.visibility(Property.NONE));
+ assertEquals(layer.getVisibility().getValue(), Property.NONE);
+ }
+ });
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
index 2c5ea8eb3f..eec00bdde9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
@@ -45,157 +45,157 @@ import static org.junit.Assert.assertNull;
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleTests {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testGetAddRemoveLayer() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
+ }
+
+ @Test
+ public void testAddRemoveSource() {
+ ViewUtils.checkViewIsDisplayed(R.id.mapView);
+
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+ mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
+ try {
+ mapboxMap.removeSource("my-source");
+ } catch (NoSuchSourceException noSuchSourceException) {
+ // it's ok..
+ }
+
+ onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction());
+ }
- private OnMapReadyIdlingResource idlingResource;
+ private class AddRemoveLayerAction implements ViewAction {
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- @Test
- public void testGetAddRemoveLayer() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
- onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- @Test
- public void testAddRemoveSource() {
- ViewUtils.checkViewIsDisplayed(R.id.mapView);
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ //Get initial
+ assertNotNull(mapboxMap.getLayer("building"));
+
+ //Remove
+ try {
+ mapboxMap.removeLayer("building");
+ } catch (NoSuchLayerException noSuchSourceException) {
+ fail("Definitively exists: " + noSuchSourceException.getMessage());
+ }
+ assertNull(mapboxMap.getLayer("building"));
+
+ //Add
+ FillLayer layer = new FillLayer("building", "composite");
+ layer.setSourceLayer("building");
+ mapboxMap.addLayer(layer);
+ assertNotNull(mapboxMap.getLayer("building"));
+
+ //Assure the reference still works
+ layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
+
+ //Remove, preserving the reference
+ try {
+ mapboxMap.removeLayer(layer);
+ } catch (NoSuchLayerException noSuchSourceException) {
+ fail("Definitively exists: " + noSuchSourceException.getMessage());
+ }
+
+ //Property setters should still work
+ layer.setProperties(PropertyFactory.fillColor(Color.RED));
+
+ //Re-add the reference...
+ mapboxMap.addLayer(layer);
+
+ //Ensure it's there
+ Assert.assertNotNull(mapboxMap.getLayer(layer.getId()));
+
+ //Test adding a duplicate layer
+ try {
+ mapboxMap.addLayer(new FillLayer("building", "composite"));
+ fail("Should not have been allowed to add a layer with a duplicate id");
+ } catch (CannotAddLayerException cannotAddLayerException) {
+ //OK
+ }
+ }
+ }
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
- mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
- try {
- mapboxMap.removeSource("my-source");
- } catch (NoSuchSourceException e) {
- // it's ok..
- }
+ private class AddRemoveSourceAction implements ViewAction {
- onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction());
+ @Override
+ public Matcher<View> getConstraints() {
+ return isDisplayed();
}
- private class AddRemoveLayerAction implements ViewAction {
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- //Get initial
- assertNotNull(mapboxMap.getLayer("building"));
-
- //Remove
- try {
- mapboxMap.removeLayer("building");
- } catch (NoSuchLayerException e) {
- fail("Definitively exists: " + e.getMessage());
- }
- assertNull(mapboxMap.getLayer("building"));
-
- //Add
- FillLayer layer = new FillLayer("building", "composite");
- layer.setSourceLayer("building");
- mapboxMap.addLayer(layer);
- assertNotNull(mapboxMap.getLayer("building"));
-
- //Assure the reference still works
- layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
-
- //Remove, preserving the reference
- try {
- mapboxMap.removeLayer(layer);
- } catch (NoSuchLayerException e) {
- fail("Definitively exists: " + e.getMessage());
- }
-
- //Property setters should still work
- layer.setProperties(PropertyFactory.fillColor(Color.RED));
-
- //Re-add the reference...
- mapboxMap.addLayer(layer);
-
- //Ensure it's there
- Assert.assertNotNull(mapboxMap.getLayer(layer.getId()));
-
- //Test adding a duplicate layer
- try {
- mapboxMap.addLayer(new FillLayer("building", "composite"));
- fail("Should not have been allowed to add a layer with a duplicate id");
- } catch (CannotAddLayerException e) {
- //OK
- }
- }
+ @Override
+ public String getDescription() {
+ return getClass().getSimpleName();
}
- private class AddRemoveSourceAction implements ViewAction {
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
-
- //Add initial source
- mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
-
- //Remove
- try {
- mapboxMap.removeSource("my-source");
- } catch (NoSuchSourceException e) {
- fail("Definitively exists: " + e.getMessage());
- }
- assertNull(mapboxMap.getLayer("my-source"));
-
- //Add
- Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source);
-
- //Remove, preserving the reference
- try {
- mapboxMap.removeSource(source);
- } catch (NoSuchSourceException e) {
- fail("Definitively exists: " + e.getMessage());
- }
-
- //Re-add the reference...
- mapboxMap.addSource(source);
-
- //Ensure it's there
- Assert.assertNotNull(mapboxMap.getSource(source.getId()));
-
- //Test adding a duplicate source
- try {
- Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source2);
- fail("Should not have been allowed to add a source with a duplicate id");
- } catch (CannotAddSourceException e) {
- //OK
- }
- }
+ @Override
+ public void perform(UiController uiController, View view) {
+ MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
+
+ //Add initial source
+ mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
+
+ //Remove
+ try {
+ mapboxMap.removeSource("my-source");
+ } catch (NoSuchSourceException noSuchSourceException) {
+ fail("Definitively exists: " + noSuchSourceException.getMessage());
+ }
+ assertNull(mapboxMap.getLayer("my-source"));
+
+ //Add
+ Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
+ mapboxMap.addSource(source);
+
+ //Remove, preserving the reference
+ try {
+ mapboxMap.removeSource(source);
+ } catch (NoSuchSourceException noSuchSourceException) {
+ fail("Definitively exists: " + noSuchSourceException.getMessage());
+ }
+
+ //Re-add the reference...
+ mapboxMap.addSource(source);
+
+ //Ensure it's there
+ Assert.assertNotNull(mapboxMap.getSource(source.getId()));
+
+ //Test adding a duplicate source
+ try {
+ Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
+ mapboxMap.addSource(source2);
+ fail("Should not have been allowed to add a source with a duplicate id");
+ } catch (CannotAddSourceException cannotAddSourceException) {
+ //OK
+ }
}
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java
index 0282e1bcd0..57b0fe72ff 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java
@@ -20,25 +20,26 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleTimingTests extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTimingTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class);
-
- private OnMapReadyIdlingResource idlingResource;
-
- @Before
- public void registerIdlingResource() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
-
- @Test
- public void testGetAddRemoveLayer() {
- checkViewIsDisplayed(R.id.mapView);
- //We're good if it didn't crash
- }
-
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTimingTestActivity> rule =
+ new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class);
+
+ private OnMapReadyIdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @Test
+ public void testGetAddRemoveLayer() {
+ checkViewIsDisplayed(R.id.mapView);
+ //We're good if it didn't crash
+ }
+
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java
index 387e200645..5b59d4ceae 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
@@ -19,9 +18,71 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_LEFT;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconKeepUpright;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for SymbolLayer
@@ -29,1193 +90,1194 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class SymbolLayerStyleTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private SymbolLayer layer;
+ private SymbolLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testSymbolPlacement() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("symbol-placement");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
- assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testSymbolSpacing() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("symbol-spacing");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(symbolSpacing(0.3f));
- assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testSymbolAvoidEdges() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("symbol-avoid-edges");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(symbolAvoidEdges(true));
- assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testSymbolPlacement() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconAllowOverlap() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-allow-overlap");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconAllowOverlap(true));
- assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true);
+ Timber.i("symbol-placement");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
+ assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT);
+ }
+
+ @Test
+ public void testSymbolSpacing() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconIgnorePlacement() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-ignore-placement");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconIgnorePlacement(true));
- assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true);
+ Timber.i("symbol-spacing");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(symbolSpacing(0.3f));
+ assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testSymbolAvoidEdges() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconOptional() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-optional");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconOptional(true));
- assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true);
+ Timber.i("symbol-avoid-edges");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(symbolAvoidEdges(true));
+ assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconAllowOverlap() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconRotationAlignment() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-rotation-alignment");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP));
- assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP);
+ Timber.i("icon-allow-overlap");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconAllowOverlap(true));
+ assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconIgnorePlacement() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconSize() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-size");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconSize(0.3f));
- assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f);
+ Timber.i("icon-ignore-placement");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconIgnorePlacement(true));
+ assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconOptional() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTextFit() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-text-fit");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE));
- assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE);
+ Timber.i("icon-optional");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconOptional(true));
+ assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconRotationAlignment() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTextFitPadding() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-text-fit-padding");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTextFitPadding(new Float[]{0f,0f,0f,0f}));
- assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[]{0f,0f,0f,0f});
+ Timber.i("icon-rotation-alignment");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP));
+ assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP);
+ }
+
+ @Test
+ public void testIconSize() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconImage() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-image");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconImage("undefined"));
- assertEquals((String) layer.getIconImage().getValue(), (String) "undefined");
+ Timber.i("icon-size");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconSize(0.3f));
+ assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconTextFit() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconRotate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-rotate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconRotate(0.3f));
- assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f);
+ Timber.i("icon-text-fit");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE));
+ assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE);
+ }
+
+ @Test
+ public void testIconTextFitPadding() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconPadding() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-padding");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconPadding(0.3f));
- assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f);
+ Timber.i("icon-text-fit-padding");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f}));
+ assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f});
+ }
+
+ @Test
+ public void testIconImage() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconKeepUpright() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-keep-upright");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconKeepUpright(true));
- assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true);
+ Timber.i("icon-image");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconImage("undefined"));
+ assertEquals((String) layer.getIconImage().getValue(), (String) "undefined");
+ }
+
+ @Test
+ public void testIconRotate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconOffset() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-offset");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconOffset(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("icon-rotate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconRotate(0.3f));
+ assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconPadding() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextPitchAlignment() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-pitch-alignment");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP));
- assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP);
+ Timber.i("icon-padding");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconPadding(0.3f));
+ assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconKeepUpright() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextRotationAlignment() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-rotation-alignment");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP));
- assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP);
+ Timber.i("icon-keep-upright");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconKeepUpright(true));
+ assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconOffset() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextField() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-field");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textField(""));
- assertEquals((String) layer.getTextField().getValue(), (String) "");
+ Timber.i("icon-offset");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconOffset(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testTextPitchAlignment() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextFont() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-font");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}));
- assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"});
+ Timber.i("text-pitch-alignment");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP));
+ assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP);
+ }
+
+ @Test
+ public void testTextRotationAlignment() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextSize() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-size");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textSize(0.3f));
- assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f);
+ Timber.i("text-rotation-alignment");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP));
+ assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP);
+ }
+
+ @Test
+ public void testTextField() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextMaxWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-max-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textMaxWidth(0.3f));
- assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f);
+ Timber.i("text-field");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textField(""));
+ assertEquals((String) layer.getTextField().getValue(), (String) "");
+ }
+
+ @Test
+ public void testTextFont() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextLineHeight() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-line-height");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textLineHeight(0.3f));
- assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f);
+ Timber.i("text-font");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textFont(new String[] {"Open Sans Regular", "Arial Unicode MS Regular"}));
+ assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[] {"Open Sans Regular",
+ "Arial Unicode MS Regular"});
+ }
+
+ @Test
+ public void testTextSize() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextLetterSpacing() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-letter-spacing");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textLetterSpacing(0.3f));
- assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f);
+ Timber.i("text-size");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textSize(0.3f));
+ assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextMaxWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextJustify() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-justify");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT));
- assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT);
+ Timber.i("text-max-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textMaxWidth(0.3f));
+ assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextLineHeight() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER));
- assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER);
+ Timber.i("text-line-height");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textLineHeight(0.3f));
+ assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextLetterSpacing() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextMaxAngle() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-max-angle");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textMaxAngle(0.3f));
- assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f);
+ Timber.i("text-letter-spacing");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textLetterSpacing(0.3f));
+ assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextJustify() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextRotate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-rotate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textRotate(0.3f));
- assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f);
+ Timber.i("text-justify");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT));
+ assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT);
+ }
+
+ @Test
+ public void testTextAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextPadding() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-padding");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textPadding(0.3f));
- assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f);
+ Timber.i("text-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER));
+ assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER);
+ }
+
+ @Test
+ public void testTextMaxAngle() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextKeepUpright() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-keep-upright");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textKeepUpright(true));
- assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true);
+ Timber.i("text-max-angle");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textMaxAngle(0.3f));
+ assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextRotate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextTransform() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-transform");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textTransform(TEXT_TRANSFORM_NONE));
- assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE);
+ Timber.i("text-rotate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textRotate(0.3f));
+ assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextPadding() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextOffset() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-offset");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textOffset(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("text-padding");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textPadding(0.3f));
+ assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextKeepUpright() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextAllowOverlap() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-allow-overlap");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textAllowOverlap(true));
- assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true);
+ Timber.i("text-keep-upright");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textKeepUpright(true));
+ assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testTextTransform() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextIgnorePlacement() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-ignore-placement");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textIgnorePlacement(true));
- assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true);
+ Timber.i("text-transform");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textTransform(TEXT_TRANSFORM_NONE));
+ assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE);
+ }
+
+ @Test
+ public void testTextOffset() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextOptional() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-optional");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textOptional(true));
- assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true);
+ Timber.i("text-offset");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textOffset(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testTextAllowOverlap() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconOpacity(0.3f));
- assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f);
+ Timber.i("text-allow-overlap");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textAllowOverlap(true));
+ assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testTextIgnorePlacement() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("text-ignore-placement");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textIgnorePlacement(true));
+ assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testTextOptional() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconColor(Color.RED));
- assertEquals(layer.getIconColorAsInt(), Color.RED);
+ Timber.i("text-optional");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textOptional(true));
+ assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("icon-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconOpacity(0.3f));
+ assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloColor(Color.RED));
- assertEquals(layer.getIconHaloColorAsInt(), Color.RED);
+ Timber.i("icon-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testIconColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloWidth(0.3f));
- assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f);
+ Timber.i("icon-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconColor(Color.RED));
+ assertEquals(layer.getIconColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testIconHaloColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloBlur(0.3f));
- assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f);
+ Timber.i("icon-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testIconHaloColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("icon-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloColor(Color.RED));
+ assertEquals(layer.getIconHaloColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testIconHaloWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP);
+ Timber.i("icon-halo-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloWidth(0.3f));
+ assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconHaloBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textOpacity(0.3f));
- assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f);
+ Timber.i("icon-halo-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloBlur(0.3f));
+ assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("icon-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testIconTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textColor(Color.RED));
- assertEquals(layer.getTextColorAsInt(), Color.RED);
+ Timber.i("icon-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testTextOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("text-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textOpacity(0.3f));
+ assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloColor(Color.RED));
- assertEquals(layer.getTextHaloColorAsInt(), Color.RED);
+ Timber.i("text-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testTextColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloWidth(0.3f));
- assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f);
+ Timber.i("text-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textColor(Color.RED));
+ assertEquals(layer.getTextColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testTextHaloColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloBlur(0.3f));
- assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f);
+ Timber.i("text-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testTextHaloColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("text-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloColor(Color.RED));
+ assertEquals(layer.getTextHaloColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testTextHaloWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP);
+ Timber.i("text-halo-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloWidth(0.3f));
+ assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextHaloBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("text-halo-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloBlur(0.3f));
+ assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("text-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testTextTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("text-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
index 81ea514bcd..f4c50a2ffb 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
@@ -1,11 +1,10 @@
-// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
import android.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
@@ -19,9 +18,71 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Property.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+import timber.log.Timber;
+
+import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_LEFT;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE;
+import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP;
+import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconKeepUpright;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Basic smoke tests for SymbolLayer
@@ -29,1193 +90,1194 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
@RunWith(AndroidJUnit4.class)
public class SymbolLayerTest extends BaseStyleTest {
- @Rule
- public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
+ @Rule
+ public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
- private SymbolLayer layer;
+ private SymbolLayer layer;
- private OnMapReadyIdlingResource idlingResource;
+ private OnMapReadyIdlingResource idlingResource;
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Before
- public void setup() {
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- }
+ @Before
+ public void setup() {
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ }
- @Test
- public void testSetVisibility() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("visibility");
- assertNotNull(layer);
-
- //Get initial
- assertEquals(layer.getVisibility().getValue(), VISIBLE);
-
- //Set
- layer.setProperties(visibility(NONE));
- assertEquals(layer.getVisibility().getValue(), NONE);
- }
+ @Test
+ public void testSetVisibility() {
+ checkViewIsDisplayed(R.id.mapView);
- @Test
- public void testSymbolPlacement() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("symbol-placement");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
- assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT);
- }
+ mapboxMap = rule.getActivity().getMapboxMap();
- @Test
- public void testSymbolSpacing() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("symbol-spacing");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(symbolSpacing(0.3f));
- assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f);
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testSymbolAvoidEdges() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("symbol-avoid-edges");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(symbolAvoidEdges(true));
- assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true);
+ Timber.i("visibility");
+ assertNotNull(layer);
+
+ //Get initial
+ assertEquals(layer.getVisibility().getValue(), VISIBLE);
+
+ //Set
+ layer.setProperties(visibility(NONE));
+ assertEquals(layer.getVisibility().getValue(), NONE);
+ }
+
+ @Test
+ public void testSymbolPlacement() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconAllowOverlap() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-allow-overlap");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconAllowOverlap(true));
- assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true);
+ Timber.i("symbol-placement");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
+ assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT);
+ }
+
+ @Test
+ public void testSymbolSpacing() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconIgnorePlacement() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-ignore-placement");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconIgnorePlacement(true));
- assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true);
+ Timber.i("symbol-spacing");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(symbolSpacing(0.3f));
+ assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testSymbolAvoidEdges() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconOptional() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-optional");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconOptional(true));
- assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true);
+ Timber.i("symbol-avoid-edges");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(symbolAvoidEdges(true));
+ assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconAllowOverlap() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconRotationAlignment() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-rotation-alignment");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP));
- assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP);
+ Timber.i("icon-allow-overlap");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconAllowOverlap(true));
+ assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconIgnorePlacement() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconSize() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-size");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconSize(0.3f));
- assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f);
+ Timber.i("icon-ignore-placement");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconIgnorePlacement(true));
+ assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconOptional() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTextFit() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-text-fit");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE));
- assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE);
+ Timber.i("icon-optional");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconOptional(true));
+ assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconRotationAlignment() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTextFitPadding() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-text-fit-padding");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTextFitPadding(new Float[]{0f,0f,0f,0f}));
- assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[]{0f,0f,0f,0f});
+ Timber.i("icon-rotation-alignment");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP));
+ assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP);
+ }
+
+ @Test
+ public void testIconSize() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconImage() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-image");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconImage("undefined"));
- assertEquals((String) layer.getIconImage().getValue(), (String) "undefined");
+ Timber.i("icon-size");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconSize(0.3f));
+ assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconTextFit() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconRotate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-rotate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconRotate(0.3f));
- assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f);
+ Timber.i("icon-text-fit");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE));
+ assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE);
+ }
+
+ @Test
+ public void testIconTextFitPadding() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconPadding() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-padding");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconPadding(0.3f));
- assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f);
+ Timber.i("icon-text-fit-padding");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f}));
+ assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f});
+ }
+
+ @Test
+ public void testIconImage() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconKeepUpright() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-keep-upright");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconKeepUpright(true));
- assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true);
+ Timber.i("icon-image");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconImage("undefined"));
+ assertEquals((String) layer.getIconImage().getValue(), (String) "undefined");
+ }
+
+ @Test
+ public void testIconRotate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconOffset() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-offset");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconOffset(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("icon-rotate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconRotate(0.3f));
+ assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconPadding() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextPitchAlignment() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-pitch-alignment");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP));
- assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP);
+ Timber.i("icon-padding");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconPadding(0.3f));
+ assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconKeepUpright() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextRotationAlignment() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-rotation-alignment");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP));
- assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP);
+ Timber.i("icon-keep-upright");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconKeepUpright(true));
+ assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconOffset() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextField() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-field");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textField(""));
- assertEquals((String) layer.getTextField().getValue(), (String) "");
+ Timber.i("icon-offset");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconOffset(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testTextPitchAlignment() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextFont() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-font");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}));
- assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"});
+ Timber.i("text-pitch-alignment");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP));
+ assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP);
+ }
+
+ @Test
+ public void testTextRotationAlignment() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextSize() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-size");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textSize(0.3f));
- assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f);
+ Timber.i("text-rotation-alignment");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP));
+ assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP);
+ }
+
+ @Test
+ public void testTextField() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextMaxWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-max-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textMaxWidth(0.3f));
- assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f);
+ Timber.i("text-field");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textField(""));
+ assertEquals((String) layer.getTextField().getValue(), (String) "");
+ }
+
+ @Test
+ public void testTextFont() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextLineHeight() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-line-height");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textLineHeight(0.3f));
- assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f);
+ Timber.i("text-font");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textFont(new String[] {"Open Sans Regular", "Arial Unicode MS Regular"}));
+ assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[] {"Open Sans Regular",
+ "Arial Unicode MS Regular"});
+ }
+
+ @Test
+ public void testTextSize() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextLetterSpacing() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-letter-spacing");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textLetterSpacing(0.3f));
- assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f);
+ Timber.i("text-size");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textSize(0.3f));
+ assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextMaxWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextJustify() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-justify");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT));
- assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT);
+ Timber.i("text-max-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textMaxWidth(0.3f));
+ assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextLineHeight() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER));
- assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER);
+ Timber.i("text-line-height");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textLineHeight(0.3f));
+ assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextLetterSpacing() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextMaxAngle() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-max-angle");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textMaxAngle(0.3f));
- assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f);
+ Timber.i("text-letter-spacing");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textLetterSpacing(0.3f));
+ assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextJustify() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextRotate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-rotate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textRotate(0.3f));
- assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f);
+ Timber.i("text-justify");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT));
+ assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT);
+ }
+
+ @Test
+ public void testTextAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextPadding() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-padding");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textPadding(0.3f));
- assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f);
+ Timber.i("text-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER));
+ assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER);
+ }
+
+ @Test
+ public void testTextMaxAngle() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextKeepUpright() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-keep-upright");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textKeepUpright(true));
- assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true);
+ Timber.i("text-max-angle");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textMaxAngle(0.3f));
+ assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextRotate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextTransform() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-transform");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textTransform(TEXT_TRANSFORM_NONE));
- assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE);
+ Timber.i("text-rotate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textRotate(0.3f));
+ assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextPadding() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextOffset() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-offset");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textOffset(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("text-padding");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textPadding(0.3f));
+ assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextKeepUpright() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextAllowOverlap() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-allow-overlap");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textAllowOverlap(true));
- assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true);
+ Timber.i("text-keep-upright");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textKeepUpright(true));
+ assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testTextTransform() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextIgnorePlacement() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-ignore-placement");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textIgnorePlacement(true));
- assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true);
+ Timber.i("text-transform");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textTransform(TEXT_TRANSFORM_NONE));
+ assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE);
+ }
+
+ @Test
+ public void testTextOffset() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextOptional() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-optional");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textOptional(true));
- assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true);
+ Timber.i("text-offset");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textOffset(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testTextAllowOverlap() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconOpacity(0.3f));
- assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f);
+ Timber.i("text-allow-overlap");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textAllowOverlap(true));
+ assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testTextIgnorePlacement() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("text-ignore-placement");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textIgnorePlacement(true));
+ assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testTextOptional() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconColor(Color.RED));
- assertEquals(layer.getIconColorAsInt(), Color.RED);
+ Timber.i("text-optional");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textOptional(true));
+ assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true);
+ }
+
+ @Test
+ public void testIconOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("icon-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconOpacity(0.3f));
+ assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloColor(Color.RED));
- assertEquals(layer.getIconHaloColorAsInt(), Color.RED);
+ Timber.i("icon-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testIconColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloWidth(0.3f));
- assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f);
+ Timber.i("icon-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconColor(Color.RED));
+ assertEquals(layer.getIconColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testIconHaloColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconHaloBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-halo-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconHaloBlur(0.3f));
- assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f);
+ Timber.i("icon-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testIconHaloColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("icon-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloColor(Color.RED));
+ assertEquals(layer.getIconHaloColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testIconHaloWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testIconTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("icon-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP);
+ Timber.i("icon-halo-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloWidth(0.3f));
+ assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconHaloBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextOpacity() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-opacity");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textOpacity(0.3f));
- assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f);
+ Timber.i("icon-halo-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconHaloBlur(0.3f));
+ assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testIconTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("icon-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testIconTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textColor(Color.RED));
- assertEquals(layer.getTextColorAsInt(), Color.RED);
+ Timber.i("icon-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP);
+ }
+
+ @Test
+ public void testTextOpacity() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloColor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)"));
- assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ Timber.i("text-opacity");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textOpacity(0.3f));
+ assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloColorAsInt() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-color");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloColor(Color.RED));
- assertEquals(layer.getTextHaloColorAsInt(), Color.RED);
+ Timber.i("text-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testTextColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloWidth() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-width");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloWidth(0.3f));
- assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f);
+ Timber.i("text-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textColor(Color.RED));
+ assertEquals(layer.getTextColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testTextHaloColor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextHaloBlur() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-halo-blur");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textHaloBlur(0.3f));
- assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f);
+ Timber.i("text-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)"));
+ assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
+ }
+
+ @Test
+ public void testTextHaloColorAsInt() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextTranslate() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-translate");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textTranslate(new Float[]{0f,0f}));
- assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[]{0f,0f});
+ Timber.i("text-halo-color");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloColor(Color.RED));
+ assertEquals(layer.getTextHaloColorAsInt(), Color.RED);
+ }
+
+ @Test
+ public void testTextHaloWidth() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
-
- @Test
- public void testTextTranslateAnchor() {
- checkViewIsDisplayed(R.id.mapView);
-
- mapboxMap = rule.getActivity().getMapboxMap();
-
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
- Timber.i("Adding layer");
- layer = new SymbolLayer("my-layer", "composite");
- layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
- //Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
- }
- Timber.i("text-translate-anchor");
- assertNotNull(layer);
-
- //Set and Get
- layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP));
- assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP);
+ Timber.i("text-halo-width");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloWidth(0.3f));
+ assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextHaloBlur() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
}
+ Timber.i("text-halo-blur");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textHaloBlur(0.3f));
+ assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f);
+ }
+
+ @Test
+ public void testTextTranslate() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("text-translate");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textTranslate(new Float[] {0f, 0f}));
+ assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
+ }
+
+ @Test
+ public void testTextTranslateAnchor() {
+ checkViewIsDisplayed(R.id.mapView);
+
+ mapboxMap = rule.getActivity().getMapboxMap();
+
+ if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ Timber.i("Adding layer");
+ layer = new SymbolLayer("my-layer", "composite");
+ layer.setSourceLayer("composite");
+ mapboxMap.addLayer(layer);
+ //Layer reference is now stale, get new reference
+ layer = mapboxMap.getLayerAs("my-layer");
+ }
+ Timber.i("text-translate-anchor");
+ assertNotNull(layer);
+
+ //Set and Get
+ layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP));
+ assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP);
+ }
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
+ @After
+ public void unregisterIntentServiceIdlingResource() {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java
index 8d8905fdf4..d9ced47369 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/DrawerUtils.java
@@ -15,15 +15,15 @@ import static android.support.test.espresso.matcher.ViewMatchers.withContentDesc
public class DrawerUtils {
- private final static String HOME_BUTTON_STRING = "Navigate up";
+ private static final String HOME_BUTTON_STRING = "Navigate up";
- public static void openDrawer(){
- onView(withContentDescription(HOME_BUTTON_STRING)).perform(click());
- }
+ public static void openDrawer() {
+ onView(withContentDescription(HOME_BUTTON_STRING)).perform(click());
+ }
- public static void clickItem(@StringRes int txtId){
- Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text),
- ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click());
- }
+ public static void clickItem(@StringRes int txtId) {
+ Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.design_menu_item_text),
+ ViewMatchers.hasSibling(ViewMatchers.withText(txtId)))).perform(ViewActions.click());
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java
index 114fbc549e..3376f5eda4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/GestureUtils.java
@@ -8,8 +8,8 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
public class GestureUtils {
- public static void doubleClickGesture(@IdRes int id){
- onView(withId(id)).perform(doubleClick());
- }
+ public static void doubleClickGesture(@IdRes int id) {
+ onView(withId(id)).perform(doubleClick());
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
index f00c76132c..6e582c6a3a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.utils;
import android.app.Activity;
import android.support.test.espresso.IdlingResource;
+
import timber.log.Timber;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -10,47 +11,47 @@ import java.lang.reflect.Field;
public class OnMapReadyIdlingResource implements IdlingResource {
- private final Activity activity;
- private MapboxMap mapboxMap;
- private IdlingResource.ResourceCallback resourceCallback;
+ private final Activity activity;
+ private MapboxMap mapboxMap;
+ private IdlingResource.ResourceCallback resourceCallback;
- public OnMapReadyIdlingResource(Activity activity) {
- this.activity = activity;
- }
+ public OnMapReadyIdlingResource(Activity activity) {
+ this.activity = activity;
+ }
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
+ @Override
+ public String getName() {
+ return getClass().getSimpleName();
+ }
- @Override
- public boolean isIdleNow() {
- boolean idle = isMapboxMapReady();
- if (idle && resourceCallback != null) {
- resourceCallback.onTransitionToIdle();
- }
- return idle;
+ @Override
+ public boolean isIdleNow() {
+ boolean idle = isMapboxMapReady();
+ if (idle && resourceCallback != null) {
+ resourceCallback.onTransitionToIdle();
}
-
- @Override
- public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
- this.resourceCallback = resourceCallback;
+ return idle;
+ }
+
+ @Override
+ public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
+ this.resourceCallback = resourceCallback;
+ }
+
+ private boolean isMapboxMapReady() {
+ try {
+ Field field = activity.getClass().getDeclaredField("mapboxMap");
+ field.setAccessible(true);
+ mapboxMap = (MapboxMap) field.get(activity);
+ Timber.e("isMapboxReady called with value " + (mapboxMap != null));
+ return mapboxMap != null;
+ } catch (Exception exception) {
+ Timber.e("could not reflect", exception);
+ return false;
}
+ }
- private boolean isMapboxMapReady() {
- try {
- Field field = activity.getClass().getDeclaredField("mapboxMap");
- field.setAccessible(true);
- mapboxMap = (MapboxMap) field.get(activity);
- Timber.e("isMapboxReady called with value " + (mapboxMap != null));
- return mapboxMap != null;
- } catch (Exception e) {
- Timber.e("could not reflect", e);
- return false;
- }
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java
index 84bfa2c8c3..77bfc519bf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java
@@ -4,7 +4,9 @@ import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Environment;
+
import timber.log.Timber;
+
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
@@ -23,112 +25,113 @@ import java.util.UUID;
*/
public class ScreenshotUtil {
- // Where to store the files. This path is required by AWS Device Farm:
- // http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html#test-types-android-instrumentation-screenshots
- private static final String SCREENSHOT_FOLDER = "test-screenshots";
+ // Where to store the files. This path is required by AWS Device Farm:
+ // http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html
+ // #test-types-android-instrumentation-screenshots
+ private static final String SCREENSHOT_FOLDER = "test-screenshots";
- // Image type and quality
- private static final String DEFAULT_IMAGE_EXTENSION = ".png";
- private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG;
- private static final int DEFAULT_IMAGE_QUALITY = 100;
+ // Image type and quality
+ private static final String DEFAULT_IMAGE_EXTENSION = ".png";
+ private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG;
+ private static final int DEFAULT_IMAGE_QUALITY = 100;
- public static void take(Activity activity, String testName) {
+ public static void take(Activity activity, String testName) {
- // Check if storage is available
- if (!isExternalStorageWritable()) {
- Timber.d("External storage is not available.");
- return;
- }
+ // Check if storage is available
+ if (!isExternalStorageWritable()) {
+ Timber.d("External storage is not available.");
+ return;
+ }
- // Get a bitmap from the activity root view. When the drawing cache is enabled,
-// // the next call to getDrawingCache() will draw the view in a bitmap.
- View rootView = activity.getWindow().getDecorView().getRootView();
-// rootView.setDrawingCacheEnabled(true);r
-// rootView.setDrawingCacheEnabled(false);
-
- Bitmap bitmap = null;
-
- // Add the SurfaceView bit (see getAllTextureViews() below)
- List<TextureView> tilingViews = getAllTextureViews(rootView);
- if (tilingViews.size() > 0) {
- bitmap = Bitmap.createBitmap(tilingViews.get(0).getHeight(),tilingViews.get(0).getWidth(), Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- for (TextureView TextureView : tilingViews) {
- Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight());
- int[] location = new int[2];
- TextureView.getLocationInWindow(location);
- int[] location2 = new int[2];
- TextureView.getLocationOnScreen(location2);
- canvas.drawBitmap(b, 0,0, null);
- }
- }
+ // Get a bitmap from the activity root view. When the drawing cache is enabled,
+ // the next call to getDrawingCache() will draw the view in a bitmap.
+ View rootView = activity.getWindow().getDecorView().getRootView();
+ // rootView.setDrawingCacheEnabled(true);r
+ // rootView.setDrawingCacheEnabled(false);
+
+ Bitmap bitmap = null;
+
+ // Add the SurfaceView bit (see getAllTextureViews() below)
+ List<TextureView> tilingViews = getAllTextureViews(rootView);
+ if (tilingViews.size() > 0) {
+ bitmap = Bitmap.createBitmap(tilingViews.get(0).getHeight(), tilingViews.get(0).getWidth(),
+ Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ for (TextureView TextureView : tilingViews) {
+ Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight());
+ int[] location = new int[2];
+ TextureView.getLocationInWindow(location);
+ int[] location2 = new int[2];
+ TextureView.getLocationOnScreen(location2);
+ canvas.drawBitmap(b, 0, 0, null);
+ }
+ }
- // Save the bitmap in external storage
- String uniqueAbsolutePath = getUniqueAbsolutePath(testName);
- File outputFile = new File(uniqueAbsolutePath);
- OutputStream outputStream = null;
+ // Save the bitmap in external storage
+ String uniqueAbsolutePath = getUniqueAbsolutePath(testName);
+ File outputFile = new File(uniqueAbsolutePath);
+ OutputStream outputStream = null;
+ try {
+ outputStream = new FileOutputStream(outputFile);
+ bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream);
+ outputStream.flush();
+ } catch (Exception exception) {
+
+ exception.printStackTrace();
+ } finally {
+ if (outputStream != null) {
try {
- outputStream = new FileOutputStream(outputFile);
- bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream);
- outputStream.flush();
- } catch (Exception e) {
-
- e.printStackTrace();
- } finally {
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ outputStream.close();
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
}
+ }
}
-
- /*
- * The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it:
- * http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache
- */
-
- public static List<TextureView> getAllTextureViews(View view)
- {
- List<TextureView> tilingViews = new ArrayList<TextureView>();
- if (view instanceof TextureView) {
- tilingViews.add((TextureView)view);
- } else if(view instanceof ViewGroup) {
- ViewGroup viewGroup = (ViewGroup)view;
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
- tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i)));
- }
- }
-
- return tilingViews;
+ }
+
+ /*
+ * The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it:
+ * http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache
+ */
+
+ public static List<TextureView> getAllTextureViews(View view) {
+ List<TextureView> tilingViews = new ArrayList<TextureView>();
+ if (view instanceof TextureView) {
+ tilingViews.add((TextureView) view);
+ } else if (view instanceof ViewGroup) {
+ ViewGroup viewGroup = (ViewGroup) view;
+ for (int i = 0; i < viewGroup.getChildCount(); i++) {
+ tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i)));
+ }
}
- /*
- * Utils
- */
+ return tilingViews;
+ }
- public static boolean isExternalStorageWritable() {
- // Checks if external storage is available for read and write
- String state = Environment.getExternalStorageState();
- return Environment.MEDIA_MOUNTED.equals(state);
- }
+ /*
+ * Utils
+ */
- private static String getUniqueAbsolutePath(String testName) {
- // A screenshot after every test vs. manual tests
- String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION;
- if (testName != null && !testName.isEmpty()) {
- filename = testName + DEFAULT_IMAGE_EXTENSION;
- }
+ public static boolean isExternalStorageWritable() {
+ // Checks if external storage is available for read and write
+ String state = Environment.getExternalStorageState();
+ return Environment.MEDIA_MOUNTED.equals(state);
+ }
- String externalPath = Environment.getExternalStorageDirectory().toString();
- String path = externalPath + File.separator + SCREENSHOT_FOLDER;
- File dir = new File(path);
- dir.mkdirs();
- path += File.separator + filename;
- Timber.d("Screenshot path: " + path);
- return path;
+ private static String getUniqueAbsolutePath(String testName) {
+ // A screenshot after every test vs. manual tests
+ String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION;
+ if (testName != null && !testName.isEmpty()) {
+ filename = testName + DEFAULT_IMAGE_EXTENSION;
}
+ String externalPath = Environment.getExternalStorageDirectory().toString();
+ String path = externalPath + File.separator + SCREENSHOT_FOLDER;
+ File dir = new File(path);
+ dir.mkdirs();
+ path += File.separator + filename;
+ Timber.d("Screenshot path: " + path);
+ return path;
+ }
+
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java
index ef46da43ee..965f5d1443 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/TestConstants.java
@@ -4,15 +4,15 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants;
public class TestConstants {
- public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2;
+ public static final long ANIMATION_TEST_TIME = MapboxConstants.ANIMATION_DURATION * 2;
- public static final double LAT_LNG_DELTA_LARGE = 0.1;
- public static final double LAT_LNG_DELTA = 0.01;
- public static final double BEARING_DELTA = 0.1;
- public static final double TILT_DELTA = 0.1;
- public static final double ZOOM_DELTA = 0.3;
+ public static final double LAT_LNG_DELTA_LARGE = 0.1;
+ public static final double LAT_LNG_DELTA = 0.01;
+ public static final double BEARING_DELTA = 0.1;
+ public static final double TILT_DELTA = 0.1;
+ public static final double ZOOM_DELTA = 0.3;
- public static final String TEXT_MARKER_TEXT = "Text";
- public static final String TEXT_MARKER_TITLE = "Marker";
- public static final String TEXT_MARKER_SNIPPET = "Snippet";
+ public static final String TEXT_MARKER_TEXT = "Text";
+ public static final String TEXT_MARKER_TITLE = "Marker";
+ public static final String TEXT_MARKER_SNIPPET = "Snippet";
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java
index 188e75edc7..5c4d5a03c3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ViewUtils.java
@@ -10,13 +10,13 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
public class ViewUtils {
- public static void clickView(@IdRes int viewRes) {
- onView(withId(viewRes))
- .perform(click());
- }
+ public static void clickView(@IdRes int viewRes) {
+ onView(withId(viewRes))
+ .perform(click());
+ }
- public static void checkViewIsDisplayed(int id) {
- onView(withId(id))
- .check(matches(isDisplayed()));
- }
+ public static void checkViewIsDisplayed(int id) {
+ onView(withId(id))
+ .check(matches(isDisplayed()));
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java
index 23842c5dad..170e280e0b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java
@@ -5,43 +5,44 @@ import android.os.StrictMode;
import com.mapbox.mapboxsdk.MapboxAccountManager;
import com.squareup.leakcanary.LeakCanary;
+
import timber.log.Timber;
import static timber.log.Timber.DebugTree;
public class MapboxApplication extends Application {
- @Override
- public void onCreate() {
- super.onCreate();
-
- if (LeakCanary.isInAnalyzerProcess(this)) {
- // This process is dedicated to LeakCanary for heap analysis.
- // You should not init your app in this process.
- return;
- }
- LeakCanary.install(this);
-
- initializeLogger();
-
- StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
- .detectDiskReads()
- .detectDiskWrites()
- .detectNetwork()
- .penaltyLog()
- .build());
- StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
- .detectLeakedSqlLiteObjects()
- .penaltyLog()
- .penaltyDeath()
- .build());
-
- MapboxAccountManager.start(getApplicationContext(), getString(R.string.mapbox_access_token));
- }
+ @Override
+ public void onCreate() {
+ super.onCreate();
- private void initializeLogger() {
- if (BuildConfig.DEBUG) {
- Timber.plant(new DebugTree());
- }
+ if (LeakCanary.isInAnalyzerProcess(this)) {
+ // This process is dedicated to LeakCanary for heap analysis.
+ // You should not init your app in this process.
+ return;
+ }
+ LeakCanary.install(this);
+
+ initializeLogger();
+
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+ .detectDiskReads()
+ .detectDiskWrites()
+ .detectNetwork()
+ .penaltyLog()
+ .build());
+ StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+ .detectLeakedSqlLiteObjects()
+ .penaltyLog()
+ .penaltyDeath()
+ .build());
+
+ MapboxAccountManager.start(getApplicationContext(), getString(R.string.mapbox_access_token));
+ }
+
+ private void initializeLogger() {
+ if (BuildConfig.DEBUG) {
+ Timber.plant(new DebugTree());
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java
index 9a7badf0fa..9ba51e2694 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java
@@ -19,7 +19,9 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.View;
import com.mapbox.mapboxsdk.testapp.R;
@@ -35,199 +37,199 @@ import java.util.List;
public class FeatureOverviewActivity extends AppCompatActivity {
- private static final String KEY_STATE_FEATURES = "featureList";
+ private static final String KEY_STATE_FEATURES = "featureList";
- private RecyclerView recyclerView;
- private FeatureSectionAdapter sectionAdapter;
- private List<Feature> features;
+ private RecyclerView recyclerView;
+ private FeatureSectionAdapter sectionAdapter;
+ private List<Feature> features;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- toolbar.setTitle(getString(R.string.app_name));
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setElevation(getResources().getDimension(R.dimen.toolbar_shadow));
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ toolbar.setTitle(getString(R.string.app_name));
+ setSupportActionBar(toolbar);
- recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
- recyclerView.setLayoutManager(new LinearLayoutManager(this));
- recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
- recyclerView.setHasFixedSize(true);
-
- ItemClickSupport.addTo(recyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
- @Override
- public void onItemClicked(RecyclerView recyclerView, int position, View view) {
- if (!sectionAdapter.isSectionHeaderPosition(position)) {
- int itemPosition = sectionAdapter.getConvertedPosition(position);
- Feature feature = features.get(itemPosition);
- if (feature.isRequiresLocationPermission()) {
- if (requestLocationPermission(itemPosition)) {
- return;
- }
- }
- startFeature(feature);
- }
- }
- });
-
- if (savedInstanceState == null) {
- loadFeatures();
- } else {
- features = savedInstanceState.getParcelableArrayList(KEY_STATE_FEATURES);
- onFeaturesLoaded(features);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setElevation(getResources().getDimension(R.dimen.toolbar_shadow));
}
- private void loadFeatures() {
- try {
- new LoadFeatureTask().execute(
- getPackageManager().getPackageInfo(getPackageName(),
- PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA));
- } catch (PackageManager.NameNotFoundException exception) {
- Timber.e("Could not resolve package info", exception);
- }
- }
-
- private void onFeaturesLoaded(List<Feature> featuresList) {
- features = featuresList;
-
- List<FeatureSectionAdapter.Section> sections = new ArrayList<>();
- String currentCat = "";
- for (int i = 0; i < features.size(); i++) {
- String category = features.get(i).getCategory();
- if (!currentCat.equals(category)) {
- sections.add(new FeatureSectionAdapter.Section(i, category));
- currentCat = category;
+ recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+ recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
+ recyclerView.setHasFixedSize(true);
+
+ ItemClickSupport.addTo(recyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
+ @Override
+ public void onItemClicked(RecyclerView recyclerView, int position, View view) {
+ if (!sectionAdapter.isSectionHeaderPosition(position)) {
+ int itemPosition = sectionAdapter.getConvertedPosition(position);
+ Feature feature = features.get(itemPosition);
+ if (feature.isRequiresLocationPermission()) {
+ if (requestLocationPermission(itemPosition)) {
+ return;
}
+ }
+ startFeature(feature);
}
-
- FeatureSectionAdapter.Section[] dummy = new FeatureSectionAdapter.Section[sections.size()];
- sectionAdapter = new FeatureSectionAdapter(
- this, R.layout.section_main_layout, R.id.section_text, new FeatureAdapter(features));
- sectionAdapter.setSections(sections.toArray(dummy));
- recyclerView.setAdapter(sectionAdapter);
+ }
+ });
+
+ if (savedInstanceState == null) {
+ loadFeatures();
+ } else {
+ features = savedInstanceState.getParcelableArrayList(KEY_STATE_FEATURES);
+ onFeaturesLoaded(features);
}
-
- private void startFeature(Feature feature) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(getPackageName(), feature.getName()));
- startActivity(intent);
+ }
+
+ private void loadFeatures() {
+ try {
+ new LoadFeatureTask().execute(
+ getPackageManager().getPackageInfo(getPackageName(),
+ PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA));
+ } catch (PackageManager.NameNotFoundException exception) {
+ Timber.e("Could not resolve package info", exception);
}
-
- private boolean requestLocationPermission(final int positionInList) {
- if ((ContextCompat.checkSelfPermission(FeatureOverviewActivity.this,
- Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- || (ContextCompat.checkSelfPermission(FeatureOverviewActivity.this,
- Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
- ActivityCompat.requestPermissions(FeatureOverviewActivity.this, new String[]{
- Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, positionInList);
- return true;
- } else {
- return false;
- }
+ }
+
+ private void onFeaturesLoaded(List<Feature> featuresList) {
+ features = featuresList;
+
+ List<FeatureSectionAdapter.Section> sections = new ArrayList<>();
+ String currentCat = "";
+ for (int i = 0; i < features.size(); i++) {
+ String category = features.get(i).getCategory();
+ if (!currentCat.equals(category)) {
+ sections.add(new FeatureSectionAdapter.Section(i, category));
+ currentCat = category;
+ }
}
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- startFeature(features.get(requestCode));
- } else {
- Snackbar.make(
- findViewById(android.R.id.content),
- "Can't open without accepting the location permission.",
- Snackbar.LENGTH_SHORT).show();
- }
+ FeatureSectionAdapter.Section[] dummy = new FeatureSectionAdapter.Section[sections.size()];
+ sectionAdapter = new FeatureSectionAdapter(
+ this, R.layout.section_main_layout, R.id.section_text, new FeatureAdapter(features));
+ sectionAdapter.setSections(sections.toArray(dummy));
+ recyclerView.setAdapter(sectionAdapter);
+ }
+
+ private void startFeature(Feature feature) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName(getPackageName(), feature.getName()));
+ startActivity(intent);
+ }
+
+ private boolean requestLocationPermission(final int positionInList) {
+ if ((ContextCompat.checkSelfPermission(FeatureOverviewActivity.this,
+ Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(FeatureOverviewActivity.this,
+ Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(FeatureOverviewActivity.this, new String[] {
+ Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, positionInList);
+ return true;
+ } else {
+ return false;
}
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putParcelableArrayList(KEY_STATE_FEATURES, (ArrayList<Feature>) features);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ startFeature(features.get(requestCode));
+ } else {
+ Snackbar.make(
+ findViewById(android.R.id.content),
+ "Can't open without accepting the location permission.",
+ Snackbar.LENGTH_SHORT).show();
}
+ }
- private class LoadFeatureTask extends AsyncTask<PackageInfo, Void, List<Feature>> {
-
- @Override
- protected List<Feature> doInBackground(PackageInfo... params) {
- List<Feature> features = new ArrayList<>();
- PackageInfo app = params[0];
-
- String packageName = getApplicationContext().getPackageName();
- String metaDataKey = getString(R.string.category);
- for (ActivityInfo info : app.activities) {
- if (info.labelRes != 0 && info.name.startsWith(packageName)
- && !info.name.equals(FeatureOverviewActivity.class.getName())) {
- String label = getString(info.labelRes);
- String description = resolveString(info.descriptionRes);
- String category = resolveMetaData(info.metaData, metaDataKey);
- boolean requiresLocationPermission = requiresLocationPermission(label, category);
- features.add(new Feature(info.name, label, description, category, requiresLocationPermission));
- }
- }
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putParcelableArrayList(KEY_STATE_FEATURES, (ArrayList<Feature>) features);
+ }
- if (!features.isEmpty()) {
- Comparator<Feature> comparator = new Comparator<Feature>() {
- @Override
- public int compare(Feature lhs, Feature rhs) {
- int result = lhs.getCategory().compareToIgnoreCase(rhs.getCategory());
- if (result == 0) {
- result = lhs.getLabel().compareToIgnoreCase(rhs.getLabel());
- }
- return result;
- }
- };
- Collections.sort(features, comparator);
- }
+ private class LoadFeatureTask extends AsyncTask<PackageInfo, Void, List<Feature>> {
- return features;
+ @Override
+ protected List<Feature> doInBackground(PackageInfo... params) {
+ List<Feature> features = new ArrayList<>();
+ PackageInfo app = params[0];
+
+ String packageName = getApplicationContext().getPackageName();
+ String metaDataKey = getString(R.string.category);
+ for (ActivityInfo info : app.activities) {
+ if (info.labelRes != 0 && info.name.startsWith(packageName)
+ && !info.name.equals(FeatureOverviewActivity.class.getName())) {
+ String label = getString(info.labelRes);
+ String description = resolveString(info.descriptionRes);
+ String category = resolveMetaData(info.metaData, metaDataKey);
+ boolean requiresLocationPermission = requiresLocationPermission(label, category);
+ features.add(new Feature(info.name, label, description, category, requiresLocationPermission));
}
-
- private String resolveMetaData(Bundle bundle, String key) {
- String category = null;
- if (bundle != null) {
- category = bundle.getString(key);
+ }
+
+ if (!features.isEmpty()) {
+ Comparator<Feature> comparator = new Comparator<Feature>() {
+ @Override
+ public int compare(Feature lhs, Feature rhs) {
+ int result = lhs.getCategory().compareToIgnoreCase(rhs.getCategory());
+ if (result == 0) {
+ result = lhs.getLabel().compareToIgnoreCase(rhs.getLabel());
}
- return category;
- }
+ return result;
+ }
+ };
+ Collections.sort(features, comparator);
+ }
- private String resolveString(@StringRes int stringRes) {
- try {
- return getString(stringRes);
- } catch (Resources.NotFoundException exception) {
- return "-";
- }
- }
+ return features;
+ }
- private boolean requiresLocationPermission(String name, String category) {
- final Resources resources = getResources();
+ private String resolveMetaData(Bundle bundle, String key) {
+ String category = null;
+ if (bundle != null) {
+ category = bundle.getString(key);
+ }
+ return category;
+ }
- List<String> requiresPermissionCategories = new ArrayList<String>() {
- {
- add(resources.getString(R.string.category_userlocation));
- }
- };
+ private String resolveString(@StringRes int stringRes) {
+ try {
+ return getString(stringRes);
+ } catch (Resources.NotFoundException exception) {
+ return "-";
+ }
+ }
- List<String> requiresPermissionActvities = new ArrayList<String>() {
- {
- add(resources.getString(R.string.activity_double_map));
- add(getString(R.string.activity_location_picker));
- add(getString(R.string.activity_car_driving));
- }
- };
+ private boolean requiresLocationPermission(String name, String category) {
+ final Resources resources = getResources();
- return requiresPermissionCategories.contains(category) || requiresPermissionActvities.contains(name);
+ List<String> requiresPermissionCategories = new ArrayList<String>() {
+ {
+ add(resources.getString(R.string.category_userlocation));
}
+ };
- @Override
- protected void onPostExecute(List<Feature> features) {
- super.onPostExecute(features);
- onFeaturesLoaded(features);
+ List<String> requiresPermissionActvities = new ArrayList<String>() {
+ {
+ add(resources.getString(R.string.activity_double_map));
+ add(getString(R.string.activity_location_picker));
+ add(getString(R.string.activity_car_driving));
}
+ };
+
+ return requiresPermissionCategories.contains(category) || requiresPermissionActvities.contains(name);
+ }
+
+ @Override
+ protected void onPostExecute(List<Feature> features) {
+ super.onPostExecute(features);
+ onFeaturesLoaded(features);
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java
index c20a8aede1..6c56aa4a7a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java
@@ -4,7 +4,9 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import com.mapbox.mapboxsdk.annotations.Icon;
@@ -21,161 +23,161 @@ import com.mapbox.mapboxsdk.testapp.R;
public class AddRemoveMarkerActivity extends AppCompatActivity {
- public static final double THRESHOLD = 5.0;
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private double lastZoom;
- private boolean isShowingHighThresholdMarker;
- private boolean isShowingLowThresholdMarker;
-
- private MarkerOptions lowThresholdMarker;
- private MarkerOptions highThresholdMarker;
- private Marker activeMarker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_remove_marker);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- final Icon icon1 = IconFactory.getInstance(this).fromResource(R.drawable.ic_arsenal);
- final Icon icon2 = IconFactory.getInstance(this).fromResource(R.drawable.ic_chelsea);
-
- lowThresholdMarker = new MarkerOptions()
- .icon(icon1)
- .position(new LatLng(-0.1, 0));
-
- highThresholdMarker = new MarkerOptions()
- .icon(icon2)
- .position(new LatLng(0.1, 0));
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- AddRemoveMarkerActivity.this.mapboxMap = mapboxMap;
- updateZoom(mapboxMap.getCameraPosition().zoom);
- mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.9f));
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
- @Override
- public void onCameraChange(CameraPosition position) {
- updateZoom(position.zoom);
- }
- });
- }
- });
- }
+ public static final double THRESHOLD = 5.0;
- private void updateZoom(double zoom) {
- if (lastZoom == zoom) {
- return;
- }
-
- lastZoom = zoom;
- if (zoom > THRESHOLD) {
- showHighThresholdMarker();
- } else {
- showLowThresholdMarker();
- }
- }
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private double lastZoom;
+ private boolean isShowingHighThresholdMarker;
+ private boolean isShowingLowThresholdMarker;
- private void showLowThresholdMarker() {
- if (isShowingLowThresholdMarker) {
- return;
- }
+ private MarkerOptions lowThresholdMarker;
+ private MarkerOptions highThresholdMarker;
+ private Marker activeMarker;
- isShowingLowThresholdMarker = true;
- isShowingHighThresholdMarker = false;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add_remove_marker);
- if (activeMarker != null) {
- Timber.d("Remove marker with " + activeMarker.getId());
- mapboxMap.removeMarker(activeMarker);
- } else {
- Timber.e("active marker is null");
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- activeMarker = mapboxMap.addMarker(lowThresholdMarker);
- Timber.d("showLowThresholdMarker() " + activeMarker.getId());
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- private void showHighThresholdMarker() {
- if (isShowingHighThresholdMarker) {
- return;
- }
-
- isShowingLowThresholdMarker = false;
- isShowingHighThresholdMarker = true;
-
- if (activeMarker != null) {
- Timber.d("Remove marker with " + activeMarker.getId());
- mapboxMap.removeMarker(activeMarker);
- } else {
- Timber.e("active marker is null");
- }
+ final Icon icon1 = IconFactory.getInstance(this).fromResource(R.drawable.ic_arsenal);
+ final Icon icon2 = IconFactory.getInstance(this).fromResource(R.drawable.ic_chelsea);
+
+ lowThresholdMarker = new MarkerOptions()
+ .icon(icon1)
+ .position(new LatLng(-0.1, 0));
+
+ highThresholdMarker = new MarkerOptions()
+ .icon(icon2)
+ .position(new LatLng(0.1, 0));
+
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ AddRemoveMarkerActivity.this.mapboxMap = mapboxMap;
+ updateZoom(mapboxMap.getCameraPosition().zoom);
+ mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.9f));
+ mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
+ @Override
+ public void onCameraChange(CameraPosition position) {
+ updateZoom(position.zoom);
+ }
+ });
+ }
+ });
+ }
- activeMarker = mapboxMap.addMarker(highThresholdMarker);
- Timber.d("showHighThresholdMarker() " + activeMarker.getId());
+ private void updateZoom(double zoom) {
+ if (lastZoom == zoom) {
+ return;
}
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ lastZoom = zoom;
+ if (zoom > THRESHOLD) {
+ showHighThresholdMarker();
+ } else {
+ showLowThresholdMarker();
}
+ }
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ private void showLowThresholdMarker() {
+ if (isShowingLowThresholdMarker) {
+ return;
}
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ isShowingLowThresholdMarker = true;
+ isShowingHighThresholdMarker = false;
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ if (activeMarker != null) {
+ Timber.d("Remove marker with " + activeMarker.getId());
+ mapboxMap.removeMarker(activeMarker);
+ } else {
+ Timber.e("active marker is null");
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ activeMarker = mapboxMap.addMarker(lowThresholdMarker);
+ Timber.d("showLowThresholdMarker() " + activeMarker.getId());
+ }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ private void showHighThresholdMarker() {
+ if (isShowingHighThresholdMarker) {
+ return;
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ isShowingLowThresholdMarker = false;
+ isShowingHighThresholdMarker = true;
+
+ if (activeMarker != null) {
+ Timber.d("Remove marker with " + activeMarker.getId());
+ mapboxMap.removeMarker(activeMarker);
+ } else {
+ Timber.e("active marker is null");
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- }
- return super.onOptionsItemSelected(item);
+ activeMarker = mapboxMap.addMarker(highThresholdMarker);
+ Timber.d("showHighThresholdMarker() " + activeMarker.getId());
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
}
+ return super.onOptionsItemSelected(item);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java
index 397ac1d0c9..59c1877cc1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java
@@ -27,249 +27,245 @@ import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.services.commons.models.Position;
+import com.mapbox.services.commons.turf.TurfMeasurement;
import java.util.Random;
public class AnimatedMarkerActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- private LatLng dupontCircle = new LatLng(38.90962, -77.04341);
+ private LatLng dupontCircle = new LatLng(38.90962, -77.04341);
- private Marker passengerMarker = null;
- private MarkerView carMarker = null;
+ private Marker passengerMarker = null;
+ private MarkerView carMarker = null;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_animated_marker);
-
- 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 mapboxMap) {
- AnimatedMarkerActivity.this.mapboxMap = mapboxMap;
- setupMap();
- mapView.post(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < 10; i++) {
- addRandomCar();
- }
- addPassenger();
- addMainCar();
- }
- });
- }
- });
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_animated_marker);
- private void setupMap() {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(dupontCircle)
- .zoom(15)
- .build();
- mapboxMap.setCameraPosition(cameraPosition);
- }
-
- private void addPassenger() {
- LatLng randomLatLng = getLatLngInBounds();
-
- if (passengerMarker == null) {
- Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this)
- .fromResource(R.drawable.ic_directions_run_black_24dp);
- passengerMarker = mapboxMap.addMarker(new MarkerViewOptions()
- .position(randomLatLng)
- .icon(icon));
- } else {
- passengerMarker.setPosition(randomLatLng);
- }
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- private void addMainCar() {
- LatLng randomLatLng = getLatLngInBounds();
-
- if (carMarker == null) {
- carMarker = createCarMarker(randomLatLng, R.drawable.ic_taxi_top, new MarkerViewManager.OnMarkerViewAddedListener() {
- @Override
- public void onViewAdded(@NonNull MarkerView markerView) {
- // Make sure the car marker is selected so that it's always brought to the front (#5285)
- mapboxMap.selectMarker(carMarker);
- animateMoveToPassenger(carMarker);
- }
- });
-
- } else {
- carMarker.setPosition(randomLatLng);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- private void animateMoveToPassenger(final MarkerView car) {
- ValueAnimator animator = animateMoveMarker(car, passengerMarker.getPosition());
- animator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- addPassenger();
- animateMoveToPassenger(car);
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+
+ @Override
+ public void onMapReady(@NonNull final MapboxMap mapboxMap) {
+ AnimatedMarkerActivity.this.mapboxMap = mapboxMap;
+ setupMap();
+ mapView.post(new Runnable() {
+ @Override
+ public void run() {
+ for (int i = 0; i < 10; i++) {
+ addRandomCar();
}
+ addPassenger();
+ addMainCar();
+ }
});
+ }
+ });
+ }
+
+ private void setupMap() {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(dupontCircle)
+ .zoom(15)
+ .build();
+ mapboxMap.setCameraPosition(cameraPosition);
+ }
+
+ private void addPassenger() {
+ LatLng randomLatLng = getLatLngInBounds();
+
+ if (passengerMarker == null) {
+ Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this)
+ .fromResource(R.drawable.ic_directions_run_black_24dp);
+ passengerMarker = mapboxMap.addMarker(new MarkerViewOptions()
+ .position(randomLatLng)
+ .icon(icon));
+ } else {
+ passengerMarker.setPosition(randomLatLng);
}
-
- protected void addRandomCar() {
- createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top, new MarkerViewManager.OnMarkerViewAddedListener() {
- @Override
- public void onViewAdded(@NonNull MarkerView markerView) {
- randomlyMoveMarker(markerView);
- }
+ }
+
+ private void addMainCar() {
+ LatLng randomLatLng = getLatLngInBounds();
+
+ if (carMarker == null) {
+ carMarker = createCarMarker(randomLatLng, R.drawable.ic_taxi_top,
+ new MarkerViewManager.OnMarkerViewAddedListener() {
+ @Override
+ public void onViewAdded(@NonNull MarkerView markerView) {
+ // Make sure the car marker is selected so that it's always brought to the front (#5285)
+ mapboxMap.selectMarker(carMarker);
+ animateMoveToPassenger(carMarker);
+ }
});
- }
- private void randomlyMoveMarker(final MarkerView marker) {
- ValueAnimator animator = animateMoveMarker(marker, getLatLngInBounds());
-
- //Add listener to restart animation on end
- animator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- randomlyMoveMarker(marker);
- }
- });
+ } else {
+ carMarker.setPosition(randomLatLng);
}
-
- private ValueAnimator animateMoveMarker(final MarkerView marker, LatLng to) {
- marker.setRotation((float) getBearing(marker.getPosition(), to));
-
- final ValueAnimator markerAnimator = ObjectAnimator.ofObject(
- marker, "position", new LatLngEvaluator(), marker.getPosition(), to);
- markerAnimator.setDuration((long) (10 * marker.getPosition().distanceTo(to)));
- markerAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
-
- // Start
- markerAnimator.start();
-
- return markerAnimator;
- }
-
- private MarkerView createCarMarker(LatLng start, @DrawableRes int carResource, MarkerViewManager.OnMarkerViewAddedListener listener) {
- Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this)
- .fromResource(carResource);
-
- //View Markers
- return mapboxMap.addMarker(new MarkerViewOptions()
- .position(start)
- .icon(icon), listener);
-
- //GL Markers
+ }
+
+ private void animateMoveToPassenger(final MarkerView car) {
+ ValueAnimator animator = animateMoveMarker(car, passengerMarker.getPosition());
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ addPassenger();
+ animateMoveToPassenger(car);
+ }
+ });
+ }
+
+ protected void addRandomCar() {
+ createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top, new MarkerViewManager.OnMarkerViewAddedListener() {
+ @Override
+ public void onViewAdded(@NonNull MarkerView markerView) {
+ randomlyMoveMarker(markerView);
+ }
+ });
+ }
+
+ private void randomlyMoveMarker(final MarkerView marker) {
+ ValueAnimator animator = animateMoveMarker(marker, getLatLngInBounds());
+
+ //Add listener to restart animation on end
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ randomlyMoveMarker(marker);
+ }
+ });
+ }
+
+ private ValueAnimator animateMoveMarker(final MarkerView marker, LatLng to) {
+ marker.setRotation((float) getBearing(marker.getPosition(), to));
+
+ final ValueAnimator markerAnimator = ObjectAnimator.ofObject(
+ marker, "position", new LatLngEvaluator(), marker.getPosition(), to);
+ markerAnimator.setDuration((long) (10 * marker.getPosition().distanceTo(to)));
+ markerAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
+
+ // Start
+ markerAnimator.start();
+
+ return markerAnimator;
+ }
+
+ private MarkerView createCarMarker(LatLng start, @DrawableRes int carResource,
+ MarkerViewManager.OnMarkerViewAddedListener listener) {
+ Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this)
+ .fromResource(carResource);
+
+ //View Markers
+ return mapboxMap.addMarker(new MarkerViewOptions()
+ .position(start)
+ .icon(icon), listener);
+
+ //GL Markers
// return mapboxMap.addMarker(new MarkerOptions()
// .position(start)
// .icon(icon));
+ }
+
+ private LatLng getLatLngInBounds() {
+ LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
+ Random generator = new Random();
+ double randomLat = bounds.getLatSouth() + generator.nextDouble()
+ * (bounds.getLatNorth() - bounds.getLatSouth());
+ double randomLon = bounds.getLonWest() + generator.nextDouble()
+ * (bounds.getLonEast() - bounds.getLonWest());
+ return new LatLng(randomLat, randomLon);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- private LatLng getLatLngInBounds() {
- LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
- Random generator = new Random();
- double randomLat = bounds.getLatSouth() + generator.nextDouble()
- * (bounds.getLatNorth() - bounds.getLatSouth());
- double randomLon = bounds.getLonWest() + generator.nextDouble()
- * (bounds.getLonEast() - bounds.getLonWest());
- return new LatLng(randomLat, randomLon);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- @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
+ 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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ /**
+ * Evaluator for LatLng pairs
+ */
+ private static class LatLngEvaluator implements TypeEvaluator<LatLng> {
+
+ private LatLng latLng = new LatLng();
@Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- /**
- * Evaluator for LatLng pairs
- */
- private static class LatLngEvaluator implements TypeEvaluator<LatLng> {
-
- private LatLng latLng = new LatLng();
-
- @Override
- public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
- latLng.setLatitude(startValue.getLatitude()
- + ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
- latLng.setLongitude(startValue.getLongitude()
- + ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
- return latLng;
- }
- }
-
- private double getBearing(LatLng from, LatLng to) {
- double degrees2radians = Math.PI / 180;
- double radians2degrees = 180 / Math.PI;
-
- double lon1 = degrees2radians * from.getLongitude();
- double lon2 = degrees2radians * to.getLongitude();
- double lat1 = degrees2radians * from.getLatitude();
- double lat2 = degrees2radians * to.getLatitude();
- double a = Math.sin(lon2 - lon1) * Math.cos(lat2);
- double b = Math.cos(lat1) * Math.sin(lat2)
- - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
-
- return radians2degrees * Math.atan2(a, b);
+ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
+ latLng.setLatitude(startValue.getLatitude()
+ + ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
+ latLng.setLongitude(startValue.getLongitude()
+ + ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
+ return latLng;
}
+ }
+
+ private double getBearing(LatLng from, LatLng to) {
+ return TurfMeasurement.bearing(
+ Position.fromCoordinates(from.getLongitude(), from.getLatitude()),
+ Position.fromCoordinates(to.getLongitude(), to.getLatitude())
+ );
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java
index cb799c3d4d..0d97289e56 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java
@@ -8,11 +8,14 @@ import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
+import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
@@ -43,258 +46,259 @@ import java.util.Random;
public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
- private MapboxMap mapboxMap;
- private MapView mapView;
- private boolean customMarkerView;
- private List<LatLng> locations;
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private boolean customMarkerView;
+ private List<LatLng> locations;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_marker_bulk);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_marker_bulk);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayShowTitleEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- BulkMarkerActivity.this.mapboxMap = mapboxMap;
-
- if (actionBar != null) {
- ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(
- actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item);
- spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- Spinner spinner = (Spinner) findViewById(R.id.spinner);
- spinner.setAdapter(spinnerAdapter);
- spinner.setOnItemSelectedListener(BulkMarkerActivity.this);
- }
- }
- });
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ BulkMarkerActivity.this.mapboxMap = mapboxMap;
- final View fab = findViewById(R.id.fab);
- if (fab != null) {
- fab.setOnClickListener(new FabClickListener());
+ if (actionBar != null) {
+ ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(
+ actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item);
+ spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ Spinner spinner = (Spinner) findViewById(R.id.spinner);
+ spinner.setAdapter(spinnerAdapter);
+ spinner.setOnItemSelectedListener(BulkMarkerActivity.this);
}
- }
+ }
+ });
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- int amount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]);
- if (locations == null) {
- new LoadLocationTask(this, amount).execute();
- } else {
- showMarkers(amount);
- }
+ final View fab = findViewById(R.id.fab);
+ if (fab != null) {
+ fab.setOnClickListener(new FabClickListener());
}
-
- private void onLatLngListLoaded(List<LatLng> latLngs, int amount) {
- locations = latLngs;
- showMarkers(amount);
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ int amount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]);
+ if (locations == null) {
+ new LoadLocationTask(this, amount).execute();
+ } else {
+ showMarkers(amount);
}
+ }
- private void showMarkers(int amount) {
- mapboxMap.clear();
+ private void onLatLngListLoaded(List<LatLng> latLngs, int amount) {
+ locations = latLngs;
+ showMarkers(amount);
+ }
- if (locations.size() < amount) {
- amount = locations.size();
- }
+ private void showMarkers(int amount) {
+ mapboxMap.clear();
- if (customMarkerView) {
- showViewMarkers(amount);
- } else {
- showGlMarkers(amount);
- }
+ if (locations.size() < amount) {
+ amount = locations.size();
}
- private void showViewMarkers(int amount) {
- DecimalFormat formatter = new DecimalFormat("#.#####");
- Random random = new Random();
- int randomIndex;
-
- Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_droppin_24dp, getTheme());
- int redColor = ResourcesCompat.getColor(getResources(), android.R.color.holo_red_dark, getTheme());
- drawable.setColorFilter(redColor, PorterDuff.Mode.SRC_IN);
- Icon icon = IconFactory.getInstance(this).fromDrawable(drawable);
-
- List<MarkerViewOptions> markerOptionsList = new ArrayList<>();
- for (int i = 0; i < amount; i++) {
- randomIndex = random.nextInt(locations.size());
- LatLng latLng = locations.get(randomIndex);
- MarkerViewOptions markerOptions = new MarkerViewOptions()
- .position(latLng)
- .icon(icon)
- .title(String.valueOf(i))
- .snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude()));
- markerOptionsList.add(markerOptions);
- }
- mapboxMap.addMarkerViews(markerOptionsList);
+ if (customMarkerView) {
+ showViewMarkers(amount);
+ } else {
+ showGlMarkers(amount);
}
-
- private void showGlMarkers(int amount) {
- List<MarkerOptions> markerOptionsList = new ArrayList<>();
- DecimalFormat formatter = new DecimalFormat("#.#####");
- Random random = new Random();
- int randomIndex;
-
- for (int i = 0; i < amount; i++) {
- randomIndex = random.nextInt(locations.size());
- LatLng latLng = locations.get(randomIndex);
- markerOptionsList.add(new MarkerOptions()
- .position(latLng)
- .title(String.valueOf(i))
- .snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude())));
- }
-
- mapboxMap.addMarkers(markerOptionsList);
+ }
+
+ private void showViewMarkers(int amount) {
+ DecimalFormat formatter = new DecimalFormat("#.#####");
+ Random random = new Random();
+ int randomIndex;
+
+ Drawable drawable = ContextCompat.getDrawable(BulkMarkerActivity.this, R.drawable.ic_droppin_24dp);
+
+ int redColor = ResourcesCompat.getColor(getResources(), android.R.color.holo_red_dark, getTheme());
+ drawable.setColorFilter(redColor, PorterDuff.Mode.SRC_IN);
+ Icon icon = IconFactory.getInstance(this).fromDrawable(drawable);
+
+ List<MarkerViewOptions> markerOptionsList = new ArrayList<>();
+ for (int i = 0; i < amount; i++) {
+ randomIndex = random.nextInt(locations.size());
+ LatLng latLng = locations.get(randomIndex);
+ MarkerViewOptions markerOptions = new MarkerViewOptions()
+ .position(latLng)
+ .icon(icon)
+ .title(String.valueOf(i))
+ .snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude()));
+ markerOptionsList.add(markerOptions);
}
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- // nothing selected, nothing to do!
+ mapboxMap.addMarkerViews(markerOptionsList);
+ }
+
+ private void showGlMarkers(int amount) {
+ List<MarkerOptions> markerOptionsList = new ArrayList<>();
+ DecimalFormat formatter = new DecimalFormat("#.#####");
+ Random random = new Random();
+ int randomIndex;
+
+ for (int i = 0; i < amount; i++) {
+ randomIndex = random.nextInt(locations.size());
+ LatLng latLng = locations.get(randomIndex);
+ markerOptionsList.add(new MarkerOptions()
+ .position(latLng)
+ .title(String.valueOf(i))
+ .snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude())));
}
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ mapboxMap.addMarkers(markerOptionsList);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // nothing selected, nothing to do!
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
+ private class FabClickListener implements View.OnClickListener {
@Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ public void onClick(final View view) {
+ if (mapboxMap != null) {
+ customMarkerView = true;
+
+ // remove fab
+ view.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
+ view.setVisibility(View.GONE);
+ }
+ }).start();
+
+ // reload markers
+ Spinner spinner = (Spinner) findViewById(R.id.spinner);
+ if (spinner != null) {
+ int amount = Integer.valueOf(
+ getResources().getStringArray(R.array.bulk_marker_list)[spinner.getSelectedItemPosition()]);
+ showMarkers(amount);
+ }
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(@MapView.MapChange int change) {
+ if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
+ if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
+ TextView viewCountView = (TextView) findViewById(R.id.countView);
+ viewCountView.setText("ViewCache size " + (mapView.getChildCount() - 5));
+ }
+ }
+ }
+ });
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
+ new MapboxMap.OnMarkerViewClickListener() {
+ @Override
+ public boolean onMarkerClick(
+ @NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
+ Toast.makeText(
+ BulkMarkerActivity.this,
+ "Hello " + marker.getId(),
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ });
+ }
}
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ private static class LoadLocationTask extends AsyncTask<Void, Integer, List<LatLng>> {
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ private BulkMarkerActivity activity;
+ private ProgressDialog progressDialog;
+ private int amount;
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ private LoadLocationTask(BulkMarkerActivity activity, int amount) {
+ this.amount = amount;
+ this.activity = activity;
+ progressDialog = ProgressDialog.show(activity, "Loading", "Fetching markers", false);
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ protected List<LatLng> doInBackground(Void... params) {
+ try {
+ String json = GeoParseUtil.loadStringFromAssets(activity.getApplicationContext(), "points.geojson");
+ return GeoParseUtil.parseGeoJsonCoordinates(json);
+ } catch (IOException | JSONException exception) {
+ Timber.e("Could not add markers,", exception);
+ return null;
+ }
}
- private class FabClickListener implements View.OnClickListener {
- @Override
- public void onClick(final View v) {
- if (mapboxMap != null) {
- customMarkerView = true;
-
- // remove fab
- v.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- v.setVisibility(View.GONE);
- }
- }).start();
-
- // reload markers
- Spinner spinner = (Spinner) findViewById(R.id.spinner);
- if (spinner != null) {
- int amount = Integer.valueOf(
- getResources().getStringArray(R.array.bulk_marker_list)[spinner.getSelectedItemPosition()]);
- showMarkers(amount);
- }
-
- mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
- @Override
- public void onMapChanged(@MapView.MapChange int change) {
- if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
- if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
- TextView viewCountView = (TextView) findViewById(R.id.countView);
- viewCountView.setText("ViewCache size " + (mapView.getChildCount() - 5));
- }
- }
- }
- });
-
- mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
- new MapboxMap.OnMarkerViewClickListener() {
- @Override
- public boolean onMarkerClick(
- @NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
- Toast.makeText(
- BulkMarkerActivity.this,
- "Hello " + marker.getId(),
- Toast.LENGTH_SHORT).show();
- return false;
- }
- });
- }
- }
- }
-
- private static class LoadLocationTask extends AsyncTask<Void, Integer, List<LatLng>> {
-
- private BulkMarkerActivity activity;
- private ProgressDialog progressDialog;
- private int amount;
-
- public LoadLocationTask(BulkMarkerActivity activity, int amount) {
- this.amount = amount;
- this.activity = activity;
- progressDialog = ProgressDialog.show(activity, "Loading", "Fetching markers", false);
- }
-
- @Override
- protected List<LatLng> doInBackground(Void... params) {
- try {
- String json = GeoParseUtil.loadStringFromAssets(activity.getApplicationContext(), "points.geojson");
- return GeoParseUtil.parseGeoJSONCoordinates(json);
- } catch (IOException | JSONException exception) {
- Timber.e("Could not add markers,", exception);
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(List<LatLng> locations) {
- super.onPostExecute(locations);
- activity.onLatLngListLoaded(locations, amount);
- progressDialog.hide();
- }
+ @Override
+ protected void onPostExecute(List<LatLng> locations) {
+ super.onPostExecute(locations);
+ activity.onLatLngListLoaded(locations, amount);
+ progressDialog.hide();
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java
index ed6cec7df0..8446329e43 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java
@@ -21,123 +21,123 @@ import com.mapbox.mapboxsdk.testapp.R;
public class DynamicMarkerChangeActivity extends AppCompatActivity {
- private static final LatLng LAT_LNG_CHELSEA = new LatLng(51.481670, -0.190849);
- private static final LatLng LAT_LNG_ARSENAL = new LatLng(51.555062, -0.108417);
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private IconFactory iconFactory;
- private Marker marker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_dynamic_marker);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- iconFactory = IconFactory.getInstance(this);
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.setTag(false);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- DynamicMarkerChangeActivity.this.mapboxMap = mapboxMap;
- // Create marker
- MarkerOptions markerOptions = new MarkerOptions()
- .position(LAT_LNG_CHELSEA)
- .icon(iconFactory.fromResource(R.drawable.ic_chelsea))
- .title(getString(R.string.dynamic_marker_chelsea_title))
- .snippet(getString(R.string.dynamic_marker_chelsea_snippet));
- marker = mapboxMap.addMarker(markerOptions);
- }
- });
-
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- updateMarker();
- }
- }
- });
- }
-
- private void updateMarker() {
- // update model
- boolean first = (boolean) mapView.getTag();
- mapView.setTag(!first);
-
- // update marker
- marker.setPosition(first ? LAT_LNG_CHELSEA : LAT_LNG_ARSENAL);
- marker.setIcon(iconFactory.fromResource(first ? R.drawable.ic_chelsea : R.drawable.ic_arsenal));
- marker.setTitle(first
- ? getString(R.string.dynamic_marker_chelsea_title) : getString(R.string.dynamic_marker_arsenal_title));
- marker.setSnippet(first
- ? getString(R.string.dynamic_marker_chelsea_snippet) : getString(R.string.dynamic_marker_arsenal_snippet));
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ private static final LatLng LAT_LNG_CHELSEA = new LatLng(51.481670, -0.190849);
+ private static final LatLng LAT_LNG_ARSENAL = new LatLng(51.555062, -0.108417);
+
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private IconFactory iconFactory;
+ private Marker marker;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_dynamic_marker);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ iconFactory = IconFactory.getInstance(this);
+
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setTag(false);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ DynamicMarkerChangeActivity.this.mapboxMap = mapboxMap;
+ // Create marker
+ MarkerOptions markerOptions = new MarkerOptions()
+ .position(LAT_LNG_CHELSEA)
+ .icon(iconFactory.fromResource(R.drawable.ic_chelsea))
+ .title(getString(R.string.dynamic_marker_chelsea_title))
+ .snippet(getString(R.string.dynamic_marker_chelsea_snippet));
+ marker = mapboxMap.addMarker(markerOptions);
+ }
+ });
+
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ updateMarker();
}
+ }
+ });
+ }
+
+ private void updateMarker() {
+ // update model
+ boolean first = (boolean) mapView.getTag();
+ mapView.setTag(!first);
+
+ // update marker
+ marker.setPosition(first ? LAT_LNG_CHELSEA : LAT_LNG_ARSENAL);
+ marker.setIcon(iconFactory.fromResource(first ? R.drawable.ic_chelsea : R.drawable.ic_arsenal));
+ marker.setTitle(first
+ ? getString(R.string.dynamic_marker_chelsea_title) : getString(R.string.dynamic_marker_arsenal_title));
+ marker.setSnippet(first
+ ? getString(R.string.dynamic_marker_chelsea_snippet) : getString(R.string.dynamic_marker_arsenal_snippet));
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
index 2bb1a5b3d5..f1dc7f8c0d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
@@ -41,456 +41,458 @@ import java.util.Random;
public class MarkerViewActivity extends AppCompatActivity {
- private static final LatLng[] LAT_LNGS = new LatLng[]{
- new LatLng(38.897424, -77.036508),
- new LatLng(38.909698, -77.029642),
- new LatLng(38.907227, -77.036530),
- new LatLng(38.905607, -77.031916),
- new LatLng(38.889441, -77.050134),
- new LatLng(38.888000, -77.050000) //Slight overlap to show re-ordering on selection
- };
-
- private MapboxMap mapboxMap;
- private MapView mapView;
-
- // MarkerView location updates
- private MarkerView movingMarkerOne;
- private MarkerView movingMarkerTwo;
- private Random randomAnimator = new Random();
- private Handler locationUpdateHandler = new Handler();
- private Runnable moveMarkerRunnable = new MoveMarkerRunnable();
-
- // MarkerView rotate updates
- private MarkerView rotateMarker;
- private Handler rotateUpdateHandler = new Handler();
- private Runnable rotateMarkerRunnable = new RotateMarkerRunnable();
- private int rotation = 360;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_marker_view);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private static final LatLng[] LAT_LNGS = new LatLng[] {
+ new LatLng(38.897424, -77.036508),
+ new LatLng(38.909698, -77.029642),
+ new LatLng(38.907227, -77.036530),
+ new LatLng(38.905607, -77.031916),
+ new LatLng(38.889441, -77.050134),
+ new LatLng(38.888000, -77.050000) //Slight overlap to show re-ordering on selection
+ };
+
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+
+ // MarkerView location updates
+ private MarkerView movingMarkerOne;
+ private MarkerView movingMarkerTwo;
+ private Random randomAnimator = new Random();
+ private Handler locationUpdateHandler = new Handler();
+ private Runnable moveMarkerRunnable = new MoveMarkerRunnable();
+
+ // MarkerView rotate updates
+ private MarkerView rotateMarker;
+ private Handler rotateUpdateHandler = new Handler();
+ private Runnable rotateMarkerRunnable = new RotateMarkerRunnable();
+ private int rotation = 360;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_marker_view);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
+ final TextView viewCountView = (TextView) findViewById(R.id.countView);
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ MarkerViewActivity.this.mapboxMap = mapboxMap;
+
+ final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
+
+ Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this)
+ .fromResource(R.drawable.ic_us);
+
+ // add default ViewMarker markers
+ for (int i = 0; i < LAT_LNGS.length; i++) {
+ MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
+ .position(LAT_LNGS[i])
+ .title(String.valueOf(i))
+ .alpha(0.5f)
+ .icon(usFlag)
+ );
}
- final TextView viewCountView = (TextView) findViewById(R.id.countView);
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- MarkerViewActivity.this.mapboxMap = mapboxMap;
-
- final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
-
- Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this)
- .fromResource(R.drawable.ic_us);
-
- // add default ViewMarker markers
- for (int i = 0; i < LAT_LNGS.length; i++) {
- MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
- .position(LAT_LNGS[i])
- .title(String.valueOf(i))
- .alpha(0.5f)
- .icon(usFlag)
- );
- }
-
- // add custom ViewMarker
- CountryMarkerViewOptions options = new CountryMarkerViewOptions();
- options.flagRes(R.drawable.icon_burned);
- options.abbrevName("Mapbox");
- options.title("Hello");
- options.position(new LatLng(38.899774, -77.023237));
- options.flat(true);
- mapboxMap.addMarker(options);
-
- MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions()
- .title("United States")
- .position(new LatLng(38.902580, -77.050102))
- );
-
- rotateMarker = MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
- .text("A")
- .rotation(rotation = 270)
- .position(new LatLng(38.889876, -77.008849))
- );
- loopMarkerRotate();
-
-
- MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
- .text("B")
- .position(new LatLng(38.907327, -77.041293))
- );
-
- MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
- .text("C")
- .position(new LatLng(38.897642, -77.041980))
- );
-
- // if you want to customise a ViewMarker you need to extend ViewMarker and provide an adapter implementation
- // set adapters for child classes of ViewMarker
- markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this, mapboxMap));
- markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap));
-
- final ViewGroup markerViewContainer = markerViewManager.getMarkerViewContainer();
-
- // add a change listener to validate the size of amount of child views
- mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
- @Override
- public void onMapChanged(@MapView.MapChange int change) {
- if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
- if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) {
- viewCountView.setText("ViewCache size " + markerViewContainer.getChildCount());
- }
- }
- }
- });
-
- // add a OnMarkerView click listener
- MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() {
- @Override
- public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
- Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
- return false;
- }
- });
-
- movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
- .position(CarLocation.CAR_0_LNGS[0])
- .icon(IconFactory.getInstance(mapView.getContext())
- .fromResource(R.drawable.ic_chelsea))
- );
-
- movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions()
- .position(CarLocation.CAR_1_LNGS[0])
- .icon(IconFactory.getInstance(mapView.getContext())
- .fromResource(R.drawable.ic_arsenal))
- );
-
- // allow more open infowindows at the same time
- mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
-
- // add offscreen markers
- Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
- .setPosition(new LatLng(38.892846, -76.909399))
- .title("InfoWindow")
- .snippet("Offscreen, to the right of the Map."));
-
- Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
- .setPosition(new LatLng(38.791645, -77.039006))
- .title("InfoWindow")
- .snippet("Offscreen, to the bottom of the Map"));
-
- // open infowindow offscreen markers
- mapboxMap.selectMarker(markerRightOffScreen);
- mapboxMap.selectMarker(markerRightBottomOffScreen);
+ // add custom ViewMarker
+ CountryMarkerViewOptions options = new CountryMarkerViewOptions();
+ options.flagRes(R.drawable.icon_burned);
+ options.abbrevName("Mapbox");
+ options.title("Hello");
+ options.position(new LatLng(38.899774, -77.023237));
+ options.flat(true);
+ mapboxMap.addMarker(options);
+
+ MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions()
+ .title("United States")
+ .position(new LatLng(38.902580, -77.050102))
+ );
+
+ rotateMarker = MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
+ .text("A")
+ .rotation(rotation = 270)
+ .position(new LatLng(38.889876, -77.008849))
+ );
+ loopMarkerRotate();
+
+
+ MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
+ .text("B")
+ .position(new LatLng(38.907327, -77.041293))
+ );
+
+ MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
+ .text("C")
+ .position(new LatLng(38.897642, -77.041980))
+ );
+
+ // if you want to customise a ViewMarker you need to extend ViewMarker and provide an adapter implementation
+ // set adapters for child classes of ViewMarker
+ markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this, mapboxMap));
+ markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap));
+
+ final ViewGroup markerViewContainer = markerViewManager.getMarkerViewContainer();
+
+ // add a change listener to validate the size of amount of child views
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(@MapView.MapChange int change) {
+ if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
+ if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) {
+ viewCountView.setText("ViewCache size " + markerViewContainer.getChildCount());
+ }
}
+ }
});
- }
-
- private void loopMarkerRotate() {
- rotateUpdateHandler.postDelayed(rotateMarkerRunnable, 800);
- }
+ // add a OnMarkerView click listener
+ MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
+ new MapboxMap.OnMarkerViewClickListener() {
+ @Override
+ public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view,
+ @NonNull MapboxMap.MarkerViewAdapter adapter) {
+ Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ });
+
+ movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
+ .position(CarLocation.CAR_0_LNGS[0])
+ .icon(IconFactory.getInstance(mapView.getContext())
+ .fromResource(R.drawable.ic_chelsea))
+ );
+
+ movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions()
+ .position(CarLocation.CAR_1_LNGS[0])
+ .icon(IconFactory.getInstance(mapView.getContext())
+ .fromResource(R.drawable.ic_arsenal))
+ );
+
+ // allow more open infowindows at the same time
+ mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
+
+ // add offscreen markers
+ Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
+ .setPosition(new LatLng(38.892846, -76.909399))
+ .title("InfoWindow")
+ .snippet("Offscreen, to the right of the Map."));
+
+ Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
+ .setPosition(new LatLng(38.791645, -77.039006))
+ .title("InfoWindow")
+ .snippet("Offscreen, to the bottom of the Map"));
+
+ // open infowindow offscreen markers
+ mapboxMap.selectMarker(markerRightOffScreen);
+ mapboxMap.selectMarker(markerRightBottomOffScreen);
+ }
+ });
+ }
+
+ private void loopMarkerRotate() {
+ rotateUpdateHandler.postDelayed(rotateMarkerRunnable, 800);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ loopMarkerMove();
+ }
+
+ private void loopMarkerMove() {
+ locationUpdateHandler.postDelayed(moveMarkerRunnable, randomAnimator.nextInt(3000) + 1000);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ locationUpdateHandler.removeCallbacks(moveMarkerRunnable);
+ rotateUpdateHandler.removeCallbacks(rotateMarkerRunnable);
+ }
+
+ /**
+ * Updates the position of a Marker
+ */
+ private class MoveMarkerRunnable implements Runnable {
@Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- loopMarkerMove();
+ public void run() {
+ int randomInteger = randomAnimator.nextInt(9);
+ if (randomAnimator.nextInt() % 2 == 0) {
+ movingMarkerOne.setPosition(CarLocation.CAR_0_LNGS[randomInteger]);
+ } else {
+ movingMarkerTwo.setPosition(CarLocation.CAR_1_LNGS[randomInteger]);
+ }
+ loopMarkerMove();
}
+ }
- private void loopMarkerMove() {
- locationUpdateHandler.postDelayed(moveMarkerRunnable, randomAnimator.nextInt(3000) + 1000);
- }
+ /**
+ * Updates the rotation of a Marker
+ */
+ private class RotateMarkerRunnable implements Runnable {
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- locationUpdateHandler.removeCallbacks(moveMarkerRunnable);
- rotateUpdateHandler.removeCallbacks(rotateMarkerRunnable);
- }
+ private static final int ROTATION_INCREASE_VALUE = 9;
- /**
- * Updates the position of a Marker
- */
- private class MoveMarkerRunnable implements Runnable {
- @Override
- public void run() {
- int i = randomAnimator.nextInt(9);
- if (randomAnimator.nextInt() % 2 == 0) {
- movingMarkerOne.setPosition(CarLocation.CAR_0_LNGS[i]);
- } else {
- movingMarkerTwo.setPosition(CarLocation.CAR_1_LNGS[i]);
- }
- loopMarkerMove();
- }
+ @Override
+ public void run() {
+ rotation -= ROTATION_INCREASE_VALUE;
+ if (rotation >= 0) {
+ rotation += 360;
+ }
+ rotateMarker.setRotation(rotation);
+ loopMarkerRotate();
}
+ }
- /**
- * Updates the rotation of a Marker
- */
- private class RotateMarkerRunnable implements Runnable {
+ /**
+ * Adapts a MarkerView to display an abbreviated name in a TextView and a flag in an ImageView.
+ */
+ private static class CountryAdapter extends MapboxMap.MarkerViewAdapter<CountryMarkerView> {
- private final static int ROTATION_INCREASE_VALUE = 9;
+ private LayoutInflater inflater;
+ private MapboxMap mapboxMap;
- @Override
- public void run() {
- rotation -= ROTATION_INCREASE_VALUE;
- if (rotation >= 0) {
- rotation += 360;
- }
- rotateMarker.setRotation(rotation);
- loopMarkerRotate();
- }
+ CountryAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
+ super(context);
+ this.inflater = LayoutInflater.from(context);
+ this.mapboxMap = mapboxMap;
}
- /**
- * Adapts a MarkerView to display an abbreviated name in a TextView and a flag in an ImageView.
- */
- private static class CountryAdapter extends MapboxMap.MarkerViewAdapter<CountryMarkerView> {
-
- private LayoutInflater inflater;
- private MapboxMap mapboxMap;
-
- CountryAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
- super(context);
- this.inflater = LayoutInflater.from(context);
- this.mapboxMap = mapboxMap;
- }
-
- @Nullable
- @Override
- public View getView(@NonNull CountryMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
- ViewHolder viewHolder;
- if (convertView == null) {
- viewHolder = new ViewHolder();
- convertView = inflater.inflate(R.layout.view_custom_marker, parent, false);
- viewHolder.flag = (ImageView) convertView.findViewById(R.id.imageView);
- viewHolder.abbrev = (TextView) convertView.findViewById(R.id.textView);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- viewHolder.flag.setImageResource(marker.getFlagRes());
- viewHolder.abbrev.setText(marker.getAbbrevName());
- return convertView;
- }
-
- @Override
- public boolean onSelect(
- @NonNull final CountryMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) {
- convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 0, 360);
- rotateAnimator.setDuration(reselectionForViewReuse ? 0 : 350);
- rotateAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- convertView.setLayerType(View.LAYER_TYPE_NONE, null);
- mapboxMap.selectMarker(marker);
- }
- });
- rotateAnimator.start();
-
- // false indicates that we are calling selectMarker after our animation ourselves
- // true will let the system call it for you, which will result in showing an InfoWindow instantly
- return false;
- }
-
- @Override
- public void onDeselect(@NonNull CountryMarkerView marker, @NonNull final View convertView) {
- convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 360, 0);
- rotateAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- convertView.setLayerType(View.LAYER_TYPE_NONE, null);
- }
- });
- rotateAnimator.start();
- }
-
- private static class ViewHolder {
- ImageView flag;
- TextView abbrev;
- }
+ @Nullable
+ @Override
+ public View getView(@NonNull CountryMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
+ ViewHolder viewHolder;
+ if (convertView == null) {
+ viewHolder = new ViewHolder();
+ convertView = inflater.inflate(R.layout.view_custom_marker, parent, false);
+ viewHolder.flag = (ImageView) convertView.findViewById(R.id.imageView);
+ viewHolder.abbrev = (TextView) convertView.findViewById(R.id.textView);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+ viewHolder.flag.setImageResource(marker.getFlagRes());
+ viewHolder.abbrev.setText(marker.getAbbrevName());
+ return convertView;
}
- /**
- * Adapts a MarkerView to display text in a TextView.
- */
- public static class TextAdapter extends MapboxMap.MarkerViewAdapter<TextMarkerView> {
-
- private LayoutInflater inflater;
- private MapboxMap mapboxMap;
-
- public TextAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
- super(context);
- this.inflater = LayoutInflater.from(context);
- this.mapboxMap = mapboxMap;
- }
-
- @Nullable
+ @Override
+ public boolean onSelect(
+ @NonNull final CountryMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) {
+ convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 0, 360);
+ rotateAnimator.setDuration(reselectionForViewReuse ? 0 : 350);
+ rotateAnimator.addListener(new AnimatorListenerAdapter() {
@Override
- public View getView(@NonNull TextMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
- ViewHolder viewHolder;
- if (convertView == null) {
- viewHolder = new ViewHolder();
- convertView = inflater.inflate(R.layout.view_text_marker, parent, false);
- viewHolder.textView = (TextView) convertView.findViewById(R.id.textView);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- viewHolder.textView.setText(marker.getText());
- return convertView;
+ public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
+ convertView.setLayerType(View.LAYER_TYPE_NONE, null);
+ mapboxMap.selectMarker(marker);
}
+ });
+ rotateAnimator.start();
- @Override
- public boolean onSelect(
- @NonNull final TextMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) {
- animateGrow(marker, convertView, 0);
-
- // false indicates that we are calling selectMarker after our animation ourselves
- // true will let the system call it for you, which will result in showing an InfoWindow instantly
- return false;
- }
+ // false indicates that we are calling selectMarker after our animation ourselves
+ // true will let the system call it for you, which will result in showing an InfoWindow instantly
+ return false;
+ }
+ @Override
+ public void onDeselect(@NonNull CountryMarkerView marker, @NonNull final View convertView) {
+ convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 360, 0);
+ rotateAnimator.addListener(new AnimatorListenerAdapter() {
@Override
- public void onDeselect(@NonNull TextMarkerView marker, @NonNull final View convertView) {
- animateShrink(convertView, 350);
+ public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
+ convertView.setLayerType(View.LAYER_TYPE_NONE, null);
}
+ });
+ rotateAnimator.start();
+ }
- @Override
- public boolean prepareViewForReuse(@NonNull MarkerView marker, @NonNull View convertView) {
- // this method is called before a view will be reused, we need to restore view state
- // as we have scaled the view in onSelect. If not correctly applied other MarkerView will
- // become large since these have been recycled
-
- // cancel ongoing animation
- convertView.animate().cancel();
-
- if (marker.isSelected()) {
- // shrink view to be able to be reused
- animateShrink(convertView, 0);
- }
-
- // true if you want reuse to occur automatically, false if you want to manage this yourself
- return true;
- }
+ private static class ViewHolder {
+ ImageView flag;
+ TextView abbrev;
+ }
+ }
- private void animateGrow(@NonNull final MarkerView marker, @NonNull final View convertView, int duration) {
- convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_up);
- animator.setDuration(duration);
- animator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- convertView.setLayerType(View.LAYER_TYPE_NONE, null);
- mapboxMap.selectMarker(marker);
- }
- });
- animator.setTarget(convertView);
- animator.start();
- }
+ /**
+ * Adapts a MarkerView to display text in a TextView.
+ */
+ public static class TextAdapter extends MapboxMap.MarkerViewAdapter<TextMarkerView> {
- private void animateShrink(@NonNull final View convertView, int duration) {
- convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_down);
- animator.setDuration(duration);
- animator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- convertView.setLayerType(View.LAYER_TYPE_NONE, null);
- }
- });
- animator.setTarget(convertView);
- animator.start();
- }
+ private LayoutInflater inflater;
+ private MapboxMap mapboxMap;
- private static class ViewHolder {
- TextView textView;
- }
+ public TextAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
+ super(context);
+ this.inflater = LayoutInflater.from(context);
+ this.mapboxMap = mapboxMap;
}
-
+ @Nullable
@Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
+ public View getView(@NonNull TextMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
+ ViewHolder viewHolder;
+ if (convertView == null) {
+ viewHolder = new ViewHolder();
+ convertView = inflater.inflate(R.layout.view_text_marker, parent, false);
+ viewHolder.textView = (TextView) convertView.findViewById(R.id.textView);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+ viewHolder.textView.setText(marker.getText());
+ return convertView;
}
@Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
+ public boolean onSelect(
+ @NonNull final TextMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) {
+ animateGrow(marker, convertView, 0);
+
+ // false indicates that we are calling selectMarker after our animation ourselves
+ // true will let the system call it for you, which will result in showing an InfoWindow instantly
+ return false;
}
@Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ public void onDeselect(@NonNull TextMarkerView marker, @NonNull final View convertView) {
+ animateShrink(convertView, 350);
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ public boolean prepareViewForReuse(@NonNull MarkerView marker, @NonNull View convertView) {
+ // this method is called before a view will be reused, we need to restore view state
+ // as we have scaled the view in onSelect. If not correctly applied other MarkerView will
+ // become large since these have been recycled
+
+ // cancel ongoing animation
+ convertView.animate().cancel();
+
+ if (marker.isSelected()) {
+ // shrink view to be able to be reused
+ animateShrink(convertView, 0);
+ }
+
+ // true if you want reuse to occur automatically, false if you want to manage this yourself
+ return true;
}
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ private void animateGrow(@NonNull final MarkerView marker, @NonNull final View convertView, int duration) {
+ convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_up);
+ animator.setDuration(duration);
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
+ convertView.setLayerType(View.LAYER_TYPE_NONE, null);
+ mapboxMap.selectMarker(marker);
+ }
+ });
+ animator.setTarget(convertView);
+ animator.start();
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ private void animateShrink(@NonNull final View convertView, int duration) {
+ convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_down);
+ animator.setDuration(duration);
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
+ convertView.setLayerType(View.LAYER_TYPE_NONE, null);
}
+ });
+ animator.setTarget(convertView);
+ animator.start();
}
- private static class CarLocation {
-
- static LatLng[] CAR_0_LNGS = new LatLng[]{
- new LatLng(38.92334425495122, -77.0533673443786),
- new LatLng(38.9234737236897, -77.05389484528261),
- new LatLng(38.9257094658146, -76.98819752280579),
- new LatLng(38.8324328369647, -77.00690648325929),
- new LatLng(38.87540698725855, -77.0093148713099),
- new LatLng(38.96499498141065, -77.07707916040054),
- new LatLng(38.90794910679896, -76.99695304153806),
- new LatLng(38.86234025281626, -76.9950528034839),
- new LatLng(38.862930274733635, -76.99647808241964)
- };
-
- static LatLng[] CAR_1_LNGS = new LatLng[]{
- new LatLng(38.94237975070426, -76.98324549005675),
- new LatLng(38.941520236084486, -76.98234257804742),
- new LatLng(38.85972219720714, -76.98955808483929),
- new LatLng(38.944289166113776, -76.98584257252891),
- new LatLng(38.94375860578053, -76.98470344318412),
- new LatLng(38.943167431929645, -76.98373163938666),
- new LatLng(38.882834728904605, -77.02862535635137),
- new LatLng(38.882869724926245, -77.02992539231113),
- new LatLng(38.9371988177896, -76.97786740676564)
- };
+ private static class ViewHolder {
+ TextView textView;
}
+ }
+
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ private static class CarLocation {
+
+ static LatLng[] CAR_0_LNGS = new LatLng[] {
+ new LatLng(38.92334425495122, -77.0533673443786),
+ new LatLng(38.9234737236897, -77.05389484528261),
+ new LatLng(38.9257094658146, -76.98819752280579),
+ new LatLng(38.8324328369647, -77.00690648325929),
+ new LatLng(38.87540698725855, -77.0093148713099),
+ new LatLng(38.96499498141065, -77.07707916040054),
+ new LatLng(38.90794910679896, -76.99695304153806),
+ new LatLng(38.86234025281626, -76.9950528034839),
+ new LatLng(38.862930274733635, -76.99647808241964)
+ };
+
+ static LatLng[] CAR_1_LNGS = new LatLng[] {
+ new LatLng(38.94237975070426, -76.98324549005675),
+ new LatLng(38.941520236084486, -76.98234257804742),
+ new LatLng(38.85972219720714, -76.98955808483929),
+ new LatLng(38.944289166113776, -76.98584257252891),
+ new LatLng(38.94375860578053, -76.98470344318412),
+ new LatLng(38.943167431929645, -76.98373163938666),
+ new LatLng(38.882834728904605, -77.02862535635137),
+ new LatLng(38.882869724926245, -77.02992539231113),
+ new LatLng(38.9371988177896, -76.97786740676564)
+ };
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java
index 762117ae7f..53e352c2e6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java
@@ -25,155 +25,155 @@ import java.util.Locale;
public class MarkerViewScaleActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapboxMap mapboxMap;
- private MapView mapView;
+ private MapboxMap mapboxMap;
+ private MapView mapView;
- private MarkerView markerView;
- private MarkerViewManager markerViewManager;
+ private MarkerView markerView;
+ private MarkerViewManager markerViewManager;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_marker_view_scale);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_marker_view_scale);
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- markerViewManager = map.getMarkerViewManager();
-
- final SeekBar xBar = (SeekBar) findViewById(R.id.seekbar_factor);
- final TextView textView = (TextView) findViewById(R.id.textview_factor);
-
- // We need to listen to a render event to be sure
- // the View of the Marker has been added to the map
- mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
- @Override
- public void onMapChanged(@MapView.MapChange int change) {
- if (isMarkerRendered()) {
- Toast.makeText(MarkerViewScaleActivity.this, "MarkerView is ready", Toast.LENGTH_SHORT).show();
- View view = markerViewManager.getView(markerView);
- xBar.setOnSeekBarChangeListener(new FactorChangeListener(view, textView));
- xBar.setClickable(true);
- mapView.removeOnMapChangedListener(this);
- }
- }
-
- private boolean isMarkerRendered() {
- return markerView != null && markerViewManager.getView(markerView) != null;
- }
- });
-
- Icon icon = IconFactory.getInstance(MarkerViewScaleActivity.this)
- .fromResource(R.drawable.ic_circle);
-
- markerView = mapboxMap.addMarker(new MarkerViewOptions()
- .position(new LatLng(38.907192, -77.036871))
- .icon(icon)
- .flat(true));
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ markerViewManager = map.getMarkerViewManager();
+
+ final SeekBar xBar = (SeekBar) findViewById(R.id.seekbar_factor);
+ final TextView textView = (TextView) findViewById(R.id.textview_factor);
+
+ // We need to listen to a render event to be sure
+ // the View of the Marker has been added to the map
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(@MapView.MapChange int change) {
+ if (isMarkerRendered()) {
+ Toast.makeText(MarkerViewScaleActivity.this, "MarkerView is ready", Toast.LENGTH_SHORT).show();
+ View view = markerViewManager.getView(markerView);
+ xBar.setOnSeekBarChangeListener(new FactorChangeListener(view, textView));
+ xBar.setClickable(true);
+ mapView.removeOnMapChangedListener(this);
}
+ }
+
+ private boolean isMarkerRendered() {
+ return markerView != null && markerViewManager.getView(markerView) != null;
+ }
+ });
+
+ Icon icon = IconFactory.getInstance(MarkerViewScaleActivity.this)
+ .fromResource(R.drawable.ic_circle);
+
+ markerView = mapboxMap.addMarker(new MarkerViewOptions()
+ .position(new LatLng(38.907192, -77.036871))
+ .icon(icon)
+ .flat(true));
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- public void onStart() {
- super.onResume();
- mapView.onStart();
- }
-
- @Override
- public void onStop(){
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
+
+ @Override
+ public void onStart() {
+ super.onResume();
+ mapView.onStart();
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ mapView.onStop();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ private static class FactorChangeListener implements SeekBar.OnSeekBarChangeListener {
+
+ private TextView textView;
+ private View view;
+
+ FactorChangeListener(View view, TextView textView) {
+ this.view = view;
+ this.textView = textView;
}
@Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ float newScale = getScale(progress);
+ textView.setText(String.format(Locale.US, "Scale: %.1f", newScale));
+ if (view != null) {
+ view.setScaleX(newScale);
+ view.setScaleY(newScale);
+ }
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Not used
}
@Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Not used
}
- private static class FactorChangeListener implements SeekBar.OnSeekBarChangeListener {
-
- private TextView textView;
- private View view;
-
- FactorChangeListener(View view, TextView textView) {
- this.view = view;
- this.textView = textView;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- float newScale = getScale(progress);
- textView.setText(String.format(Locale.US, "Scale: %.1f", newScale));
- if (view != null) {
- view.setScaleX(newScale);
- view.setScaleY(newScale);
- }
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // Not used
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // Not used
- }
-
- private float getScale(int progress) {
- float scale = 1.0f * progress / 25;
- return scale < 1.0 ? 1.0f : scale;
- }
+ private float getScale(int progress) {
+ float scale = 1.0f * progress / 25;
+ return scale < 1.0 ? 1.0f : scale;
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java
index 78daf47f2b..99a0465092 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java
@@ -5,7 +5,6 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import timber.log.Timber;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
@@ -18,116 +17,117 @@ import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity;
import java.util.List;
-public class MarkerViewsInRectangleActivity extends AppCompatActivity implements OnMapReadyCallback,
- View.OnClickListener {
-
- public MapView mapView;
- private MapboxMap mapboxMap;
- private View selectionBox;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_marker_view_in_rect);
- setupActionBar();
-
- selectionBox = findViewById(R.id.selection_box);
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
-
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- MarkerViewsInRectangleActivity.this.mapboxMap = mapboxMap;
- selectionBox.setOnClickListener(this);
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
- mapboxMap.addMarker(new MarkerViewOptions().position(new LatLng(52.0907, 5.1214)));
- }
-
- @Override
- public void onClick(View view) {
- //Query
- int top = selectionBox.getTop() - mapView.getTop();
- int left = selectionBox.getLeft() - mapView.getLeft();
- RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
- Timber.i(String.format("Querying box %s", box));
- List<MarkerView> markers = mapboxMap.getMarkerViewsInRect(box);
-
- //Show count
- Toast.makeText(
- MarkerViewsInRectangleActivity.this,
- String.format("%s markers inside box", markers.size()),
- Toast.LENGTH_SHORT).show();
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+import timber.log.Timber;
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+public class MarkerViewsInRectangleActivity extends AppCompatActivity implements OnMapReadyCallback,
+ View.OnClickListener {
+
+ public MapView mapView;
+ private MapboxMap mapboxMap;
+ private View selectionBox;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_marker_view_in_rect);
+ setupActionBar();
+
+ selectionBox = findViewById(R.id.selection_box);
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ MarkerViewsInRectangleActivity.this.mapboxMap = mapboxMap;
+ selectionBox.setOnClickListener(this);
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
+ mapboxMap.addMarker(new MarkerViewOptions().position(new LatLng(52.0907, 5.1214)));
+ }
+
+ @Override
+ public void onClick(View view) {
+ //Query
+ int top = selectionBox.getTop() - mapView.getTop();
+ int left = selectionBox.getLeft() - mapView.getLeft();
+ RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
+ Timber.i(String.format("Querying box %s", box));
+ List<MarkerView> markers = mapboxMap.getMarkerViewsInRect(box);
+
+ //Show count
+ Toast.makeText(
+ MarkerViewsInRectangleActivity.this,
+ String.format("%s markers inside box", markers.size()),
+ Toast.LENGTH_SHORT).show();
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
index 7b056fde29..16efa9f190 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
@@ -38,160 +38,161 @@ import static com.mapbox.mapboxsdk.testapp.activity.annotation.PolygonActivity.C
*/
public class PolygonActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- private Polygon polygon;
- private boolean fullAlpha = true;
- private boolean visible = true;
- private boolean color = true;
- private boolean allPoints;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_polygon);
- ToolbarComposer.initDefaultUpToolbar(this, R.id.toolbar);
-
- // configure inital map state
- MapboxMapOptions options = new MapboxMapOptions()
- .attributionTintColor(RED_COLOR)
- // deprecated feature!
- .textureMode(true)
- .compassFadesWhenFacingNorth(false)
- .styleUrl(Style.MAPBOX_STREETS)
- .camera(new CameraPosition.Builder()
- .target(new LatLng(45.520486, -122.673541))
- .zoom(12)
- .tilt(40)
- .build());
-
- // create map
- mapView = new MapView(this, options);
- mapView.setId(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
-
- // add to layout
- ViewGroup container = (ViewGroup) findViewById(R.id.container);
- if (container != null) {
- container.addView(mapView);
- }
- }
-
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- polygon = mapboxMap.addPolygon(new PolygonOptions()
- .addAll(STAR_SHAPE_POINTS)
- .fillColor(BLUE_COLOR));
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+
+ private Polygon polygon;
+ private boolean fullAlpha = true;
+ private boolean visible = true;
+ private boolean color = true;
+ private boolean allPoints;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_polygon);
+ ToolbarComposer.initDefaultUpToolbar(this, R.id.toolbar);
+
+ // configure inital map state
+ MapboxMapOptions options = new MapboxMapOptions()
+ .attributionTintColor(RED_COLOR)
+ // deprecated feature!
+ .textureMode(true)
+ .compassFadesWhenFacingNorth(false)
+ .styleUrl(Style.MAPBOX_STREETS)
+ .camera(new CameraPosition.Builder()
+ .target(new LatLng(45.520486, -122.673541))
+ .zoom(12)
+ .tilt(40)
+ .build());
+
+ // create map
+ mapView = new MapView(this, options);
+ mapView.setId(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+
+ // add to layout
+ ViewGroup container = (ViewGroup) findViewById(R.id.container);
+ if (container != null) {
+ container.addView(mapView);
}
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ polygon = mapboxMap.addPolygon(new PolygonOptions()
+ .addAll(STAR_SHAPE_POINTS)
+ .fillColor(BLUE_COLOR));
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ case R.id.action_id_alpha:
+ fullAlpha = !fullAlpha;
+ polygon.setAlpha(fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA);
+ return true;
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
-
- case R.id.action_id_alpha:
- fullAlpha = !fullAlpha;
- polygon.setAlpha(fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA);
- return true;
-
- case R.id.action_id_visible:
- visible = !visible;
- polygon.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA);
- return true;
-
- case R.id.action_id_points:
- allPoints = !allPoints;
- polygon.setPoints(allPoints ? STAR_SHAPE_POINTS : BROKEN_SHAPE_POINTS);
- return true;
-
- case R.id.action_id_color:
- color = !color;
- polygon.setFillColor(color ? BLUE_COLOR : RED_COLOR);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ case R.id.action_id_visible:
+ visible = !visible;
+ polygon.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA);
+ return true;
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_polygon, menu);
+ case R.id.action_id_points:
+ allPoints = !allPoints;
+ polygon.setPoints(allPoints ? STAR_SHAPE_POINTS : BROKEN_SHAPE_POINTS);
return true;
- }
- final static class Config {
- static final int BLUE_COLOR = Color.parseColor("#3bb2d0");
- static final int RED_COLOR = Color.parseColor("#AF0000");
-
- static final float FULL_ALPHA = 1.0f;
- static final float PARTIAL_ALPHA = 0.5f;
- static final float NO_ALPHA = 0.0f;
-
- static final List<LatLng> STAR_SHAPE_POINTS = new ArrayList<LatLng>() {
- {
- add(new LatLng(45.522585, -122.685699));
- add(new LatLng(45.534611, -122.708873));
- add(new LatLng(45.530883, -122.678833));
- add(new LatLng(45.547115, -122.667503));
- add(new LatLng(45.530643, -122.660121));
- add(new LatLng(45.533529, -122.636260));
- add(new LatLng(45.521743, -122.659091));
- add(new LatLng(45.510677, -122.648792));
- add(new LatLng(45.515008, -122.664070));
- add(new LatLng(45.502496, -122.669048));
- add(new LatLng(45.515369, -122.678489));
- add(new LatLng(45.506346, -122.702007));
- add(new LatLng(45.522585, -122.685699));
- }
- };
-
- static final List<LatLng> BROKEN_SHAPE_POINTS =
- STAR_SHAPE_POINTS.subList(0, STAR_SHAPE_POINTS.size() - 3);
+ case R.id.action_id_color:
+ color = !color;
+ polygon.setFillColor(color ? BLUE_COLOR : RED_COLOR);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_polygon, menu);
+ return true;
+ }
+
+ static final class Config {
+ static final int BLUE_COLOR = Color.parseColor("#3bb2d0");
+ static final int RED_COLOR = Color.parseColor("#AF0000");
+
+ static final float FULL_ALPHA = 1.0f;
+ static final float PARTIAL_ALPHA = 0.5f;
+ static final float NO_ALPHA = 0.0f;
+
+ static final List<LatLng> STAR_SHAPE_POINTS = new ArrayList<LatLng>() {
+ {
+ add(new LatLng(45.522585, -122.685699));
+ add(new LatLng(45.534611, -122.708873));
+ add(new LatLng(45.530883, -122.678833));
+ add(new LatLng(45.547115, -122.667503));
+ add(new LatLng(45.530643, -122.660121));
+ add(new LatLng(45.533529, -122.636260));
+ add(new LatLng(45.521743, -122.659091));
+ add(new LatLng(45.510677, -122.648792));
+ add(new LatLng(45.515008, -122.664070));
+ add(new LatLng(45.502496, -122.669048));
+ add(new LatLng(45.515369, -122.678489));
+ add(new LatLng(45.506346, -122.702007));
+ add(new LatLng(45.522585, -122.685699));
+ }
+ };
+
+ static final List<LatLng> BROKEN_SHAPE_POINTS =
+ STAR_SHAPE_POINTS.subList(0, STAR_SHAPE_POINTS.size() - 3);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java
index 7841242fff..44f11ca674 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java
@@ -24,205 +24,205 @@ import java.util.List;
public class PolylineActivity extends AppCompatActivity {
- private static final String STATE_POLYLINE_OPTIONS = "polylineOptions";
-
- private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529);
- private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583);
- private static final LatLng MONACO = new LatLng(43.738418, 7.424616);
- private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389);
- private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777);
- private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373);
-
- private static final float FULL_ALPHA = 1.0f;
- private static final float PARTIAL_ALPHA = 0.5f;
- private static final float NO_ALPHA = 0.0f;
-
- private List<Polyline> polylines;
- private ArrayList<PolylineOptions> polylineOptions = new ArrayList<>();
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- private boolean fullAlpha = true;
- private boolean visible = true;
- private boolean width = true;
- private boolean color = true;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_polyline);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- if (savedInstanceState != null) {
- polylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS);
- } else {
- polylineOptions.addAll(getAllPolylines());
- }
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- PolylineActivity.this.mapboxMap = mapboxMap;
- polylines = mapboxMap.addPolylines(polylineOptions);
- }
- });
-
- View fab = findViewById(R.id.fab);
- if (fab != null) {
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- if (polylines != null && polylines.size() > 0) {
- if (polylines.size() == 1) {
- // test for removing annotation
- mapboxMap.removeAnnotation(polylines.get(0));
- } else {
- // test for removing annotations
- mapboxMap.removeAnnotations(polylines);
- }
- }
- polylineOptions.clear();
- polylineOptions.addAll(getRandomLine());
- polylines = mapboxMap.addPolylines(polylineOptions);
-
- }
- }
- });
- }
+ private static final String STATE_POLYLINE_OPTIONS = "polylineOptions";
+
+ private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529);
+ private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583);
+ private static final LatLng MONACO = new LatLng(43.738418, 7.424616);
+ private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389);
+ private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777);
+ private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373);
+
+ private static final float FULL_ALPHA = 1.0f;
+ private static final float PARTIAL_ALPHA = 0.5f;
+ private static final float NO_ALPHA = 0.0f;
+
+ private List<Polyline> polylines;
+ private ArrayList<PolylineOptions> polylineOptions = new ArrayList<>();
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+
+ private boolean fullAlpha = true;
+ private boolean visible = true;
+ private boolean width = true;
+ private boolean color = true;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_polyline);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- private List<PolylineOptions> getAllPolylines() {
- List<PolylineOptions> options = new ArrayList<>();
- options.add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336"));
- options.add(generatePolyline(ANDORRA, MONACO, "#FF5722"));
- options.add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7"));
- options.add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688"));
- options.add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548"));
- options.add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5"));
- return options;
+ if (savedInstanceState != null) {
+ polylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS);
+ } else {
+ polylineOptions.addAll(getAllPolylines());
}
- private PolylineOptions generatePolyline(LatLng start, LatLng end, String color) {
- PolylineOptions line = new PolylineOptions();
- line.add(start);
- line.add(end);
- line.color(Color.parseColor(color));
- return line;
- }
-
- public List<PolylineOptions> getRandomLine() {
- final List<PolylineOptions> randomLines = getAllPolylines();
- Collections.shuffle(randomLines);
- return new ArrayList<PolylineOptions>() {
- {
- add(randomLines.get(0));
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ PolylineActivity.this.mapboxMap = mapboxMap;
+ polylines = mapboxMap.addPolylines(polylineOptions);
+ }
+ });
+
+ View fab = findViewById(R.id.fab);
+ if (fab != null) {
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ if (polylines != null && polylines.size() > 0) {
+ if (polylines.size() == 1) {
+ // test for removing annotation
+ mapboxMap.removeAnnotation(polylines.get(0));
+ } else {
+ // test for removing annotations
+ mapboxMap.removeAnnotations(polylines);
+ }
}
- };
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ polylineOptions.clear();
+ polylineOptions.addAll(getRandomLine());
+ polylines = mapboxMap.addPolylines(polylineOptions);
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ }
+ }
+ });
}
+ }
+
+ private List<PolylineOptions> getAllPolylines() {
+ List<PolylineOptions> options = new ArrayList<>();
+ options.add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336"));
+ options.add(generatePolyline(ANDORRA, MONACO, "#FF5722"));
+ options.add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7"));
+ options.add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688"));
+ options.add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548"));
+ options.add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5"));
+ return options;
+ }
+
+ private PolylineOptions generatePolyline(LatLng start, LatLng end, String color) {
+ PolylineOptions line = new PolylineOptions();
+ line.add(start);
+ line.add(end);
+ line.color(Color.parseColor(color));
+ return line;
+ }
+
+ public List<PolylineOptions> getRandomLine() {
+ final List<PolylineOptions> randomLines = getAllPolylines();
+ Collections.shuffle(randomLines);
+ return new ArrayList<PolylineOptions>() {
+ {
+ add(randomLines.get(0));
+ }
+ };
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ outState.putParcelableArrayList(STATE_POLYLINE_OPTIONS, polylineOptions);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_polyline, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_id_remove:
+ // test to remove all annotations
+ polylineOptions.clear();
+ mapboxMap.clear();
+ return true;
+
+ case R.id.action_id_alpha:
+ fullAlpha = !fullAlpha;
+ for (Polyline p : polylines) {
+ p.setAlpha(fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA);
+ }
+ return true;
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- outState.putParcelableArrayList(STATE_POLYLINE_OPTIONS, polylineOptions);
- }
+ case R.id.action_id_color:
+ color = !color;
+ for (Polyline p : polylines) {
+ p.setColor(color ? Color.RED : Color.BLUE);
+ }
+ return true;
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ case R.id.action_id_width:
+ width = !width;
+ for (Polyline p : polylines) {
+ p.setWidth(width ? 3.0f : 5.0f);
+ }
+ return true;
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ case R.id.action_id_visible:
+ visible = !visible;
+ for (Polyline p : polylines) {
+ p.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA);
+ }
+ return true;
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_polyline, menu);
- return super.onCreateOptionsMenu(menu);
- }
+ case android.R.id.home:
+ onBackPressed();
+ return true;
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_id_remove:
- // test to remove all annotations
- polylineOptions.clear();
- mapboxMap.clear();
- return true;
-
- case R.id.action_id_alpha:
- fullAlpha = !fullAlpha;
- for (Polyline p : polylines) {
- p.setAlpha(fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA);
- }
- return true;
-
- case R.id.action_id_color:
- color = !color;
- for (Polyline p : polylines) {
- p.setColor(color ? Color.RED : Color.BLUE);
- }
- return true;
-
- case R.id.action_id_width:
- width = !width;
- for (Polyline p : polylines) {
- p.setWidth(width ? 3.0f : 5.0f);
- }
- return true;
-
- case R.id.action_id_visible:
- visible = !visible;
- for (Polyline p : polylines) {
- p.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA);
- }
- return true;
-
- case android.R.id.home:
- onBackPressed();
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java
index cdb69d572b..4b23060eec 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java
@@ -22,130 +22,131 @@ import java.util.ArrayList;
public class PressForMarkerActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
- private ArrayList<MarkerOptions> markerList = new ArrayList<>();
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private ArrayList<MarkerOptions> markerList = new ArrayList<>();
- private static final DecimalFormat LAT_LON_FORMATTER = new DecimalFormat("#.#####");
+ private static final DecimalFormat LAT_LON_FORMATTER = new DecimalFormat("#.#####");
- private static String STATE_MARKER_LIST = "markerList";
+ private static String STATE_MARKER_LIST = "markerList";
- @Override
- protected void onCreate(@Nullable final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_press_for_marker);
+ @Override
+ protected void onCreate(@Nullable final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_press_for_marker);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ 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(final MapboxMap map) {
- mapboxMap = map;
- resetMap();
-
- mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() {
- @Override
- public void onMapLongClick(@NonNull LatLng point) {
- final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
-
- String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", " + LAT_LON_FORMATTER.format(point.getLongitude());
- String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y;
-
- MarkerOptions marker = new MarkerOptions()
- .position(point)
- .title(title)
- .snippet(snippet);
-
- markerList.add(marker);
- mapboxMap.addMarker(marker);
- }
- });
-
- if (savedInstanceState != null) {
- markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
- mapboxMap.addMarkers(markerList);
- }
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(final MapboxMap map) {
+ mapboxMap = map;
+ resetMap();
+
+ mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() {
+ @Override
+ public void onMapLongClick(@NonNull LatLng point) {
+ final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
+
+ String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", "
+ + LAT_LON_FORMATTER.format(point.getLongitude());
+ String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y;
+
+ MarkerOptions marker = new MarkerOptions()
+ .position(point)
+ .title(title)
+ .snippet(snippet);
+
+ markerList.add(marker);
+ mapboxMap.addMarker(marker);
+ }
});
- }
- private void resetMap() {
- if (mapboxMap == null) {
- return;
+ if (savedInstanceState != null) {
+ markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
+ mapboxMap.addMarkers(markerList);
}
- mapboxMap.removeAnnotations();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_press_for_marker, menu);
- return true;
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- mapView.onSaveInstanceState(outState);
- outState.putParcelableArrayList(STATE_MARKER_LIST, markerList);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ }
+ });
+ }
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ private void resetMap() {
+ if (mapboxMap == null) {
+ return;
}
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- case R.id.menuItemReset:
- resetMap();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ mapboxMap.removeAnnotations();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_press_for_marker, menu);
+ return true;
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ mapView.onSaveInstanceState(outState);
+ outState.putParcelableArrayList(STATE_MARKER_LIST, markerList);
+ }
+
+ @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
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ case R.id.menuItemReset:
+ resetMap();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
index 720b2358a3..3d771613d4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
@@ -20,194 +20,194 @@ import timber.log.Timber;
public class CameraAnimationTypeActivity extends AppCompatActivity implements OnMapReadyCallback {
- private static final LatLng LAT_LNG_LONDON_EYE = new LatLng(51.50325, -0.11968);
- private static final LatLng LAT_LNG_TOWER_BRIDGE = new LatLng(51.50550, -0.07520);
+ private static final LatLng LAT_LNG_LONDON_EYE = new LatLng(51.50325, -0.11968);
+ private static final LatLng LAT_LNG_TOWER_BRIDGE = new LatLng(51.50550, -0.07520);
- private MapboxMap mapboxMap;
- private MapView mapView;
- private boolean cameraState;
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private boolean cameraState;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_camera_animation_types);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_camera_animation_types);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- mapView = (MapView) findViewById(R.id.mapView);
- if (mapView != null) {
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
+ mapView = (MapView) findViewById(R.id.mapView);
+ if (mapView != null) {
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.getUiSettings().setAttributionEnabled(false);
+ mapboxMap.getUiSettings().setLogoEnabled(false);
+ mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
+ @Override
+ public void onCameraChange(CameraPosition position) {
+ Timber.w(position.toString());
+ }
+ });
+
+ // handle move button clicks
+ View moveButton = findViewById(R.id.cameraMoveButton);
+ if (moveButton != null) {
+ moveButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(getNextLatLng())
+ .zoom(14)
+ .tilt(30)
+ .tilt(0)
+ .build();
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
+ });
}
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.getUiSettings().setAttributionEnabled(false);
- mapboxMap.getUiSettings().setLogoEnabled(false);
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
+ // handle ease button clicks
+ View easeButton = findViewById(R.id.cameraEaseButton);
+ if (easeButton != null) {
+ easeButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(getNextLatLng())
+ .zoom(15)
+ .bearing(180)
+ .tilt(30)
+ .build();
+
+ MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
@Override
- public void onCameraChange(CameraPosition position) {
- Timber.w(position.toString());
+ public void onCancel() {
+ Timber.i("Duration onCancel Callback called.");
+ Toast.makeText(
+ CameraAnimationTypeActivity.this,
+ "Ease onCancel Callback called.",
+ Toast.LENGTH_LONG).show();
}
- });
-
- // handle move button clicks
- View moveButton = findViewById(R.id.cameraMoveButton);
- if (moveButton != null) {
- moveButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(getNextLatLng())
- .zoom(14)
- .tilt(30)
- .tilt(0)
- .build();
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
- }
- });
- }
- // handle ease button clicks
- View easeButton = findViewById(R.id.cameraEaseButton);
- if (easeButton != null) {
- easeButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(getNextLatLng())
- .zoom(15)
- .bearing(180)
- .tilt(30)
- .build();
-
- MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- Timber.i("Duration onCancel Callback called.");
- Toast.makeText(
- CameraAnimationTypeActivity.this,
- "Ease onCancel Callback called.",
- Toast.LENGTH_LONG).show();
- }
-
- @Override
- public void onFinish() {
- Timber.i("Duration onFinish Callback called.");
- Toast.makeText(
- CameraAnimationTypeActivity.this,
- "Ease onFinish Callback called.",
- Toast.LENGTH_LONG).show();
- }
- };
-
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
- }
- });
- }
+ @Override
+ public void onFinish() {
+ Timber.i("Duration onFinish Callback called.");
+ Toast.makeText(
+ CameraAnimationTypeActivity.this,
+ "Ease onFinish Callback called.",
+ Toast.LENGTH_LONG).show();
+ }
+ };
- // handle animate button clicks
- View animateButton = findViewById(R.id.cameraAnimateButton);
- if (animateButton != null) {
- animateButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(getNextLatLng())
- .bearing(270)
- .tilt(20)
- .build();
-
- MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- Timber.i("Duration onCancel Callback called.");
- Toast.makeText(
- CameraAnimationTypeActivity.this,
- "Duration onCancel Callback called.",
- Toast.LENGTH_LONG).show();
- }
-
- @Override
- public void onFinish() {
- Timber.i("Duration onFinish Callback called.");
- Toast.makeText(
- CameraAnimationTypeActivity.this,
- "Duration onFinish Callback called.",
- Toast.LENGTH_LONG).show();
- }
- };
-
- mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
- }
- });
+ mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
}
+ });
}
- private LatLng getNextLatLng() {
- cameraState = !cameraState;
- return cameraState ? LAT_LNG_TOWER_BRIDGE : LAT_LNG_LONDON_EYE;
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ // handle animate button clicks
+ View animateButton = findViewById(R.id.cameraAnimateButton);
+ if (animateButton != null) {
+ animateButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(getNextLatLng())
+ .bearing(270)
+ .tilt(20)
+ .build();
+
+ MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ Timber.i("Duration onCancel Callback called.");
+ Toast.makeText(
+ CameraAnimationTypeActivity.this,
+ "Duration onCancel Callback called.",
+ Toast.LENGTH_LONG).show();
+ }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ @Override
+ public void onFinish() {
+ Timber.i("Duration onFinish Callback called.");
+ Toast.makeText(
+ CameraAnimationTypeActivity.this,
+ "Duration onFinish Callback called.",
+ Toast.LENGTH_LONG).show();
+ }
+ };
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
}
+ });
+ }
+ }
+
+ private LatLng getNextLatLng() {
+ cameraState = !cameraState;
+ return cameraState ? LAT_LNG_TOWER_BRIDGE : LAT_LNG_LONDON_EYE;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
index b6394eac34..193b59a9db 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
@@ -11,7 +11,9 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@@ -28,187 +30,188 @@ import com.mapbox.mapboxsdk.testapp.R;
public class CameraPositionActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapView mapView;
- private MapboxMap mapboxMap;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_camera_position);
-
- 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(this);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_camera_position);
- @Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
-
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
- @Override
- public void onCameraChange(CameraPosition position) {
- Timber.w("OnCameraChange: " + position);
- }
- });
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- // add a listener to FAB
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Context context = v.getContext();
- final View dialogContent = LayoutInflater.from(context).inflate(R.layout.dialog_camera_position, null);
- AlertDialog.Builder builder = new AlertDialog.Builder(
- context, com.mapbox.mapboxsdk.R.style.mapbox_AlertDialogStyle);
- builder.setTitle(R.string.dialog_camera_position);
- builder.setView(onInflateDialogContent(dialogContent));
- builder.setPositiveButton("Animate", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- double latitude = Double.parseDouble(
- ((TextView) dialogContent.findViewById(R.id.value_lat)).getText().toString());
- double longitude = Double.parseDouble(
- ((TextView) dialogContent.findViewById(R.id.value_lon)).getText().toString());
- double zoom = Double.parseDouble(
- ((TextView) dialogContent.findViewById(R.id.value_zoom)).getText().toString());
- double bearing = Double.parseDouble(
- ((TextView) dialogContent.findViewById(R.id.value_bearing)).getText().toString());
- double tilt = Double.parseDouble(
- ((TextView) dialogContent.findViewById(R.id.value_tilt)).getText().toString());
-
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(new LatLng(latitude, longitude))
- .zoom(zoom)
- .bearing(bearing)
- .tilt(tilt)
- .build();
-
- mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- Timber.v("OnCancel called");
- }
-
- @Override
- public void onFinish() {
- Timber.v("OnFinish called");
- }
- });
- Timber.v(cameraPosition.toString());
- }
- });
- builder.setNegativeButton("Cancel", null);
- builder.setCancelable(false);
- builder.show();
- }
- });
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(@NonNull final MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+
+ mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
+ @Override
+ public void onCameraChange(CameraPosition position) {
+ Timber.w("OnCameraChange: " + position);
+ }
+ });
+
+ // add a listener to FAB
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Context context = view.getContext();
+ final View dialogContent = LayoutInflater.from(context).inflate(R.layout.dialog_camera_position, null);
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ context, com.mapbox.mapboxsdk.R.style.mapbox_AlertDialogStyle);
+ builder.setTitle(R.string.dialog_camera_position);
+ builder.setView(onInflateDialogContent(dialogContent));
+ builder.setPositiveButton("Animate", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ double latitude = Double.parseDouble(
+ ((TextView) dialogContent.findViewById(R.id.value_lat)).getText().toString());
+ double longitude = Double.parseDouble(
+ ((TextView) dialogContent.findViewById(R.id.value_lon)).getText().toString());
+ double zoom = Double.parseDouble(
+ ((TextView) dialogContent.findViewById(R.id.value_zoom)).getText().toString());
+ double bearing = Double.parseDouble(
+ ((TextView) dialogContent.findViewById(R.id.value_bearing)).getText().toString());
+ double tilt = Double.parseDouble(
+ ((TextView) dialogContent.findViewById(R.id.value_tilt)).getText().toString());
+
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(new LatLng(latitude, longitude))
+ .zoom(zoom)
+ .bearing(bearing)
+ .tilt(tilt)
+ .build();
+
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000,
+ new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ Timber.v("OnCancel called");
+ }
+
+ @Override
+ public void onFinish() {
+ Timber.v("OnFinish called");
+ }
+ });
+ Timber.v(cameraPosition.toString());
+ }
+ });
+ builder.setNegativeButton("Cancel", null);
+ builder.setCancelable(false);
+ builder.show();
+ }
+ });
+ }
+
+ @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
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ }
+
+ private View onInflateDialogContent(View view) {
+ linkTextView(view, R.id.value_lat, R.id.seekbar_lat, new LatLngChangeListener(), 180 + 38);
+ linkTextView(view, R.id.value_lon, R.id.seekbar_lon, new LatLngChangeListener(), 180 - 77);
+ linkTextView(view, R.id.value_zoom, R.id.seekbar_zoom, new ValueChangeListener(), 6);
+ linkTextView(view, R.id.value_bearing, R.id.seekbar_bearing, new ValueChangeListener(), 90);
+ linkTextView(view, R.id.value_tilt, R.id.seekbar_tilt, new ValueChangeListener(), 40);
+ return view;
+ }
+
+ private void linkTextView(
+ View view, @IdRes int textViewRes, @IdRes int seekBarRes, ValueChangeListener listener, int defaultValue) {
+ final TextView value = (TextView) view.findViewById(textViewRes);
+ SeekBar seekBar = (SeekBar) view.findViewById(seekBarRes);
+ listener.setLinkedValueView(value);
+ seekBar.setOnSeekBarChangeListener(listener);
+ seekBar.setProgress(defaultValue);
+ }
+
+ private class ValueChangeListener implements SeekBar.OnSeekBarChangeListener {
+
+ protected TextView textView;
+
+ public void setLinkedValueView(TextView textView) {
+ this.textView = textView;
}
@Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ public void onStartTrackingTouch(SeekBar seekBar) {
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ public void onStopTrackingTouch(SeekBar seekBar) {
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ textView.setText(String.valueOf(progress));
}
+ }
- private View onInflateDialogContent(View view) {
- linkTextView(view, R.id.value_lat, R.id.seekbar_lat, new LatLngChangeListener(), 180 + 38);
- linkTextView(view, R.id.value_lon, R.id.seekbar_lon, new LatLngChangeListener(), 180 - 77);
- linkTextView(view, R.id.value_zoom, R.id.seekbar_zoom, new ValueChangeListener(), 6);
- linkTextView(view, R.id.value_bearing, R.id.seekbar_bearing, new ValueChangeListener(), 90);
- linkTextView(view, R.id.value_tilt, R.id.seekbar_tilt, new ValueChangeListener(), 40);
- return view;
- }
-
- private void linkTextView(
- View view, @IdRes int textViewRes, @IdRes int seekBarRes, ValueChangeListener listener, int defaultValue) {
- final TextView value = (TextView) view.findViewById(textViewRes);
- SeekBar seekBar = (SeekBar) view.findViewById(seekBarRes);
- listener.setLinkedValueView(value);
- seekBar.setOnSeekBarChangeListener(listener);
- seekBar.setProgress(defaultValue);
- }
-
- private class ValueChangeListener implements SeekBar.OnSeekBarChangeListener {
-
- protected TextView textView;
-
- public void setLinkedValueView(TextView textView) {
- this.textView = textView;
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
+ private class LatLngChangeListener extends ValueChangeListener {
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
-
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- textView.setText(String.valueOf(progress));
- }
- }
-
- private class LatLngChangeListener extends ValueChangeListener {
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- super.onProgressChanged(seekBar, progress - 180, fromUser);
- }
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ super.onProgressChanged(seekBar, progress - 180, fromUser);
}
-}
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
index 8a1e41bb42..3dd6a6344d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
@@ -4,7 +4,9 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
@@ -23,120 +25,120 @@ import java.util.List;
public class LatLngBoundsActivity extends AppCompatActivity implements OnMapReadyCallback {
- private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622);
- private static final LatLng NEW_YORK = new LatLng(40.712730, -74.005953);
-
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_visible_bounds);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622);
+ private static final LatLng NEW_YORK = new LatLng(40.712730, -74.005953);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.setStyleUrl(Style.DARK);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
-
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- UiSettings uiSettings = mapboxMap.getUiSettings();
- uiSettings.setAllGesturesEnabled(false);
-
- mapboxMap.addMarker(new MarkerOptions()
- .title("Los Angeles")
- .snippet("City Hall")
- .position(LOS_ANGELES));
-
- mapboxMap.addMarker(new MarkerOptions()
- .title("New York")
- .snippet("City Hall")
- .position(NEW_YORK));
-
- List<LatLng> points = new ArrayList<>();
- points.add(NEW_YORK);
- points.add(LOS_ANGELES);
-
- // Create Bounds
- final LatLngBounds bounds = new LatLngBounds.Builder()
- .includes(points)
- .build();
-
- // Add map padding
- int mapPadding = (int) getResources().getDimension(R.dimen.fab_margin);
- mapboxMap.setPadding(mapPadding, mapPadding, mapPadding, mapPadding);
-
- // Move camera to the bounds with added padding
- int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
-
- // Log data
- Timber.e("Move to bounds: " + bounds.toString());
- Timber.e("Resulting bounds:" + mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString());
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_visible_bounds);
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setStyleUrl(Style.DARK);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ UiSettings uiSettings = mapboxMap.getUiSettings();
+ uiSettings.setAllGesturesEnabled(false);
+
+ mapboxMap.addMarker(new MarkerOptions()
+ .title("Los Angeles")
+ .snippet("City Hall")
+ .position(LOS_ANGELES));
+
+ mapboxMap.addMarker(new MarkerOptions()
+ .title("New York")
+ .snippet("City Hall")
+ .position(NEW_YORK));
+
+ List<LatLng> points = new ArrayList<>();
+ points.add(NEW_YORK);
+ points.add(LOS_ANGELES);
+
+ // Create Bounds
+ final LatLngBounds bounds = new LatLngBounds.Builder()
+ .includes(points)
+ .build();
+
+ // Add map padding
+ int mapPadding = (int) getResources().getDimension(R.dimen.fab_margin);
+ mapboxMap.setPadding(mapPadding, mapPadding, mapPadding, mapPadding);
+
+ // Move camera to the bounds with added padding
+ int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
+
+ // Log data
+ Timber.e("Move to bounds: " + bounds.toString());
+ Timber.e("Resulting bounds:" + mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString());
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java
index 38186b0318..4bc30157f8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java
@@ -20,116 +20,116 @@ import com.mapbox.mapboxsdk.testapp.R;
public class ManualZoomActivity extends AppCompatActivity {
- private MapboxMap mapboxMap;
- private MapView mapView;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_manual_zoom);
-
- 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.setStyleUrl(Style.SATELLITE);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- ManualZoomActivity.this.mapboxMap = mapboxMap;
-
- UiSettings uiSettings = ManualZoomActivity.this.mapboxMap.getUiSettings();
- uiSettings.setAllGesturesEnabled(false);
- }
- });
- }
+ private MapboxMap mapboxMap;
+ private MapView mapView;
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_zoom, menu);
- return true;
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_manual_zoom);
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case android.R.id.home:
- onBackPressed();
- return true;
-
- case R.id.action_zoom_in:
- mapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
- return true;
-
- case R.id.action_zoom_out:
- mapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
- return true;
-
- case R.id.action_zoom_by:
- mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2));
- return true;
- case R.id.action_zoom_to:
- mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(2));
- return true;
-
- case R.id.action_zoom_to_point:
- View view = getWindow().getDecorView();
- mapboxMap.animateCamera(
- CameraUpdateFactory.zoomBy(1, new Point(view.getMeasuredWidth() / 4, view.getMeasuredHeight() / 4)));
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ 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();
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setStyleUrl(Style.SATELLITE);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull final MapboxMap mapboxMap) {
+ ManualZoomActivity.this.mapboxMap = mapboxMap;
+
+ UiSettings uiSettings = ManualZoomActivity.this.mapboxMap.getUiSettings();
+ uiSettings.setAllGesturesEnabled(false);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_zoom, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+
+ case android.R.id.home:
+ onBackPressed();
+ return true;
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ case R.id.action_zoom_in:
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
+ return true;
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ case R.id.action_zoom_out:
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
+ return true;
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ case R.id.action_zoom_by:
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2));
+ return true;
+ case R.id.action_zoom_to:
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(2));
+ return true;
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ case R.id.action_zoom_to_point:
+ View view = getWindow().getDecorView();
+ mapboxMap.animateCamera(
+ CameraUpdateFactory.zoomBy(1, new Point(view.getMeasuredWidth() / 4, view.getMeasuredHeight() / 4)));
+ return true;
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
index 849f6da077..71e8cc0a08 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
@@ -13,86 +13,86 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapView mapView;
- private MapboxMap mapboxMap;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
+ @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_maxmin_zoom);
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_maxmin_zoom);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ 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(this);
- }
-
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.setMinZoomPreference(3);
- mapboxMap.setMaxZoomPreference(5);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- }
- return false;
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.setMinZoomPreference(3);
+ mapboxMap.setMaxZoomPreference(5);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
}
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
-}
+ return false;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java
index 6466537e39..2f16e862ee 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java
@@ -22,139 +22,139 @@ import com.mapbox.mapboxsdk.testapp.R;
public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCallback {
- public static final int MULTIPLIER_PER_PIXEL = 50;
+ public static final int MULTIPLIER_PER_PIXEL = 50;
- private MapView mapView;
- private MapboxMap mapboxMap;
- private SeekBar xBar;
- private SeekBar yBar;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private SeekBar seekBarX;
+ private SeekBar seekBarY;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_scroll_by);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- xBar = (SeekBar) findViewById(R.id.seekbar_move_x);
- TextView xText = (TextView) findViewById(R.id.textview_x);
- xBar.setOnSeekBarChangeListener(new PixelBarChangeListener(xText, R.string.scrollby_x_value));
-
- yBar = (SeekBar) findViewById(R.id.seekbar_move_y);
- TextView yText = (TextView) findViewById(R.id.textview_y);
- yBar.setOnSeekBarChangeListener(new PixelBarChangeListener(yText, R.string.scrollby_y_value));
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.setTag(true);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_scroll_by);
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- UiSettings uiSettings = mapboxMap.getUiSettings();
- uiSettings.setLogoEnabled(false);
- uiSettings.setAttributionEnabled(false);
-
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(ScrollByActivity.this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
- xBar.getProgress() * MULTIPLIER_PER_PIXEL,
- yBar.getProgress() * MULTIPLIER_PER_PIXEL)
- );
- }
- });
- }
+ 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();
+ seekBarX = (SeekBar) findViewById(R.id.seekbar_move_x);
+ TextView textViewX = (TextView) findViewById(R.id.textview_x);
+ seekBarX.setOnSeekBarChangeListener(new PixelBarChangeListener(textViewX, R.string.scrollby_x_value));
+
+ seekBarY = (SeekBar) findViewById(R.id.seekbar_move_y);
+ TextView textViewY = (TextView) findViewById(R.id.textview_y);
+ seekBarY.setOnSeekBarChangeListener(new PixelBarChangeListener(textViewY, R.string.scrollby_y_value));
+
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setTag(true);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ UiSettings uiSettings = mapboxMap.getUiSettings();
+ uiSettings.setLogoEnabled(false);
+ uiSettings.setAttributionEnabled(false);
+
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(ScrollByActivity.this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
+ seekBarX.getProgress() * MULTIPLIER_PER_PIXEL,
+ seekBarY.getProgress() * MULTIPLIER_PER_PIXEL)
+ );
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ private static class PixelBarChangeListener implements SeekBar.OnSeekBarChangeListener {
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ @StringRes
+ private int prefixTextResource;
+ private TextView valueView;
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ public PixelBarChangeListener(@NonNull TextView textView, @StringRes int textRes) {
+ valueView = textView;
+ prefixTextResource = textRes;
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ int value = progress * ScrollByActivity.MULTIPLIER_PER_PIXEL;
+ valueView.setText(String.format(seekBar.getResources().getString(prefixTextResource), value));
}
@Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ public void onStartTrackingTouch(SeekBar seekBar) {
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
}
- private static class PixelBarChangeListener implements SeekBar.OnSeekBarChangeListener {
-
- @StringRes
- private int prefixTextResource;
- private TextView valueView;
-
- public PixelBarChangeListener(@NonNull TextView textView, @StringRes int textRes) {
- valueView = textView;
- prefixTextResource = textRes;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- int value = progress * ScrollByActivity.MULTIPLIER_PER_PIXEL;
- valueView.setText(String.format(seekBar.getResources().getString(prefixTextResource), value));
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
- }
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
index 804fc95213..8e4b58366f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
@@ -6,7 +6,9 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -23,147 +25,147 @@ import com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer;
public class CustomLayerActivity extends AppCompatActivity {
- private MapboxMap mapboxMap;
- private MapView mapView;
- private CustomLayer customLayer;
-
- private FloatingActionButton fab;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_custom_layer);
-
- setupActionBar();
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.91448, -243.60947), 10));
-
- }
- });
-
- fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- swapCustomLayer();
- }
- }
- });
- }
-
- private void swapCustomLayer() {
- if (customLayer != null) {
- try {
- mapboxMap.removeLayer(customLayer.getId());
- customLayer = null;
- } catch (NoSuchLayerException noSuchLayerException) {
- Timber.e("No custom layer to remove");
- }
- fab.setImageResource(R.drawable.ic_layers_24dp);
- } else {
- customLayer = new CustomLayer("custom",
- ExampleCustomLayer.createContext(),
- ExampleCustomLayer.InitializeFunction,
- ExampleCustomLayer.RenderFunction,
- ExampleCustomLayer.DeinitializeFunction);
- mapboxMap.addLayer(customLayer, "building");
- fab.setImageResource(R.drawable.ic_layers_clear_24dp);
- }
- }
-
- private void updateLayer() {
- if (customLayer != null) {
- customLayer.update();
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private CustomLayer customLayer;
+
+ private FloatingActionButton fab;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_custom_layer);
+
+ setupActionBar();
+
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.91448, -243.60947), 10));
+
+ }
+ });
+
+ fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ swapCustomLayer();
}
+ }
+ });
+ }
+
+ private void swapCustomLayer() {
+ if (customLayer != null) {
+ try {
+ mapboxMap.removeLayer(customLayer.getId());
+ customLayer = null;
+ } catch (NoSuchLayerException noSuchLayerException) {
+ Timber.e("No custom layer to remove");
+ }
+ fab.setImageResource(R.drawable.ic_layers_24dp);
+ } else {
+ customLayer = new CustomLayer("custom",
+ ExampleCustomLayer.createContext(),
+ ExampleCustomLayer.InitializeFunction,
+ ExampleCustomLayer.RenderFunction,
+ ExampleCustomLayer.DeinitializeFunction);
+ mapboxMap.addLayer(customLayer, "building");
+ fab.setImageResource(R.drawable.ic_layers_clear_24dp);
}
+ }
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ private void updateLayer() {
+ if (customLayer != null) {
+ customLayer.update();
}
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_custom_layer, menu);
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_custom_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_update_layer:
+ updateLayer();
+ return true;
+ case R.id.action_set_color_red:
+ ExampleCustomLayer.setColor(1, 0, 0, 1);
+ return true;
+ case R.id.action_set_color_green:
+ ExampleCustomLayer.setColor(0, 1, 0, 1);
+ return true;
+ case R.id.action_set_color_blue:
+ ExampleCustomLayer.setColor(0, 0, 1, 1);
+ 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_update_layer:
- updateLayer();
- return true;
- case R.id.action_set_color_red:
- ExampleCustomLayer.setColor(1, 0, 0, 1);
- return true;
- case R.id.action_set_color_green:
- ExampleCustomLayer.setColor(0, 1, 0, 1);
- return true;
- case R.id.action_set_color_blue:
- ExampleCustomLayer.setColor(0, 0, 1, 1);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java
index 64d0a773b4..fc8f5059be 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java
@@ -6,8 +6,11 @@ import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
+
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -35,176 +38,176 @@ import retrofit2.Response;
public class DirectionsActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_directions);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- DirectionsActivity.this.mapboxMap = mapboxMap;
- loadRoute();
- }
- });
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_directions);
- private void loadRoute() {
- // Dupont Circle (Washington, DC)
- Position origin = Position.fromCoordinates(-77.04341, 38.90962);
-
- // The White House (Washington, DC)
- Position destination = Position.fromCoordinates(-77.0365, 38.8977);
-
- // Set map at centroid
- LatLng centroid = new LatLng(
- (origin.getLatitude() + destination.getLatitude()) / 2,
- (origin.getLongitude() + destination.getLongitude()) / 2);
-
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
- .target(centroid)
- .zoom(14)
- .build()));
-
- // Add origin and destination to the map
- mapboxMap.addMarker(new MarkerOptions()
- .position(new LatLng(origin.getLatitude(), origin.getLongitude()))
- .title("Origin")
- .snippet("Dupont Circle"));
- mapboxMap.addMarker(new MarkerOptions()
- .position(new LatLng(destination.getLatitude(), destination.getLongitude()))
- .title("Destination")
- .snippet("The White House"));
-
- // Get route from API
- getRoute(origin, destination);
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- private void getRoute(Position origin, Position destination) {
- try {
- MapboxDirections md = new MapboxDirections.Builder()
- .setAccessToken(getString(R.string.mapbox_access_token))
- .setOrigin(origin)
- .setOverview(DirectionsCriteria.OVERVIEW_FULL)
- .setDestination(destination)
- .setProfile(DirectionsCriteria.PROFILE_WALKING)
- .build();
-
- md.enqueueCall(new Callback<DirectionsResponse>() {
-
- @Override
- public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
- Timber.e("Error: " + throwable.getMessage());
- }
-
- @Override
- public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
- // You can get generic HTTP info about the response
- Timber.d("Response code: " + response.code());
-
- // Print some info about the route
- DirectionsRoute currentRoute = response.body().getRoutes().get(0);
- Timber.d("Distance: " + currentRoute.getDistance());
-
- // Draw the route on the map
- drawRoute(currentRoute);
- }
-
- });
- } catch (ServicesException servicesException) {
- Timber.e("Error displaying route: " + servicesException.toString());
- servicesException.printStackTrace();
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- private void drawRoute(DirectionsRoute route) {
-
- PolylineOptions builder = new PolylineOptions();
- builder.color(Color.parseColor("#3887be"));
- builder.alpha(0.5f);
- builder.width(5);
- builder.width(5);
-
- LineString lineString = LineString.fromPolyline(route.getGeometry(), Constants.OSRM_PRECISION_V5);
- List<Position> coordinates = lineString.getCoordinates();
- List<LatLng> points = new ArrayList<>();
- for (int i = 0; i < coordinates.size(); i++) {
- points.add(new LatLng(
- coordinates.get(i).getLatitude(),
- coordinates.get(i).getLongitude()));
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ DirectionsActivity.this.mapboxMap = mapboxMap;
+ loadRoute();
+ }
+ });
+ }
+
+ private void loadRoute() {
+ // Dupont Circle (Washington, DC)
+ Position origin = Position.fromCoordinates(-77.04341, 38.90962);
+
+ // The White House (Washington, DC)
+ Position destination = Position.fromCoordinates(-77.0365, 38.8977);
+
+ // Set map at centroid
+ LatLng centroid = new LatLng(
+ (origin.getLatitude() + destination.getLatitude()) / 2,
+ (origin.getLongitude() + destination.getLongitude()) / 2);
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
+ .target(centroid)
+ .zoom(14)
+ .build()));
+
+ // Add origin and destination to the map
+ mapboxMap.addMarker(new MarkerOptions()
+ .position(new LatLng(origin.getLatitude(), origin.getLongitude()))
+ .title("Origin")
+ .snippet("Dupont Circle"));
+ mapboxMap.addMarker(new MarkerOptions()
+ .position(new LatLng(destination.getLatitude(), destination.getLongitude()))
+ .title("Destination")
+ .snippet("The White House"));
+
+ // Get route from API
+ getRoute(origin, destination);
+ }
+
+ private void getRoute(Position origin, Position destination) {
+ try {
+ MapboxDirections md = new MapboxDirections.Builder()
+ .setAccessToken(getString(R.string.mapbox_access_token))
+ .setOrigin(origin)
+ .setOverview(DirectionsCriteria.OVERVIEW_FULL)
+ .setDestination(destination)
+ .setProfile(DirectionsCriteria.PROFILE_WALKING)
+ .build();
+
+ md.enqueueCall(new Callback<DirectionsResponse>() {
+
+ @Override
+ public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
+ Timber.e("Error: " + throwable.getMessage());
}
- builder.addAll(points);
+ @Override
+ public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
+ // You can get generic HTTP info about the response
+ Timber.d("Response code: " + response.code());
- // Draw Points on MapView
- mapboxMap.addPolyline(builder);
- }
+ // Print some info about the route
+ DirectionsRoute currentRoute = response.body().getRoutes().get(0);
+ Timber.d("Distance: " + currentRoute.getDistance());
- @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();
- }
+ // Draw the route on the map
+ drawRoute(currentRoute);
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ });
+ } catch (ServicesException servicesException) {
+ Timber.e("Error displaying route: " + servicesException.toString());
+ servicesException.printStackTrace();
}
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ }
+
+ private void drawRoute(DirectionsRoute route) {
+
+ PolylineOptions builder = new PolylineOptions();
+ builder.color(Color.parseColor("#3887be"));
+ builder.alpha(0.5f);
+ builder.width(5);
+ builder.width(5);
+
+ LineString lineString = LineString.fromPolyline(route.getGeometry(), Constants.OSRM_PRECISION_V5);
+ List<Position> coordinates = lineString.getCoordinates();
+ List<LatLng> points = new ArrayList<>();
+ for (int i = 0; i < coordinates.size(); i++) {
+ points.add(new LatLng(
+ coordinates.get(i).getLatitude(),
+ coordinates.get(i).getLongitude()));
}
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ builder.addAll(points);
+
+ // Draw Points on MapView
+ mapboxMap.addPolyline(builder);
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java
index 5c6c4b7125..677e09e719 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java
@@ -13,68 +13,68 @@ import com.mapbox.mapboxsdk.testapp.R;
*/
public class EspressoTestActivity extends AppCompatActivity implements OnMapReadyCallback {
- public MapView mapView;
- protected MapboxMap mapboxMap;
+ public MapView mapView;
+ protected MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_camera_test);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_camera_test);
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- }
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ }
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
- @Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ }
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java
index 1b9d3a164a..00cc8dfac7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java
@@ -5,15 +5,11 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import timber.log.Timber;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.google.gson.JsonElement;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
@@ -23,143 +19,143 @@ import com.mapbox.services.commons.geojson.Feature;
import java.util.List;
import java.util.Map;
+import timber.log.Timber;
+
/**
* Demo's query rendered features
*/
public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {
- public MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_query_features_box);
- setupActionBar();
-
- final float density = getResources().getDisplayMetrics().density;
-
- final View selectionBox = findViewById(R.id.selection_box);
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @SuppressWarnings("ConstantConditions")
- @Override
- public void onMapReady(final MapboxMap mapboxMap) {
- QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap;
- selectionBox.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- //Query
- int top = selectionBox.getTop() - mapView.getTop();
- int left = selectionBox.getLeft() - mapView.getLeft();
- RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
- Timber.i(String.format("Querying box %s", box));
- List<Feature> features = mapboxMap.queryRenderedFeatures(box);
-
- //Show count
- Toast.makeText(
- QueryRenderedFeaturesBoxCountActivity.this,
- String.format("%s features in box", features.size()),
- Toast.LENGTH_SHORT).show();
-
- //Debug output
- debugOutput(features);
- }
- });
- }
+ public MapView mapView;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_query_features_box);
+ setupActionBar();
+
+ final View selectionBox = findViewById(R.id.selection_box);
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @SuppressWarnings("ConstantConditions")
+ @Override
+ public void onMapReady(final MapboxMap mapboxMap) {
+ QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap;
+ selectionBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //Query
+ int top = selectionBox.getTop() - mapView.getTop();
+ int left = selectionBox.getLeft() - mapView.getLeft();
+ RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
+ Timber.i(String.format("Querying box %s", box));
+ List<Feature> features = mapboxMap.queryRenderedFeatures(box);
+
+ //Show count
+ Toast.makeText(
+ QueryRenderedFeaturesBoxCountActivity.this,
+ String.format("%s features in box", features.size()),
+ Toast.LENGTH_SHORT).show();
+
+ //Debug output
+ debugOutput(features);
+ }
});
- }
-
- private void debugOutput(List<Feature> features) {
- Timber.i(String.format("Got %s features", features.size()));
- for (Feature feature : features) {
- if (feature != null) {
- Timber.i(String.format("Got feature %s with %s properties and Geometry %s",
- feature.getId(),
- feature.getProperties() != null ? feature.getProperties().entrySet().size() : "<null>",
- feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>")
- );
- if (feature.getProperties() != null) {
- for (Map.Entry<String, JsonElement> entry : feature.getProperties().entrySet()) {
- Timber.i(String.format("Prop %s - %s", entry.getKey(), entry.getValue()));
- }
- }
- } else {
- // TODO Question: Why not formatting here??
- Timber.i("Got NULL feature %s");
- }
+ }
+ });
+ }
+
+ private void debugOutput(List<Feature> features) {
+ Timber.i(String.format("Got %s features", features.size()));
+ for (Feature feature : features) {
+ if (feature != null) {
+ Timber.i(String.format("Got feature %s with %s properties and Geometry %s",
+ feature.getId(),
+ feature.getProperties() != null ? feature.getProperties().entrySet().size() : "<null>",
+ feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>")
+ );
+ if (feature.getProperties() != null) {
+ for (Map.Entry<String, JsonElement> entry : feature.getProperties().entrySet()) {
+ Timber.i(String.format("Prop %s - %s", entry.getKey(), entry.getValue()));
+ }
}
+ } else {
+ // TODO Question: Why not formatting here??
+ Timber.i("Got NULL feature %s");
+ }
}
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ }
+
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java
index 71b2b3e828..8c4a499f9b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java
@@ -6,14 +6,10 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import timber.log.Timber;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
@@ -25,6 +21,8 @@ import com.mapbox.services.commons.geojson.FeatureCollection;
import java.util.List;
+import timber.log.Timber;
+
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
/**
@@ -32,126 +30,129 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
*/
public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity {
- public MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_query_features_box);
- setupActionBar();
-
- final View selectionBox = findViewById(R.id.selection_box);
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @SuppressWarnings("ConstantConditions")
- @Override
- public void onMapReady(final MapboxMap mapboxMap) {
- QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap;
- selectionBox.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- //Query
- int top = selectionBox.getTop() - mapView.getTop();
- int left = selectionBox.getLeft() - mapView.getLeft();
- RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
- Timber.i(String.format("Querying box %s for buildings", box));
- List<Feature> features = mapboxMap.queryRenderedFeatures(box, "building");
-
- //Show count
- Toast.makeText(
- QueryRenderedFeaturesBoxHighlightActivity.this,
- String.format("%s features in box", features.size()),
- Toast.LENGTH_SHORT).show();
-
- //remove layer / source if already added
- try {
- mapboxMap.removeSource("highlighted-shapes-source");
- mapboxMap.removeLayer("highlighted-shapes-layer");
- } catch (Exception exception) {
- //that's ok
- }
-
- //Add layer / source
- mapboxMap.addSource(new GeoJsonSource("highlighted-shapes-source", FeatureCollection.fromFeatures(features)));
- mapboxMap.addLayer(new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source")
- .withProperties(fillColor(Color.RED)));
- }
- });
+ public MapView mapView;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_query_features_box);
+ setupActionBar();
+
+ final View selectionBox = findViewById(R.id.selection_box);
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @SuppressWarnings("ConstantConditions")
+ @Override
+ public void onMapReady(final MapboxMap mapboxMap) {
+ QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap;
+ selectionBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //Query
+ int top = selectionBox.getTop() - mapView.getTop();
+ int left = selectionBox.getLeft() - mapView.getLeft();
+ RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
+ Timber.i(String.format("Querying box %s for buildings", box));
+ List<Feature> features = mapboxMap.queryRenderedFeatures(box, "building");
+
+ //Show count
+ Toast.makeText(
+ QueryRenderedFeaturesBoxHighlightActivity.this,
+ String.format("%s features in box", features.size()),
+ Toast.LENGTH_SHORT).show();
+
+ //remove layer / source if already added
+ try {
+ mapboxMap.removeSource("highlighted-shapes-source");
+ mapboxMap.removeLayer("highlighted-shapes-layer");
+ } catch (Exception exception) {
+ //that's ok
}
- });
-
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ //Add layer / source
+ mapboxMap.addSource(
+ new GeoJsonSource("highlighted-shapes-source",
+ FeatureCollection.fromFeatures(features))
+ );
+ mapboxMap.addLayer(new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source")
+ .withProperties(fillColor(Color.RED)));
+ }
+ });
+ }
+ });
+
+ }
+
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java
index be8f44af7c..4b7bbb9614 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java
@@ -7,7 +7,6 @@ import android.support.annotation.RawRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import timber.log.Timber;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
@@ -29,6 +28,8 @@ import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
+import timber.log.Timber;
+
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
/**
@@ -36,148 +37,150 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
*/
public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivity {
- public MapView mapView;
- private MapboxMap mapboxMap;
-
- private Toast toast;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_query_features_box);
- setupActionBar();
-
- final float density = getResources().getDisplayMetrics().density;
-
- final View selectionBox = findViewById(R.id.selection_box);
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @SuppressWarnings("ConstantConditions")
- @Override
- public void onMapReady(final MapboxMap mapboxMap) {
- QueryRenderedFeaturesBoxSymbolCountActivity.this.mapboxMap = mapboxMap;
-
- //Add a symbol layer (also works with annotations)
- try {
- mapboxMap.addSource(new GeoJsonSource("symbols-source", readRawResource(R.raw.test_points_utrecht)));
- } catch (IOException e) {
- Timber.e("Could not load geojson: " + e.getMessage());
- return;
- }
- mapboxMap.addImage("test-icon", BitmapFactory.decodeResource(getResources(), R.drawable.mapbox_marker_icon_default));
- mapboxMap.addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
-
- selectionBox.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- //Query
- int top = selectionBox.getTop() - mapView.getTop();
- int left = selectionBox.getLeft() - mapView.getLeft();
- RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
- Timber.i(String.format("Querying box %s", box));
- List<Feature> features = mapboxMap.queryRenderedFeatures(box, "symbols-layer");
-
- //Show count
- if (toast != null) {
- toast.cancel();
- }
- toast = Toast.makeText(
- QueryRenderedFeaturesBoxSymbolCountActivity.this,
- String.format("%s features in box", features.size()),
- Toast.LENGTH_SHORT);
- toast.show();
- }
- });
- }
- });
- }
-
- private String readRawResource(@RawRes int rawResource) throws IOException {
- InputStream is = getResources().openRawResource(rawResource);
- Writer writer = new StringWriter();
- char[] buffer = new char[1024];
- try {
- Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- int n;
- while ((n = reader.read(buffer)) != -1) {
- writer.write(buffer, 0, n);
- }
- } finally {
- is.close();
- }
-
- return writer.toString();
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ public MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ private Toast toast;
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_query_features_box);
+ setupActionBar();
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ final View selectionBox = findViewById(R.id.selection_box);
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @SuppressWarnings("ConstantConditions")
+ @Override
+ public void onMapReady(final MapboxMap mapboxMap) {
+ QueryRenderedFeaturesBoxSymbolCountActivity.this.mapboxMap = mapboxMap;
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ //Add a symbol layer (also works with annotations)
+ try {
+ mapboxMap.addSource(new GeoJsonSource("symbols-source", readRawResource(R.raw.test_points_utrecht)));
+ } catch (IOException ioException) {
+ Timber.e("Could not load geojson: " + ioException.getMessage());
+ return;
+ }
+ mapboxMap.addImage(
+ "test-icon",
+ BitmapFactory.decodeResource(getResources(),
+ R.drawable.mapbox_marker_icon_default)
+ );
+ mapboxMap.addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
+
+ selectionBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //Query
+ int top = selectionBox.getTop() - mapView.getTop();
+ int left = selectionBox.getLeft() - mapView.getLeft();
+ RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
+ Timber.i(String.format("Querying box %s", box));
+ List<Feature> features = mapboxMap.queryRenderedFeatures(box, "symbols-layer");
+
+ //Show count
+ if (toast != null) {
+ toast.cancel();
+ }
+ toast = Toast.makeText(
+ QueryRenderedFeaturesBoxSymbolCountActivity.this,
+ String.format("%s features in box", features.size()),
+ Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ });
+ }
+ });
+ }
+
+ private String readRawResource(@RawRes int rawResource) throws IOException {
+ InputStream is = getResources().openRawResource(rawResource);
+ Writer writer = new StringWriter();
+ char[] buffer = new char[1024];
+ try {
+ Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ int numRead;
+ while ((numRead = reader.read(buffer)) != -1) {
+ writer.write(buffer, 0, numRead);
+ }
+ } finally {
+ is.close();
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ return writer.toString();
+ }
+
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java
index 4e824ae9cb..17dfbc18b4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java
@@ -9,7 +9,9 @@ import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
@@ -33,237 +35,235 @@ import java.util.Map;
*/
public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
- public MapView mapView;
- private MapboxMap mapboxMap;
- private Marker marker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_query_features_point);
- setupActionBar();
-
- final float density = getResources().getDisplayMetrics().density;
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(final MapboxMap mapboxMap) {
- QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
-
- //Add custom window adapter
- addCustomInfoWindowAdapter(mapboxMap);
-
- //Add a click listener
- mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
- @Override
- public void onMapClick(@NonNull LatLng point) {
- //Query
- final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
- Timber.i(String.format(
- "Requesting features for %sx%s (%sx%s adjusted for density)",
- pixel.x, pixel.y, pixel.x / density, pixel.y / density)
- );
- List<Feature> features = mapboxMap.queryRenderedFeatures(pixel);
-
- //Debug output
- debugOutput(features);
-
- //Remove any previous markers
- if (marker != null) {
- mapboxMap.removeMarker(marker);
- }
-
- //Add a marker on the clicked point
- marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
- mapboxMap.selectMarker(marker);
- }
- });
+ public MapView mapView;
+ private MapboxMap mapboxMap;
+ private Marker marker;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_query_features_point);
+ setupActionBar();
+
+ final float density = getResources().getDisplayMetrics().density;
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(final MapboxMap mapboxMap) {
+ QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
+
+ //Add custom window adapter
+ addCustomInfoWindowAdapter(mapboxMap);
+
+ //Add a click listener
+ mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
+ @Override
+ public void onMapClick(@NonNull LatLng point) {
+ //Query
+ final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
+ Timber.i(String.format(
+ "Requesting features for %sx%s (%sx%s adjusted for density)",
+ pixel.x, pixel.y, pixel.x / density, pixel.y / density)
+ );
+ List<Feature> features = mapboxMap.queryRenderedFeatures(pixel);
+
+ //Debug output
+ debugOutput(features);
+
+ //Remove any previous markers
+ if (marker != null) {
+ mapboxMap.removeMarker(marker);
}
+
+ //Add a marker on the clicked point
+ marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
+ mapboxMap.selectMarker(marker);
+ }
});
+ }
+ });
+
+ }
+
+ private void debugOutput(List<Feature> features) {
+ Timber.i(String.format("Got %s features", features.size()));
+ for (Feature feature : features) {
+ if (feature != null) {
+ Timber.i(String.format("Got feature %s with %s properties and Geometry %s",
+ feature.getId(),
+ feature.getProperties() != null ? feature.getProperties().entrySet().size() : "<null>",
+ feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>")
+ );
+ if (feature.getProperties() != null) {
+ for (Map.Entry<String, JsonElement> entry : feature.getProperties().entrySet()) {
+ Timber.i(String.format("Prop %s - %s", entry.getKey(), entry.getValue()));
+ }
+ }
+ } else {
+ // TODO Question: Why not formatting here??
+ Timber.i("Got NULL feature %s");
+ }
+ }
+ }
+
+ private void addCustomInfoWindowAdapter(MapboxMap mapboxMap) {
+ mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
+
+ private TextView row(String text) {
+ TextView view = new TextView(QueryRenderedFeaturesPropertiesActivity.this);
+ view.setText(text);
+ return view;
+ }
+
+ @Override
+ public View getInfoWindow(@NonNull Marker marker) {
+ CustomMarker customMarker = (CustomMarker) marker;
+ LinearLayout view = new LinearLayout(QueryRenderedFeaturesPropertiesActivity.this);
+ view.setOrientation(LinearLayout.VERTICAL);
+ view.setBackgroundColor(Color.WHITE);
+
+ if (customMarker.features.size() > 0) {
+ view.addView(row(String.format("Found %s features", customMarker.features.size())));
+ Feature feature = customMarker.features.get(0);
+ for (Map.Entry<String, JsonElement> prop : feature.getProperties().entrySet()) {
+ view.addView(row(String.format("%s: %s", prop.getKey(), prop.getValue())));
+ }
+ } else {
+ view.addView(row("No features here"));
+ }
+ return view;
+ }
+ });
+ }
+
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private void debugOutput(List<Feature> features) {
- Timber.i(String.format("Got %s features", features.size()));
- for (Feature feature : features) {
- if (feature != null) {
- Timber.i(String.format("Got feature %s with %s properties and Geometry %s",
- feature.getId(),
- feature.getProperties() != null ? feature.getProperties().entrySet().size() : "<null>",
- feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>")
- );
- if (feature.getProperties() != null) {
- for (Map.Entry<String, JsonElement> entry : feature.getProperties().entrySet()) {
- Timber.i(String.format("Prop %s - %s", entry.getKey(), entry.getValue()));
- }
- }
- } else {
- // TODO Question: Why not formatting here??
- Timber.i("Got NULL feature %s");
- }
- }
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
- private void addCustomInfoWindowAdapter(MapboxMap mapboxMap) {
- mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
+ private static class CustomMarker extends Marker {
- private TextView row(String text) {
- TextView view = new TextView(QueryRenderedFeaturesPropertiesActivity.this);
- view.setText(text);
- return view;
- }
+ private final List<Feature> features;
- private int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);
-
- @Override
- public View getInfoWindow(@NonNull Marker marker) {
- CustomMarker customMarker = (CustomMarker) marker;
- LinearLayout view = new LinearLayout(QueryRenderedFeaturesPropertiesActivity.this);
- view.setOrientation(LinearLayout.VERTICAL);
- view.setBackgroundColor(Color.WHITE);
-
- if (customMarker.features.size() > 0) {
- view.addView(row(String.format("Found %s features", customMarker.features.size())));
- Feature feature = customMarker.features.get(0);
- for (Map.Entry<String, JsonElement> prop : feature.getProperties().entrySet()) {
- view.addView(row(String.format("%s: %s", prop.getKey(), prop.getValue())));
- }
- } else {
- view.addView(row("No features here"));
- }
-
- return view;
- }
- });
+ public CustomMarker(BaseMarkerOptions baseMarkerOptions, List<Feature> features) {
+ super(baseMarkerOptions);
+ this.features = features;
}
+ }
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
+ private static class CustomMarkerOptions extends BaseMarkerOptions<CustomMarker, CustomMarkerOptions> {
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ private List<Feature> features;
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
+ public CustomMarkerOptions features(List<Feature> features) {
+ this.features = features;
+ return this;
}
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ public CustomMarkerOptions() {
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ private CustomMarkerOptions(Parcel in) {
+ //Should implement this
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ public CustomMarkerOptions getThis() {
+ return this;
}
@Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ public CustomMarker getMarker() {
+ return new CustomMarker(this, features);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ public static final Parcelable.Creator<CustomMarkerOptions> CREATOR
+ = new Parcelable.Creator<CustomMarkerOptions>() {
+ public CustomMarkerOptions createFromParcel(Parcel in) {
+ return new CustomMarkerOptions(in);
}
- }
-
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
+ public CustomMarkerOptions[] newArray(int size) {
+ return new CustomMarkerOptions[size];
}
- }
+ };
- private static class CustomMarker extends Marker {
-
- private final List<Feature> features;
-
- public CustomMarker(BaseMarkerOptions baseMarkerOptions, List<Feature> features) {
- super(baseMarkerOptions);
- this.features = features;
- }
+ @Override
+ public int describeContents() {
+ return 0;
}
- private static class CustomMarkerOptions extends BaseMarkerOptions<CustomMarker, CustomMarkerOptions> {
-
-
- private List<Feature> features;
-
- public CustomMarkerOptions features(List<Feature> features) {
- this.features = features;
- return this;
- }
-
- public CustomMarkerOptions() {
- }
-
- private CustomMarkerOptions(Parcel in) {
- //Should implement this
- }
-
- @Override
- public CustomMarkerOptions getThis() {
- return this;
- }
-
- @Override
- public CustomMarker getMarker() {
- return new CustomMarker(this, features);
- }
-
- public static final Parcelable.Creator<CustomMarkerOptions> CREATOR
- = new Parcelable.Creator<CustomMarkerOptions>() {
- public CustomMarkerOptions createFromParcel(Parcel in) {
- return new CustomMarkerOptions(in);
- }
-
- public CustomMarkerOptions[] newArray(int size) {
- return new CustomMarkerOptions[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- //Should implement this
- }
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ //Should implement this
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java
index 5b1fd8f2a5..1c259b1304 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java
@@ -19,71 +19,71 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_map_fragment);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map_fragment);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- MapFragment mapFragment;
- if (savedInstanceState == null) {
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- MapboxMapOptions options = new MapboxMapOptions();
- options.styleUrl(Style.OUTDOORS);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- options.scrollGesturesEnabled(false);
- options.zoomGesturesEnabled(false);
- options.tiltGesturesEnabled(false);
- options.rotateGesturesEnabled(false);
+ MapFragment mapFragment;
+ if (savedInstanceState == null) {
+ final FragmentTransaction transaction = getFragmentManager().beginTransaction();
- options.debugActive(false);
+ MapboxMapOptions options = new MapboxMapOptions();
+ options.styleUrl(Style.OUTDOORS);
- LatLng dc = new LatLng(38.90252, -77.02291);
+ options.scrollGesturesEnabled(false);
+ options.zoomGesturesEnabled(false);
+ options.tiltGesturesEnabled(false);
+ options.rotateGesturesEnabled(false);
- options.minZoomPreference(9);
- options.maxZoomPreference(11);
- options.camera(new CameraPosition.Builder()
- .target(dc)
- .zoom(11)
- .build());
+ options.debugActive(false);
- mapFragment = MapFragment.newInstance(options);
+ LatLng dc = new LatLng(38.90252, -77.02291);
- transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
- transaction.commit();
- } else {
- mapFragment = (MapFragment) getFragmentManager().findFragmentByTag("com.mapbox.map");
- }
+ options.minZoomPreference(9);
+ options.maxZoomPreference(11);
+ options.camera(new CameraPosition.Builder()
+ .target(dc)
+ .zoom(11)
+ .build());
- mapFragment.getMapAsync(this);
- }
+ mapFragment = MapFragment.newInstance(options);
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.animateCamera(
- CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
+ transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
+ transaction.commit();
+ } else {
+ mapFragment = (MapFragment) getFragmentManager().findFragmentByTag("com.mapbox.map");
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ mapFragment.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.animateCamera(
+ CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java
index 526f9ae107..d5d51887dd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java
@@ -7,9 +7,9 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MultiMapActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_multi_map);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_multi_map);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java
index 17dd8659d6..ca499c871e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java
@@ -19,74 +19,69 @@ import com.mapbox.mapboxsdk.testapp.R;
public class SupportMapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapboxMap mapboxMap;
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_map_fragment);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map_fragment);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- SupportMapFragment mapFragment;
- if (savedInstanceState == null) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-
- MapboxMapOptions options = new MapboxMapOptions();
- options.styleUrl(Style.SATELLITE_STREETS);
-
- options.scrollGesturesEnabled(false);
- options.zoomGesturesEnabled(false);
- options.tiltGesturesEnabled(false);
- options.rotateGesturesEnabled(false);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- options.debugActive(false);
- options.compassEnabled(false);
- options.attributionEnabled(false);
- options.logoEnabled(false);
+ SupportMapFragment mapFragment;
+ if (savedInstanceState == null) {
+ final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- LatLng dc = new LatLng(38.90252, -77.02291);
+ MapboxMapOptions options = new MapboxMapOptions();
+ options.styleUrl(Style.SATELLITE_STREETS);
- options.minZoomPreference(9);
- options.maxZoomPreference(11);
- options.camera(new CameraPosition.Builder()
- .target(dc)
- .zoom(11)
- .build());
+ options.debugActive(false);
+ options.compassEnabled(false);
+ options.attributionEnabled(false);
+ options.logoEnabled(false);
- mapFragment = SupportMapFragment.newInstance(options);
+ LatLng dc = new LatLng(38.90252, -77.02291);
- transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
- transaction.commit();
- } else {
- mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
- }
+ options.minZoomPreference(9);
+ options.maxZoomPreference(11);
+ options.camera(new CameraPosition.Builder()
+ .target(dc)
+ .zoom(11)
+ .build());
- mapFragment.getMapAsync(this);
- }
+ mapFragment = SupportMapFragment.newInstance(options);
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.animateCamera(
- CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
+ transaction.add(R.id.fragment_container, mapFragment, "com.mapbox.map");
+ transaction.commit();
+ } else {
+ mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ mapFragment.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.animateCamera(
+ CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java
index 6cd3fd62a1..e6953bd3d2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java
@@ -19,81 +19,81 @@ import com.mapbox.mapboxsdk.testapp.R;
public class ViewPagerActivity extends AppCompatActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_viewpager);
+
+ final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
+
+ ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
+ if (viewPager != null) {
+ MapFragmentAdapter adapter = new MapFragmentAdapter(getSupportFragmentManager());
+ viewPager.setAdapter(adapter);
+ }
+ }
+
+ public static class MapFragmentAdapter extends FragmentPagerAdapter {
+
+ private static int NUM_ITEMS = 3;
+
+ public MapFragmentAdapter(FragmentManager fragmentManager) {
+ super(fragmentManager);
+ }
+
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_viewpager);
-
- final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
- if (viewPager != null) {
- MapFragmentAdapter adapter = new MapFragmentAdapter(getSupportFragmentManager());
- viewPager.setAdapter(adapter);
- }
+ public int getCount() {
+ return NUM_ITEMS;
}
- public static class MapFragmentAdapter extends FragmentPagerAdapter {
-
- private static int NUM_ITEMS = 3;
-
- public MapFragmentAdapter(FragmentManager fragmentManager) {
- super(fragmentManager);
- }
-
- @Override
- public int getCount() {
- return NUM_ITEMS;
- }
-
- @Override
- public Fragment getItem(int position) {
- SupportMapFragment fragment = null;
- MapboxMapOptions options = new MapboxMapOptions();
-
- switch (position) {
- case 0:
- options.styleUrl(Style.MAPBOX_STREETS);
- options.camera(new CameraPosition.Builder().target(new LatLng(34.920526, 102.634774)).zoom(3).build());
- fragment = SupportMapFragment.newInstance(options);
- break;
- case 1:
- options.styleUrl(Style.DARK);
- options.camera(new CameraPosition.Builder().target(new LatLng(62.326440, 92.764913)).zoom(3).build());
- fragment = SupportMapFragment.newInstance(options);
- break;
- case 2:
- options.styleUrl(Style.SATELLITE);
- options.camera(new CameraPosition.Builder().target(new LatLng(-25.007786, 133.623852)).zoom(3).build());
- fragment = SupportMapFragment.newInstance(options);
- break;
- }
- return fragment;
- }
-
-
- @Override
- public CharSequence getPageTitle(int position) {
- return "Page " + position;
- }
+ @Override
+ public Fragment getItem(int position) {
+ SupportMapFragment fragment = null;
+ MapboxMapOptions options = new MapboxMapOptions();
+
+ switch (position) {
+ case 0:
+ options.styleUrl(Style.MAPBOX_STREETS);
+ options.camera(new CameraPosition.Builder().target(new LatLng(34.920526, 102.634774)).zoom(3).build());
+ fragment = SupportMapFragment.newInstance(options);
+ break;
+ case 1:
+ options.styleUrl(Style.DARK);
+ options.camera(new CameraPosition.Builder().target(new LatLng(62.326440, 92.764913)).zoom(3).build());
+ fragment = SupportMapFragment.newInstance(options);
+ break;
+ case 2:
+ options.styleUrl(Style.SATELLITE);
+ options.camera(new CameraPosition.Builder().target(new LatLng(-25.007786, 133.623852)).zoom(3).build());
+ fragment = SupportMapFragment.newInstance(options);
+ break;
+ }
+ return fragment;
}
+
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ public CharSequence getPageTitle(int position) {
+ return "Page " + position;
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java
index c399adec37..43feb5eaad 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java
@@ -6,7 +6,9 @@ import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.Gravity;
import android.view.MenuItem;
import android.view.ViewGroup;
@@ -37,167 +39,167 @@ import retrofit2.Response;
public class GeocoderActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapboxMap mapboxMap;
- private MapView mapView;
- private ImageView dropPinView;
- private TextView textView;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_geocoder);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- textView = (TextView) findViewById(R.id.message);
- setMessage(getString(R.string.geocoder_instructions));
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.setStyleUrl(Style.MAPBOX_STREETS);
- mapView.onCreate(savedInstanceState);
-
- dropPinView = new ImageView(this);
- dropPinView.setImageResource(R.drawable.ic_droppin_24dp);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
- dropPinView.setLayoutParams(params);
- mapView.addView(dropPinView);
- mapView.getMapAsync(this);
- }
-
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- final Projection projection = mapboxMap.getProjection();
- final int width = mapView.getMeasuredWidth();
- final int height = mapView.getMeasuredHeight();
-
- // Click listener
- mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
- @Override
- public void onMapClick(@NonNull LatLng point) {
- PointF centerPoint = new PointF(width / 2, (height + dropPinView.getHeight()) / 2);
- LatLng centerLatLng = new LatLng(projection.fromScreenLocation(centerPoint));
-
- setMessage("Geocoding...");
-
- mapboxMap.removeAnnotations();
- mapboxMap.addMarker(new MarkerOptions().position(centerLatLng));
-
- geocode(centerLatLng);
- }
- });
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private ImageView dropPinView;
+ private TextView textView;
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_geocoder);
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ textView = (TextView) findViewById(R.id.message);
+ setMessage(getString(R.string.geocoder_instructions));
+
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setStyleUrl(Style.MAPBOX_STREETS);
+ mapView.onCreate(savedInstanceState);
+
+ dropPinView = new ImageView(this);
+ dropPinView.setImageResource(R.drawable.ic_droppin_24dp);
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
+ dropPinView.setLayoutParams(params);
+ mapView.addView(dropPinView);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ final Projection projection = mapboxMap.getProjection();
+ final int width = mapView.getMeasuredWidth();
+ final int height = mapView.getMeasuredHeight();
+
+ // Click listener
+ mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
+ @Override
+ public void onMapClick(@NonNull LatLng point) {
+ PointF centerPoint = new PointF(width / 2, (height + dropPinView.getHeight()) / 2);
+ LatLng centerLatLng = new LatLng(projection.fromScreenLocation(centerPoint));
+
+ setMessage("Geocoding...");
+
+ mapboxMap.removeAnnotations();
+ mapboxMap.addMarker(new MarkerOptions().position(centerLatLng));
+
+ geocode(centerLatLng);
+ }
+ });
+ }
+
+ @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
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ /*
+ * Forward geocoding
+ */
+
+ private void geocode(final LatLng point) {
+
+ try {
+ MapboxGeocoding client = new MapboxGeocoding.Builder()
+ .setAccessToken(getString(R.string.mapbox_access_token))
+ .setCoordinates(Position.fromCoordinates(point.getLongitude(), point.getLatitude()))
+ .setGeocodingType(GeocodingCriteria.TYPE_POI)
+ .build();
+
+ client.enqueueCall(new Callback<GeocodingResponse>() {
+ @Override
+ public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) {
+
+ List<CarmenFeature> results = response.body().getFeatures();
+ if (results.size() > 0) {
+ String placeName = results.get(0).getPlaceName();
+ setSuccess(placeName);
+ } else {
+ setMessage("No results.");
+ }
- /*
- * Forward geocoding
- */
-
- private void geocode(final LatLng point) {
-
- try {
- MapboxGeocoding client = new MapboxGeocoding.Builder()
- .setAccessToken(getString(R.string.mapbox_access_token))
- .setCoordinates(Position.fromCoordinates(point.getLongitude(), point.getLatitude()))
- .setGeocodingType(GeocodingCriteria.TYPE_POI)
- .build();
-
- client.enqueueCall(new Callback<GeocodingResponse>() {
- @Override
- public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) {
-
- List<CarmenFeature> results = response.body().getFeatures();
- if (results.size() > 0) {
- String placeName = results.get(0).getPlaceName();
- setSuccess(placeName);
- } else {
- setMessage("No results.");
- }
-
- }
-
- @Override
- public void onFailure(Call<GeocodingResponse> call, Throwable throwable) {
- setError(throwable.getMessage());
- }
- });
- } catch (ServicesException servicesException) {
- Timber.e("Error geocoding: " + servicesException.toString());
- servicesException.printStackTrace();
- setError(servicesException.getMessage());
}
- }
- /*
- * Update text view
- */
-
- private void setMessage(String message) {
- Timber.d("Message: " + message);
- textView.setText(message);
- }
-
- private void setSuccess(String placeName) {
- Timber.d("Place name: " + placeName);
- textView.setText(placeName);
- }
-
- private void setError(String message) {
- Timber.e("Error: " + message);
- textView.setText("Error: " + message);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ @Override
+ public void onFailure(Call<GeocodingResponse> call, Throwable throwable) {
+ setError(throwable.getMessage());
}
+ });
+ } catch (ServicesException servicesException) {
+ Timber.e("Error geocoding: " + servicesException.toString());
+ servicesException.printStackTrace();
+ setError(servicesException.getMessage());
+ }
+ }
+
+ /*
+ * Update text view
+ */
+
+ private void setMessage(String message) {
+ Timber.d("Message: " + message);
+ textView.setText(message);
+ }
+
+ private void setSuccess(String placeName) {
+ Timber.d("Place name: " + placeName);
+ textView.setText(placeName);
+ }
+
+ private void setError(String message) {
+ Timber.e("Error: " + message);
+ textView.setText("Error: " + message);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java
index 6f3e556242..7f3c16d7b8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java
@@ -17,103 +17,103 @@ import com.mapbox.mapboxsdk.testapp.R;
public class PrintActivity extends AppCompatActivity implements MapboxMap.SnapshotReadyCallback {
- private MapView mapView;
- private MapboxMap mapboxMap;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_print);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_print);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final 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 MapboxMap mapboxMap) {
- PrintActivity.this.mapboxMap = mapboxMap;
- }
- });
-
- final View fab = findViewById(R.id.fab);
- if (fab != null) {
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- mapboxMap.snapshot(PrintActivity.this);
- }
- }
- });
- }
- }
-
- @Override
- public void onSnapshotReady(Bitmap snapshot) {
- PrintHelper photoPrinter = new PrintHelper(this);
- photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
- photoPrinter.printBitmap("map.jpg - mapbox print job", snapshot);
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ PrintActivity.this.mapboxMap = mapboxMap;
+ }
+ });
+
+ final View fab = findViewById(R.id.fab);
+ if (fab != null) {
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ mapboxMap.snapshot(PrintActivity.this);
+ }
}
+ });
+ }
+ }
+
+ @Override
+ public void onSnapshotReady(Bitmap snapshot) {
+ PrintHelper photoPrinter = new PrintHelper(this);
+ photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
+ photoPrinter.printBitmap("map.jpg - mapbox print job", snapshot);
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java
index 2da0e19a23..3912dfa918 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java
@@ -20,107 +20,107 @@ import com.mapbox.mapboxsdk.testapp.R;
public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCallback, View.OnClickListener {
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_snapshot);
-
- 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(this);
- }
-
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.setStyleUrl(Style.OUTDOORS);
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- if (fab != null) {
- fab.setColorFilter(ContextCompat.getColor(SnapshotActivity.this, R.color.primary));
- fab.setOnClickListener(this);
- }
- }
-
- @Override
- public void onClick(View view) {
- final long startTime = System.nanoTime();
- mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
- @Override
- public void onSnapshotReady(Bitmap snapshot) {
- long endTime = System.nanoTime();
- long duration = (long) ((endTime - startTime) / 1e6);
- ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
- snapshotView.setImageBitmap(snapshot);
- Toast.makeText(
- SnapshotActivity.this,
- String.format("Snapshot taken in %d ms", duration),
- Toast.LENGTH_LONG).show();
- }
- });
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_snapshot);
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.setStyleUrl(Style.OUTDOORS);
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ if (fab != null) {
+ fab.setColorFilter(ContextCompat.getColor(SnapshotActivity.this, R.color.primary));
+ fab.setOnClickListener(this);
}
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ }
+
+ @Override
+ public void onClick(View view) {
+ final long startTime = System.nanoTime();
+ mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
+ @Override
+ public void onSnapshotReady(Bitmap snapshot) {
+ long endTime = System.nanoTime();
+ long duration = (long) ((endTime - startTime) / 1e6);
+ ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
+ snapshotView.setImageBitmap(snapshot);
+ Toast.makeText(
+ SnapshotActivity.this,
+ String.format("Snapshot taken in %d ms", duration),
+ Toast.LENGTH_LONG).show();
+ }
+ });
+ }
+
+ @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 onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
index 8942f69b90..c70e263be5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
@@ -31,154 +31,157 @@ import com.mapbox.mapboxsdk.testapp.R;
*/
public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapboxMap mapboxMap;
- private MapView mapView;
+ private MapboxMap mapboxMap;
+ private MapView mapView;
- private LatLng paris = new LatLng(48.864716, 2.349014);
+ private LatLng paris = new LatLng(48.864716, 2.349014);
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_infowindow_adapter);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_infowindow_adapter);
- setupActionBar();
+ setupActionBar();
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
-
- @Override
- public void onMapReady(MapboxMap map) {
-
- mapboxMap = map;
-
- //Add info window adapter
- addCustomInfoWindowAdapter(mapboxMap);
-
- //Keep info windows open on click
- mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
-
- //Add a marker
- final MarkerView marker = addMarker(mapboxMap);
- mapboxMap.selectMarker(marker);
-
- //On map click, change the info window contents
- mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
- @Override
- public void onMapClick(@NonNull LatLng point) {
- //Distance from click to marker
- double distanceKm = marker.getPosition().distanceTo(point) / 1000;
-
- //Get the info window
- InfoWindow infoWindow = marker.getInfoWindow();
-
- //Get the view from the info window
- if (infoWindow != null && infoWindow.getView() != null) {
- //Set the new text on the text view in the info window
- ((TextView) infoWindow.getView()).setText(String.format("%.2fkm", distanceKm));
-
- //Update the info window position (as the text length changes)
- infoWindow.update();
- }
- }
- });
-
- //Focus on Paris
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(paris));
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
- private MarkerView addMarker(MapboxMap mapboxMap) {
- IconFactory iconFactory = IconFactory.getInstance(this);
- Drawable iconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp);
- iconDrawable.setColorFilter(getResources().getColor(R.color.mapbox_blue), PorterDuff.Mode.SRC_IN);
+ @Override
+ public void onMapReady(MapboxMap map) {
- return mapboxMap.addMarker(
- new MarkerViewOptions()
- .position(paris)
- .icon(iconFactory.fromDrawable(iconDrawable))
- );
- }
-
- private void addCustomInfoWindowAdapter(final MapboxMap mapboxMap) {
- final int padding = (int) getResources().getDimension(R.dimen.attr_margin);
- mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
-
- @Nullable
- @Override
- public View getInfoWindow(@NonNull Marker marker) {
- TextView textView = new TextView(DynamicInfoWindowAdapterActivity.this);
- textView.setText(marker.getTitle());
- textView.setBackgroundColor(Color.WHITE);
- textView.setText("Click the map to calculate the distance");
- textView.setPadding(padding, padding, padding, padding);
-
- return textView;
- }
- });
- }
+ mapboxMap = map;
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ //Add info window adapter
+ addCustomInfoWindowAdapter(mapboxMap);
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ //Keep info windows open on click
+ mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ //Add a marker
+ final MarkerView marker = addMarker(mapboxMap);
+ mapboxMap.selectMarker(marker);
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ //On map click, change the info window contents
+ mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
+ @Override
+ public void onMapClick(@NonNull LatLng point) {
+ //Distance from click to marker
+ double distanceKm = marker.getPosition().distanceTo(point) / 1000;
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ //Get the info window
+ InfoWindow infoWindow = marker.getInfoWindow();
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ //Get the view from the info window
+ if (infoWindow != null && infoWindow.getView() != null) {
+ //Set the new text on the text view in the info window
+ ((TextView) infoWindow.getView()).setText(String.format("%.2fkm", distanceKm));
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ //Update the info window position (as the text length changes)
+ infoWindow.update();
}
+ }
+ });
+
+ //Focus on Paris
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(paris));
+ }
+
+ private MarkerView addMarker(MapboxMap mapboxMap) {
+ IconFactory iconFactory = IconFactory.getInstance(this);
+ Drawable iconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp);
+ iconDrawable.setColorFilter(
+ ContextCompat.getColor(DynamicInfoWindowAdapterActivity.this, R.color.mapbox_blue),
+ PorterDuff.Mode.SRC_IN
+ );
+
+ return mapboxMap.addMarker(
+ new MarkerViewOptions()
+ .position(paris)
+ .icon(iconFactory.fromDrawable(iconDrawable))
+ );
+ }
+
+ private void addCustomInfoWindowAdapter(final MapboxMap mapboxMap) {
+ final int padding = (int) getResources().getDimension(R.dimen.attr_margin);
+ mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
+
+ @Nullable
+ @Override
+ public View getInfoWindow(@NonNull Marker marker) {
+ TextView textView = new TextView(DynamicInfoWindowAdapterActivity.this);
+ textView.setText(marker.getTitle());
+ textView.setBackgroundColor(Color.WHITE);
+ textView.setText("Click the map to calculate the distance");
+ textView.setPadding(padding, padding, padding, padding);
+
+ return textView;
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java
index e8e207e180..0c2af9b7e3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java
@@ -8,6 +8,7 @@ import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
+
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
@@ -15,182 +16,183 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.maps.MapView;
+
import java.text.DecimalFormat;
public class InfoWindowActivity extends AppCompatActivity
- implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnMapLongClickListener,
- MapboxMap.OnInfoWindowClickListener, MapboxMap.OnInfoWindowLongClickListener {
-
- private MapboxMap mapboxMap;
- private MapView mapView;
- private Marker customMarker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_infowindow);
-
- 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(this);
- }
-
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- addMarkers();
- addInfoWindowListeners();
- }
-
- private void addMarkers() {
- mapboxMap.addMarker(new MarkerOptions()
- .title("Intersection")
- .snippet("H St NW with 15th St NW")
- .position(new LatLng(38.9002073, -77.03364419)));
-
- mapboxMap.addMarker(new MarkerOptions().title("Intersection")
- .snippet("E St NW with 17th St NW")
- .position(new LatLng(38.8954236, -77.0394623)));
-
- mapboxMap.addMarker(new MarkerOptions().title("The Ellipse").position(new LatLng(38.89393, -77.03654)));
-
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng(38.89596, -77.03434)));
-
- mapboxMap.addMarker(new MarkerOptions().snippet("Lafayette Square").position(new LatLng(38.89949, -77.03656)));
-
- Marker marker = mapboxMap.addMarker(new MarkerOptions()
- .title("White House")
- .snippet("The official residence and principal workplace of the President of the United States, "
- + "located at 1600 Pennsylvania Avenue NW in Washington, D.C. It has been the residence of every"
- + "U.S. president since John Adams in 1800.")
- .position(new LatLng(38.897705003219784, -77.03655168667463)));
-
- // open InfoWindow at startup
- mapboxMap.selectMarker(marker);
- }
-
- private void addInfoWindowListeners() {
- mapboxMap.setOnInfoWindowCloseListener(this);
- mapboxMap.setOnMapLongClickListener(this);
- mapboxMap.setOnInfoWindowClickListener(this);
- mapboxMap.setOnInfoWindowLongClickListener(this);
- }
-
- private void toggleConcurrentInfoWindow(boolean allowConcurrentInfoWindow) {
- mapboxMap.deselectMarkers();
- mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(allowConcurrentInfoWindow);
- }
-
- private void toggleDeselectMarkersOnTap(boolean deselectMarkersOnTap) {
- mapboxMap.getUiSettings().setDeselectMarkersOnTap(deselectMarkersOnTap);
- }
-
- @Override
- public boolean onInfoWindowClick(@NonNull Marker marker) {
- Toast.makeText(getApplicationContext(), "OnClick: " + marker.getTitle(), Toast.LENGTH_LONG).show();
- // returning true will leave the info window open
- return false;
- }
-
- @Override
- public void onInfoWindowClose(Marker marker) {
- Toast.makeText(getApplicationContext(), "OnClose: " + marker.getTitle(), Toast.LENGTH_LONG).show();
- }
-
- @Override
- public void onInfoWindowLongClick(Marker marker) {
- Toast.makeText(getApplicationContext(), "OnLongClick: " + marker.getTitle(), Toast.LENGTH_LONG).show();
- }
-
- @Override
- public void onMapLongClick(@NonNull LatLng point) {
- if (customMarker != null) {
- // Remove previous added marker
- mapboxMap.removeAnnotation(customMarker);
- customMarker = null;
- }
-
- // Add marker on long click location with default marker image
- customMarker = mapboxMap.addMarker(new MarkerOptions()
- .title("Custom Marker")
- .snippet(new DecimalFormat("#.#####").format(point.getLatitude()) + ", "
- + new DecimalFormat("#.#####").format(point.getLongitude()))
- .position(point));
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_infowindow, menu);
+ implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnMapLongClickListener,
+ MapboxMap.OnInfoWindowClickListener, MapboxMap.OnInfoWindowLongClickListener {
+
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private Marker customMarker;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_infowindow);
+
+ 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(this);
+ }
+
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ addMarkers();
+ addInfoWindowListeners();
+ }
+
+ private void addMarkers() {
+ mapboxMap.addMarker(new MarkerOptions()
+ .title("Intersection")
+ .snippet("H St NW with 15th St NW")
+ .position(new LatLng(38.9002073, -77.03364419)));
+
+ mapboxMap.addMarker(new MarkerOptions().title("Intersection")
+ .snippet("E St NW with 17th St NW")
+ .position(new LatLng(38.8954236, -77.0394623)));
+
+ mapboxMap.addMarker(new MarkerOptions().title("The Ellipse").position(new LatLng(38.89393, -77.03654)));
+
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(38.89596, -77.03434)));
+
+ mapboxMap.addMarker(new MarkerOptions().snippet("Lafayette Square").position(new LatLng(38.89949, -77.03656)));
+
+ Marker marker = mapboxMap.addMarker(new MarkerOptions()
+ .title("White House")
+ .snippet("The official residence and principal workplace of the President of the United States, "
+ + "located at 1600 Pennsylvania Avenue NW in Washington, D.C. It has been the residence of every"
+ + "U.S. president since John Adams in 1800.")
+ .position(new LatLng(38.897705003219784, -77.03655168667463)));
+
+ // open InfoWindow at startup
+ mapboxMap.selectMarker(marker);
+ }
+
+ private void addInfoWindowListeners() {
+ mapboxMap.setOnInfoWindowCloseListener(this);
+ mapboxMap.setOnMapLongClickListener(this);
+ mapboxMap.setOnInfoWindowClickListener(this);
+ mapboxMap.setOnInfoWindowLongClickListener(this);
+ }
+
+ private void toggleConcurrentInfoWindow(boolean allowConcurrentInfoWindow) {
+ mapboxMap.deselectMarkers();
+ mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(allowConcurrentInfoWindow);
+ }
+
+ private void toggleDeselectMarkersOnTap(boolean deselectMarkersOnTap) {
+ mapboxMap.getUiSettings().setDeselectMarkersOnTap(deselectMarkersOnTap);
+ }
+
+ @Override
+ public boolean onInfoWindowClick(@NonNull Marker marker) {
+ Toast.makeText(getApplicationContext(), "OnClick: " + marker.getTitle(), Toast.LENGTH_LONG).show();
+ // returning true will leave the info window open
+ return false;
+ }
+
+ @Override
+ public void onInfoWindowClose(Marker marker) {
+ Toast.makeText(getApplicationContext(), "OnClose: " + marker.getTitle(), Toast.LENGTH_LONG).show();
+ }
+
+ @Override
+ public void onInfoWindowLongClick(Marker marker) {
+ Toast.makeText(getApplicationContext(), "OnLongClick: " + marker.getTitle(), Toast.LENGTH_LONG).show();
+ }
+
+ @Override
+ public void onMapLongClick(@NonNull LatLng point) {
+ if (customMarker != null) {
+ // Remove previous added marker
+ mapboxMap.removeAnnotation(customMarker);
+ customMarker = null;
+ }
+
+ // Add marker on long click location with default marker image
+ customMarker = mapboxMap.addMarker(new MarkerOptions()
+ .title("Custom Marker")
+ .snippet(new DecimalFormat("#.#####").format(point.getLatitude()) + ", "
+ + new DecimalFormat("#.#####").format(point.getLongitude()))
+ .position(point));
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_infowindow, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_toggle_concurrent_infowindow:
+ toggleConcurrentInfoWindow(!item.isChecked());
+ item.setChecked(!item.isChecked());
return true;
+ case R.id.action_toggle_deselect_markers_on_tap:
+ toggleDeselectMarkersOnTap(!item.isChecked());
+ item.setChecked(!item.isChecked());
+ return true;
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_toggle_concurrent_infowindow:
- toggleConcurrentInfoWindow(!item.isChecked());
- item.setChecked(!item.isChecked());
- return true;
- case R.id.action_toggle_deselect_markers_on_tap:
- toggleDeselectMarkersOnTap(!item.isChecked());
- item.setChecked(!item.isChecked());
- return true;
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java
index 0c4c4de763..08f64abcba 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java
@@ -26,133 +26,133 @@ import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarkerOptions;
public class InfoWindowAdapterActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
- private IconFactory iconFactory;
- private Drawable iconDrawable;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_infowindow_adapter);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- iconFactory = IconFactory.getInstance(this);
- iconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp);
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap map) {
- mapboxMap = map;
- addMarkers();
- addCustomInfoWindowAdapter();
- }
- });
- }
-
- private void addMarkers() {
- mapboxMap.addMarker(generateCityStateMarker("Andorra", 42.505777, 1.52529, "#F44336"));
- mapboxMap.addMarker(generateCityStateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5"));
- mapboxMap.addMarker(generateCityStateMarker("Monaco", 43.738418, 7.424616, "#673AB7"));
- mapboxMap.addMarker(generateCityStateMarker("Vatican City", 41.902916, 12.453389, "#009688"));
- mapboxMap.addMarker(generateCityStateMarker("San Marino", 43.942360, 12.457777, "#795548"));
- mapboxMap.addMarker(generateCityStateMarker("Liechtenstein", 47.166000, 9.555373, "#FF5722"));
- }
-
- private CityStateMarkerOptions generateCityStateMarker(String title, double lat, double lng, String color) {
- CityStateMarkerOptions marker = new CityStateMarkerOptions();
- marker.title(title);
- marker.position(new LatLng(lat, lng));
- marker.infoWindowBackground(color);
-
- iconDrawable.setColorFilter(Color.parseColor(color), PorterDuff.Mode.SRC_IN);
- Icon icon = iconFactory.fromDrawable(iconDrawable);
- marker.icon(icon);
- return marker;
- }
-
- private void addCustomInfoWindowAdapter() {
- mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
-
- private int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);
-
- @Override
- public View getInfoWindow(@NonNull Marker marker) {
- TextView textView = new TextView(InfoWindowAdapterActivity.this);
- textView.setText(marker.getTitle());
- textView.setTextColor(Color.WHITE);
-
- if (marker instanceof CityStateMarker) {
- CityStateMarker cityStateMarker = (CityStateMarker) marker;
- textView.setBackgroundColor(Color.parseColor(cityStateMarker.getInfoWindowBackgroundColor()));
- }
-
- textView.setPadding(tenDp, tenDp, tenDp, tenDp);
- return textView;
- }
- });
- }
-
- @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();
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private IconFactory iconFactory;
+ private Drawable iconDrawable;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_infowindow_adapter);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ iconFactory = IconFactory.getInstance(this);
+ iconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp);
+
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap map) {
+ mapboxMap = map;
+ addMarkers();
+ addCustomInfoWindowAdapter();
+ }
+ });
+ }
+
+ private void addMarkers() {
+ mapboxMap.addMarker(generateCityStateMarker("Andorra", 42.505777, 1.52529, "#F44336"));
+ mapboxMap.addMarker(generateCityStateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5"));
+ mapboxMap.addMarker(generateCityStateMarker("Monaco", 43.738418, 7.424616, "#673AB7"));
+ mapboxMap.addMarker(generateCityStateMarker("Vatican City", 41.902916, 12.453389, "#009688"));
+ mapboxMap.addMarker(generateCityStateMarker("San Marino", 43.942360, 12.457777, "#795548"));
+ mapboxMap.addMarker(generateCityStateMarker("Liechtenstein", 47.166000, 9.555373, "#FF5722"));
+ }
+
+ private CityStateMarkerOptions generateCityStateMarker(String title, double lat, double lng, String color) {
+ CityStateMarkerOptions marker = new CityStateMarkerOptions();
+ marker.title(title);
+ marker.position(new LatLng(lat, lng));
+ marker.infoWindowBackground(color);
+
+ iconDrawable.setColorFilter(Color.parseColor(color), PorterDuff.Mode.SRC_IN);
+ Icon icon = iconFactory.fromDrawable(iconDrawable);
+ marker.icon(icon);
+ return marker;
+ }
+
+ private void addCustomInfoWindowAdapter() {
+ mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
+
+ private int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);
+
+ @Override
+ public View getInfoWindow(@NonNull Marker marker) {
+ TextView textView = new TextView(InfoWindowAdapterActivity.this);
+ textView.setText(marker.getTitle());
+ textView.setTextColor(Color.WHITE);
+
+ if (marker instanceof CityStateMarker) {
+ CityStateMarker cityStateMarker = (CityStateMarker) marker;
+ textView.setBackgroundColor(Color.parseColor(cityStateMarker.getInfoWindowBackgroundColor()));
}
+
+ textView.setPadding(tenDp, tenDp, tenDp, tenDp);
+ return textView;
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
index ca3fc5ed64..5c9d927e9b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
@@ -6,7 +6,9 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import android.view.View;
@@ -18,123 +20,123 @@ import com.mapbox.mapboxsdk.testapp.R;
public class DebugModeActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- private int currentStyleIndex = 0;
-
- private static final String[] STYLES = new String[]{
- Style.MAPBOX_STREETS,
- Style.OUTDOORS,
- Style.LIGHT,
- Style.DARK,
- Style.SATELLITE,
- Style.SATELLITE_STREETS
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_debug_mode);
-
- final 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.setTag(true);
- mapView.setStyleUrl(STYLES[currentStyleIndex]);
- mapView.onCreate(savedInstanceState);
-
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap map) {
- mapboxMap = map;
- }
- });
-
- FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
- fabDebug.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- Timber.d("Debug FAB: isDebug Active? " + mapboxMap.isDebugActive());
- mapboxMap.cycleDebugOptions();
- }
- }
- });
-
- FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
- fabStyles.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- currentStyleIndex++;
- if (currentStyleIndex == STYLES.length) {
- currentStyleIndex = 0;
- }
- mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
- }
- }
- });
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ private int currentStyleIndex = 0;
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ private static final String[] STYLES = new String[] {
+ Style.MAPBOX_STREETS,
+ Style.OUTDOORS,
+ Style.LIGHT,
+ Style.DARK,
+ Style.SATELLITE,
+ Style.SATELLITE_STREETS
+ };
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_debug_mode);
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setTag(true);
+ mapView.setStyleUrl(STYLES[currentStyleIndex]);
+ mapView.onCreate(savedInstanceState);
+
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap map) {
+ mapboxMap = map;
+ }
+ });
+
+ FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
+ fabDebug.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ Timber.d("Debug FAB: isDebug Active? " + mapboxMap.isDebugActive());
+ mapboxMap.cycleDebugOptions();
+ }
+ }
+ });
+
+ FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
+ fabStyles.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ currentStyleIndex++;
+ if (currentStyleIndex == STYLES.length) {
+ currentStyleIndex = 0;
+ }
+ mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
}
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
index b34962a792..5cb340bdd3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
@@ -28,165 +28,165 @@ import com.mapbox.mapboxsdk.testapp.R;
public class DoubleMapActivity extends AppCompatActivity {
- private static final String TAG_FRAGMENT = "map";
+ private static final String TAG_FRAGMENT = "map";
- // used for ui tests
- private MapboxMap mapboxMap;
+ // used for ui tests
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_map_fragment);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map_fragment);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- Fragment mapFragment;
- if (savedInstanceState == null) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.add(R.id.fragment_container, mapFragment = new DoubleMapFragment(), TAG_FRAGMENT);
- transaction.commit();
- } else {
- mapFragment = (DoubleMapFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT);
- }
+ Fragment mapFragment;
+ if (savedInstanceState == null) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.add(R.id.fragment_container, mapFragment = new DoubleMapFragment(), TAG_FRAGMENT);
+ transaction.commit();
+ } else {
+ mapFragment = (DoubleMapFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT);
+ }
+ }
+
+ public void setMapboxMap(MapboxMap map) {
+ // we need to set mapboxmap on the parent activity,
+ // for auto-generated ui tests
+
+ mapboxMap = map;
+ mapboxMap.setStyleUrl(Style.DARK);
+ mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
+ try {
+ TrackingSettings settings = mapboxMap.getTrackingSettings();
+ settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+ } catch (SecurityException securityException) {
+ // permission is handled in MainActivity
+ finish();
}
+ }
- public void setMapboxMap(MapboxMap map) {
- // we need to set mapboxmap on the parent activity,
- // for auto-generated ui tests
+ public static class DoubleMapFragment extends Fragment {
- mapboxMap = map;
- mapboxMap.setStyleUrl(Style.DARK);
- mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
- try {
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- } catch (SecurityException securityException) {
- // permission is handled in MainActivity
- finish();
- }
+ private DoubleMapActivity activity;
+ private MapView mapView;
+ private MapView mapViewMini;
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ activity = (DoubleMapActivity) context;
}
- public static class DoubleMapFragment extends Fragment {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_double_map, container, false);
+ }
- private DoubleMapActivity activity;
- private MapView mapView;
- private MapView mapViewMini;
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ // MapView large
+ mapView = (MapView) view.findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
@Override
- public void onAttach(Context context) {
- super.onAttach(context);
- activity = (DoubleMapActivity) context;
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ if (activity != null) {
+ activity.setMapboxMap(mapboxMap);
+ }
}
+ });
+ // MapView mini
+ mapViewMini = (MapView) view.findViewById(R.id.mini_map);
+ mapViewMini.onCreate(savedInstanceState);
+ mapViewMini.getMapAsync(new OnMapReadyCallback() {
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_double_map, container, false);
- }
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ mapboxMap.setStyleUrl(Style.LIGHT);
+ mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4));
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- // MapView large
- mapView = (MapView) view.findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- if (activity != null) {
- activity.setMapboxMap(mapboxMap);
- }
- }
- });
-
- // MapView mini
- mapViewMini = (MapView) view.findViewById(R.id.mini_map);
- mapViewMini.onCreate(savedInstanceState);
- mapViewMini.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mapboxMap.setStyleUrl(Style.LIGHT);
- mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4));
-
- UiSettings uiSettings = mapboxMap.getUiSettings();
- uiSettings.setAllGesturesEnabled(false);
- uiSettings.setCompassEnabled(false);
- uiSettings.setAttributionEnabled(false);
- uiSettings.setLogoEnabled(false);
-
- try {
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- } catch (SecurityException securityException) {
- // permission is handled in MainActivity
- getActivity().finish();
- }
-
- mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
- @Override
- public void onMapClick(@NonNull LatLng point) {
- // test if we can open 2 activities after each other
- startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
- }
- });
- }
- });
-
- SurfaceView surfaceViewMini = (SurfaceView) mapViewMini.findViewById(R.id.surfaceView);
- surfaceViewMini.setZOrderMediaOverlay(true);
- }
+ UiSettings uiSettings = mapboxMap.getUiSettings();
+ uiSettings.setAllGesturesEnabled(false);
+ uiSettings.setCompassEnabled(false);
+ uiSettings.setAttributionEnabled(false);
+ uiSettings.setLogoEnabled(false);
- @Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
- mapViewMini.onResume();
+ try {
+ TrackingSettings settings = mapboxMap.getTrackingSettings();
+ settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+ } catch (SecurityException securityException) {
+ // permission is handled in MainActivity
+ getActivity().finish();
+ }
+
+ mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
+ @Override
+ public void onMapClick(@NonNull LatLng point) {
+ // test if we can open 2 activities after each other
+ startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
+ }
+ });
}
+ });
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
- mapViewMini.onPause();
- }
+ SurfaceView surfaceViewMini = (SurfaceView) mapViewMini.findViewById(R.id.surfaceView);
+ surfaceViewMini.setZOrderMediaOverlay(true);
+ }
- @Override
- public void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- mapViewMini.onDestroy();
- }
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ mapViewMini.onResume();
+ }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- mapViewMini.onLowMemory();
- }
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ mapViewMini.onPause();
+ }
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- mapViewMini.onSaveInstanceState(outState);
- }
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ mapViewMini.onDestroy();
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ mapViewMini.onLowMemory();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ mapViewMini.onSaveInstanceState(outState);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java
index b80ef348e2..ed3f315e06 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java
@@ -14,115 +14,114 @@ import android.view.ViewGroup;
import android.widget.Button;
import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
public class MapInDialogActivity extends AppCompatActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map_in_dialog);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
+
+ Button button = (Button) findViewById(R.id.button_open_dialog);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ FragmentManager fm = getSupportFragmentManager();
+ MapDialogFragment editNameDialogFragment = MapDialogFragment.newInstance("Map Dialog");
+ editNameDialogFragment.show(fm, "fragment_dialog_map");
+ }
+ });
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ public static class MapDialogFragment extends DialogFragment {
+
+ private MapView mapView;
+
+ public MapDialogFragment() {
+ }
+
+ public static MapDialogFragment newInstance(String title) {
+ MapDialogFragment frag = new MapDialogFragment();
+ Bundle args = new Bundle();
+ args.putString("title", title);
+ frag.setArguments(args);
+ return frag;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_dialog_map, container);
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ mapView = (MapView) view.findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ mapView.onStart();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_map_in_dialog);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- Button button = (Button) findViewById(R.id.button_open_dialog);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- FragmentManager fm = getSupportFragmentManager();
- MapDialogFragment editNameDialogFragment = MapDialogFragment.newInstance("Map Dialog");
- editNameDialogFragment.show(fm, "fragment_dialog_map");
- }
- });
+ public void onStop() {
+ super.onStop();
+ mapView.onStop();
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ public void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
}
- public static class MapDialogFragment extends DialogFragment {
-
- private MapView mapView;
-
- public MapDialogFragment() {}
-
- public static MapDialogFragment newInstance(String title) {
- MapDialogFragment frag = new MapDialogFragment();
- Bundle args = new Bundle();
- args.putString("title", title);
- frag.setArguments(args);
- return frag;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_dialog_map, container);
- }
-
- @Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- mapView = (MapView) view.findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- }
-
- @Override
- public void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- public void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
index d127e03126..90b91057ed 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
@@ -21,143 +21,143 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MapPaddingActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_map_padding);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map_padding);
- final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ final 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.setTag(true);
- mapView.onCreate(savedInstanceState);
-
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- MapPaddingActivity.this.mapboxMap = mapboxMap;
-
- int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
- int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);
- int paddingRight = (int) getResources().getDimension(R.dimen.map_padding_right);
- mapboxMap.setPadding(paddingLeft, toolbar.getHeight(), paddingRight, paddingBottom);
-
- moveToBangalore();
- }
- });
- }
-
- @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();
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setTag(true);
+ mapView.onCreate(savedInstanceState);
+
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ MapPaddingActivity.this.mapboxMap = mapboxMap;
+
+ int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
+ int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);
+ int paddingRight = (int) getResources().getDimension(R.dimen.map_padding_right);
+ mapboxMap.setPadding(paddingLeft, toolbar.getHeight(), paddingRight, paddingBottom);
+
+ moveToBangalore();
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_padding, menu);
+ return true;
+ }
+
+ private void toggleGps(boolean enable) {
+ try {
+ // Enable user location
+ mapboxMap.setMyLocationEnabled(enable);
+
+ TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
+ trackingSettings.setDismissLocationTrackingOnGesture(false);
+ trackingSettings.setMyLocationTrackingMode(
+ enable ? MyLocationTracking.TRACKING_FOLLOW : MyLocationTracking.TRACKING_NONE);
+ } catch (SecurityException securityException) {
+ // permission not granted is handled in FeatureOverviewActivity
+ finish();
}
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_padding, menu);
+ }
+
+ private void moveToBangalore() {
+ toggleGps(false);
+
+ LatLng bangalore = new LatLng(12.9810816, 77.6368034);
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .zoom(16)
+ .target(bangalore)
+ .bearing(40)
+ .tilt(45)
+ .build();
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
+ mapboxMap.addMarker(new MarkerOptions().title("Center map").position(bangalore));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
return true;
- }
- private void toggleGps(boolean enable) {
- try {
- // Enable user location
- mapboxMap.setMyLocationEnabled(enable);
-
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- trackingSettings.setDismissTrackingOnGesture(false);
- trackingSettings.setMyLocationTrackingMode(
- enable ? MyLocationTracking.TRACKING_FOLLOW : MyLocationTracking.TRACKING_NONE);
- } catch (SecurityException securityException) {
- // permission not granted is handled in FeatureOverviewActivity
- finish();
+ case R.id.action_user_tracking:
+ if (mapboxMap != null) {
+ toggleGps(true);
}
- }
-
- private void moveToBangalore() {
- toggleGps(false);
-
- LatLng bangalore = new LatLng(12.9810816, 77.6368034);
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .zoom(16)
- .target(bangalore)
- .bearing(40)
- .tilt(45)
- .build();
-
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
- mapboxMap.addMarker(new MarkerOptions().title("Center map").position(bangalore));
- }
+ return true;
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
-
- case R.id.action_user_tracking:
- if (mapboxMap != null) {
- toggleGps(true);
- }
- return true;
-
- case R.id.action_bangalore:
- if (mapboxMap != null) {
- moveToBangalore();
- }
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
+ case R.id.action_bangalore:
+ if (mapboxMap != null) {
+ moveToBangalore();
}
+ return true;
+
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java
index 76363ef808..7f59dd3bdb 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java
@@ -32,221 +32,221 @@ import com.mapbox.mapboxsdk.testapp.R;
public class NavigationDrawerActivity extends AppCompatActivity {
- private boolean firstStyle = true;
- private MapboxMap mapboxMap;
+ private boolean firstStyle = true;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_navigation_drawer);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ NavigationDrawerFragment navigationDrawerFragment;
+
+ getFragmentManager()
+ .beginTransaction()
+ .add(R.id.navigation_drawer, navigationDrawerFragment = new NavigationDrawerFragment())
+ .commit();
+
+ navigationDrawerFragment.setUp(this,
+ R.id.navigation_drawer,
+ (DrawerLayout) findViewById(R.id.drawer_layout),
+ getSupportActionBar());
+ }
+
+ public void onNavigationDrawerItemSelected(int position) {
+ // update the main content by replacing fragments
+ switch (position) {
+ case 0:
+ // options
+ MapboxMapOptions options = new MapboxMapOptions();
+ options.styleUrl(firstStyle ? Style.LIGHT : Style.SATELLITE);
+ options.camera(new CameraPosition.Builder()
+ .target(new LatLng(39.913271, 116.413891))
+ .zoom(12)
+ .build());
+
+ // fragment
+ MapFragment mapFragment = MapFragment.newInstance(options);
+ FragmentManager fragmentManager = getFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.container, mapFragment)
+ .commit();
+
+ // get callback when map is ready
+ mapFragment.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ }
+ });
+
+ firstStyle = !firstStyle;
+ break;
+ case 1:
+ Snackbar.make(
+ findViewById(android.R.id.content),
+ "Hello from snackbar",
+ Snackbar.LENGTH_LONG)
+ .show();
+ break;
+ }
+ }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_navigation_drawer);
+ public static class NavigationDrawerFragment extends Fragment {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
+ private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
- NavigationDrawerFragment navigationDrawerFragment;
+ private ActionBarDrawerToggle drawerToggle;
- getFragmentManager()
- .beginTransaction()
- .add(R.id.navigation_drawer, navigationDrawerFragment = new NavigationDrawerFragment())
- .commit();
+ private DrawerLayout drawerLayout;
+ private ListView drawerListView;
+ private View fragmentContainerView;
- navigationDrawerFragment.setUp(this,
- R.id.navigation_drawer,
- (DrawerLayout) findViewById(R.id.drawer_layout),
- getSupportActionBar());
- }
+ private int currentSelectedPosition = 0;
+ private boolean fromSavedInstanceState;
+ private boolean userLearnedDrawer;
- public void onNavigationDrawerItemSelected(int position) {
- // update the main content by replacing fragments
- switch (position) {
- case 0:
- // options
- MapboxMapOptions options = new MapboxMapOptions();
- options.styleUrl(firstStyle ? Style.LIGHT : Style.SATELLITE);
- options.camera(new CameraPosition.Builder()
- .target(new LatLng(39.913271, 116.413891))
- .zoom(12)
- .build());
-
- // fragment
- MapFragment mapFragment = MapFragment.newInstance(options);
- FragmentManager fragmentManager = getFragmentManager();
- fragmentManager.beginTransaction()
- .replace(R.id.container, mapFragment)
- .commit();
-
- // get callback when map is ready
- mapFragment.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- }
- });
-
- firstStyle = !firstStyle;
- break;
- case 1:
- Snackbar.make(
- findViewById(android.R.id.content),
- "Hello from snackbar",
- Snackbar.LENGTH_LONG)
- .show();
- break;
- }
+ public NavigationDrawerFragment() {
}
- public static class NavigationDrawerFragment extends Fragment {
-
- private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
- private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
-
- private ActionBarDrawerToggle drawerToggle;
-
- private DrawerLayout drawerLayout;
- private ListView drawerListView;
- private View fragmentContainerView;
-
- private int currentSelectedPosition = 0;
- private boolean fromSavedInstanceState;
- private boolean userLearnedDrawer;
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ userLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
+
+ if (savedInstanceState != null) {
+ currentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
+ fromSavedInstanceState = true;
+ }
+ selectItem(currentSelectedPosition);
+ }
- public NavigationDrawerFragment() {
- }
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ drawerListView = (ListView) inflater.inflate(
+ R.layout.drawer_navigation_drawer, container, false);
+ drawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
- userLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
-
- if (savedInstanceState != null) {
- currentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
- fromSavedInstanceState = true;
- }
- selectItem(currentSelectedPosition);
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ selectItem(position);
}
+ });
+ drawerListView.setAdapter(new ArrayAdapter<>(
+ inflater.getContext(),
+ android.R.layout.simple_list_item_activated_1,
+ android.R.id.text1,
+ new String[] {
+ getString(R.string.title_section1),
+ getString(R.string.title_section2)
+ }));
+ drawerListView.setItemChecked(currentSelectedPosition, true);
+ return drawerListView;
+ }
+ /**
+ * Users of this fragment must call this method to set up the navigation drawer interactions.
+ *
+ * @param fragmentId The android:id of this fragment in its activity's layout.
+ * @param drawerLayout The DrawerLayout containing this fragment's UI.
+ */
+ public void setUp(Activity activity, int fragmentId, DrawerLayout drawerLayout, ActionBar actionBar) {
+ fragmentContainerView = activity.findViewById(fragmentId);
+ this.drawerLayout = drawerLayout;
+ // drawerLayout.setScrimColor(Color.TRANSPARENT);
+
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
+
+ drawerToggle = new ActionBarDrawerToggle(
+ activity,
+ NavigationDrawerFragment.this.drawerLayout,
+ R.string.navigation_drawer_open,
+ R.string.navigation_drawer_close
+ ) {
@Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- setHasOptionsMenu(true);
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ if (!isAdded()) {
+ return;
+ }
+ getActivity().invalidateOptionsMenu();
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- drawerListView = (ListView) inflater.inflate(
- R.layout.drawer_navigation_drawer, container, false);
- drawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- selectItem(position);
- }
- });
- drawerListView.setAdapter(new ArrayAdapter<>(
- inflater.getContext(),
- android.R.layout.simple_list_item_activated_1,
- android.R.id.text1,
- new String[]{
- getString(R.string.title_section1),
- getString(R.string.title_section2)
- }));
- drawerListView.setItemChecked(currentSelectedPosition, true);
- return drawerListView;
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ if (!isAdded()) {
+ return;
+ }
+
+ if (!userLearnedDrawer) {
+ userLearnedDrawer = true;
+ SharedPreferences sp = PreferenceManager
+ .getDefaultSharedPreferences(getActivity());
+ sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
+ }
+ getActivity().invalidateOptionsMenu();
}
+ };
- /**
- * Users of this fragment must call this method to set up the navigation drawer interactions.
- *
- * @param fragmentId The android:id of this fragment in its activity's layout.
- * @param drawerLayout The DrawerLayout containing this fragment's UI.
- */
- public void setUp(Activity activity, int fragmentId, DrawerLayout drawerLayout, ActionBar actionBar) {
- fragmentContainerView = activity.findViewById(fragmentId);
- this.drawerLayout = drawerLayout;
- // drawerLayout.setScrimColor(Color.TRANSPARENT);
-
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
-
- drawerToggle = new ActionBarDrawerToggle(
- activity,
- NavigationDrawerFragment.this.drawerLayout,
- R.string.navigation_drawer_open,
- R.string.navigation_drawer_close
- ) {
- @Override
- public void onDrawerClosed(View drawerView) {
- super.onDrawerClosed(drawerView);
- if (!isAdded()) {
- return;
- }
- getActivity().invalidateOptionsMenu();
- }
-
- @Override
- public void onDrawerOpened(View drawerView) {
- super.onDrawerOpened(drawerView);
- if (!isAdded()) {
- return;
- }
-
- if (!userLearnedDrawer) {
- userLearnedDrawer = true;
- SharedPreferences sp = PreferenceManager
- .getDefaultSharedPreferences(getActivity());
- sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
- }
- getActivity().invalidateOptionsMenu();
- }
- };
-
- if (!userLearnedDrawer && !fromSavedInstanceState) {
- this.drawerLayout.openDrawer(fragmentContainerView);
- }
- this.drawerLayout.post(new Runnable() {
- @Override
- public void run() {
- drawerToggle.syncState();
- }
- });
- this.drawerLayout.setDrawerListener(drawerToggle);
+ if (!userLearnedDrawer && !fromSavedInstanceState) {
+ this.drawerLayout.openDrawer(fragmentContainerView);
+ }
+ this.drawerLayout.post(new Runnable() {
+ @Override
+ public void run() {
+ drawerToggle.syncState();
}
+ });
+ this.drawerLayout.setDrawerListener(drawerToggle);
+ }
- private void selectItem(int position) {
- currentSelectedPosition = position;
- if (drawerListView != null) {
- drawerListView.setItemChecked(position, true);
- }
- if (drawerLayout != null) {
- drawerLayout.closeDrawer(fragmentContainerView);
- }
-
- Activity activity = getActivity();
- if (activity != null && activity instanceof NavigationDrawerActivity) {
- NavigationDrawerActivity navActivity = (NavigationDrawerActivity) activity;
- navActivity.onNavigationDrawerItemSelected(position);
- }
- }
+ private void selectItem(int position) {
+ currentSelectedPosition = position;
+ if (drawerListView != null) {
+ drawerListView.setItemChecked(position, true);
+ }
+ if (drawerLayout != null) {
+ drawerLayout.closeDrawer(fragmentContainerView);
+ }
+
+ Activity activity = getActivity();
+ if (activity != null && activity instanceof NavigationDrawerActivity) {
+ NavigationDrawerActivity navActivity = (NavigationDrawerActivity) activity;
+ navActivity.onNavigationDrawerItemSelected(position);
+ }
+ }
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition);
- }
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition);
+ }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- drawerToggle.onConfigurationChanged(newConfig);
- }
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ drawerToggle.onConfigurationChanged(newConfig);
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (drawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (drawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java
index 767b627d73..7e04b95e20 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java
@@ -1,92 +1,86 @@
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import android.util.Log;
import android.view.MenuItem;
-import android.view.View;
-import com.mapbox.mapboxsdk.constants.Style;
+
import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
public class SimpleMapActivity extends AppCompatActivity {
- private MapView mapView;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_map_simple);
+ private MapView mapView;
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_map_simple);
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ }
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ }
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ @Override
+ protected void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java
index 65ce23133f..4bb6bc5f39 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java
@@ -32,170 +32,170 @@ import com.mapbox.mapboxsdk.testapp.R;
public class CarDrivingActivity extends AppCompatActivity implements MapboxMap.OnMyLocationChangeListener {
- private static final int PERMISSIONS_LOCATION = 0;
+ private static final int PERMISSIONS_LOCATION = 0;
- private MapView mapView;
- private MapboxMap mapboxMap;
- private Location location;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private Location location;
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_car_driving);
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_car_driving);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- final 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 MapboxMap mapboxMap) {
- CarDrivingActivity.this.mapboxMap = mapboxMap;
-
- // view settings
- MyLocationViewSettings settings = mapboxMap.getMyLocationViewSettings();
- settings.setPadding(0, getWindow().getDecorView().getMeasuredHeight() / 3, 0, 0);
-
- // get car
- Drawable car = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_taxi_top_small, getTheme());
- settings.setForegroundTintColor(Color.TRANSPARENT);
- settings.setForegroundDrawable(car, car);
-
- // remove accuracy circle
- settings.setAccuracyAlpha(0);
-
- // disable dismissal when a gesture occurs
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- trackingSettings.setDismissLocationTrackingOnGesture(false);
- trackingSettings.setDismissBearingTrackingOnGesture(false);
-
- mapboxMap.setOnMyLocationChangeListener(CarDrivingActivity.this);
-
- if (savedInstanceState == null) {
- toggleGps(true);
- }
- }
- });
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @UiThread
- public void toggleGps(boolean enableGps) {
- if (enableGps) {
- if ((ContextCompat.checkSelfPermission(this,
- Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
- != PackageManager.PERMISSION_GRANTED)) {
- ActivityCompat.requestPermissions(this, new String[]{
- Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
- } else {
- enableLocation(true);
- }
- } else {
- enableLocation(false);
- }
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ CarDrivingActivity.this.mapboxMap = mapboxMap;
- private void enableLocation(boolean enabled) {
- if (enabled) {
- mapboxMap.setMyLocationEnabled(true);
- Location location = mapboxMap.getMyLocation();
- if (location != null) {
- setInitialPosition(new LatLng(location));
- }
- } else {
- mapboxMap.setMyLocationEnabled(false);
- }
- }
+ // view settings
+ MyLocationViewSettings settings = mapboxMap.getMyLocationViewSettings();
+ settings.setPadding(0, getWindow().getDecorView().getMeasuredHeight() / 3, 0, 0);
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (requestCode == PERMISSIONS_LOCATION) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- enableLocation(true);
- }
- }
- }
+ // get car
+ Drawable car = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_taxi_top_small, getTheme());
+ settings.setForegroundTintColor(Color.TRANSPARENT);
+ settings.setForegroundDrawable(car, car);
- private void setInitialPosition(LatLng latLng) {
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder().target(latLng).zoom(15).tilt(20f).build()));
- mapboxMap.setMyLocationEnabled(true);
+ // remove accuracy circle
+ settings.setAccuracyAlpha(0);
+ // disable dismissal when a gesture occurs
TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS);
- }
+ trackingSettings.setDismissLocationTrackingOnGesture(false);
+ trackingSettings.setDismissBearingTrackingOnGesture(false);
- @Override
- public void onMyLocationChange(@Nullable Location location) {
- if (location != null) {
- if (this.location == null) {
- // initial location to reposition map
- setInitialPosition(new LatLng(location));
- }
- this.location = location;
- }
- }
+ mapboxMap.setOnMyLocationChangeListener(CarDrivingActivity.this);
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ if (savedInstanceState == null) {
+ toggleGps(true);
+ }
+ }
+ });
+ }
+
+ @UiThread
+ public void toggleGps(boolean enableGps) {
+ if (enableGps) {
+ if ((ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(this, new String[] {
+ Manifest.permission.ACCESS_COARSE_LOCATION,
+ Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
+ } else {
+ enableLocation(true);
+ }
+ } else {
+ enableLocation(false);
}
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
+ }
+
+ private void enableLocation(boolean enabled) {
+ if (enabled) {
+ mapboxMap.setMyLocationEnabled(true);
+ Location location = mapboxMap.getMyLocation();
+ if (location != null) {
+ setInitialPosition(new LatLng(location));
+ }
+ } else {
+ mapboxMap.setMyLocationEnabled(false);
}
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == PERMISSIONS_LOCATION) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ enableLocation(true);
+ }
}
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ }
+
+ private void setInitialPosition(LatLng latLng) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder().target(latLng).zoom(15).tilt(20f).build()));
+ mapboxMap.setMyLocationEnabled(true);
+
+ TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
+ trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+ trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS);
+ }
+
+ @Override
+ public void onMyLocationChange(@Nullable Location location) {
+ if (location != null) {
+ if (this.location == null) {
+ // initial location to reposition map
+ setInitialPosition(new LatLng(location));
+ }
+ this.location = location;
}
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java
index 3dbcc24b3b..bb6b28393e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java
@@ -14,7 +14,9 @@ import android.support.v4.app.ActivityCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
@@ -59,417 +61,417 @@ import retrofit2.Response;
* Sample Activity to show a typical location picker use case
*/
public class LocationPickerActivity extends AppCompatActivity {
- private static final int REQUEST_PERMISSIONS = 101;
-
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- private ImageView dropPinView;
- private Marker addressPin;
- private ImageButton clearDisplayViewButton;
- private MarkerView userMarker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_location_picker);
-
- setupActionBar();
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
-
- //Create ui elements
- createDropPin();
- createSelectLocationButton();
- createClearSelectionButton();
-
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- //Store for later
- mapboxMap = map;
-
- //Add user marker
- mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
- new PulseMarkerViewAdapter(LocationPickerActivity.this));
- userMarker = createCustomUserMarker(new LatLng(0, 0));
-
- //Fix the focal point to the center of the map
- PointF focalPoint = new PointF(
- (mapView.getX() + mapView.getWidth() / 2), (mapView.getY() + mapView.getHeight() / 2));
- mapboxMap.getUiSettings().setFocalPoint(focalPoint);
-
- //Track camera updates to animate the user location views
- trackUserLocationView(userMarker);
- }
- });
- }
-
- private void zoomInOn(Location location) {
- //Move the camera to the user
- if (location != null) {
- mapboxMap.setCameraPosition(new CameraPosition.Builder()
- .target(new LatLng(location))
- .zoom(16)
- .bearing(0)
- .tilt(0)
- .build());
- }
- }
-
-
- /**
- * Tracks the camera to animate the marker when overlapping with the picker.
- * Makes sure the marker actually points to the user's position by tracking it.
- */
- private void trackUserLocationView(final MarkerView markerView) {
- final float circleDiameterSize = getResources().getDimension(R.dimen.circle_size);
-
- //Track camera changes to check for overlap
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
-
- private Animation pulseAnimation;
-
- @Override
- public void onCameraChange(CameraPosition position) {
- if (markerView == null) {
- return;
- }
-
- //Make drop pin visible, if it wasn't already
- showDropPin();
-
- //Get the distance from the tip of the location picker to the MarkerView
- double distance = getLocationPickerLocation().distanceTo(markerView.getPosition());
-
- //If closeby, animate, otherwise, stop animation
- View view = mapboxMap.getMarkerViewManager().getView(markerView);
- if (view != null) {
- View backgroundView = view.findViewById(R.id.background_imageview);
- if (pulseAnimation == null && distance < 0.5f * circleDiameterSize) {
- pulseAnimation = AnimationUtils.loadAnimation(LocationPickerActivity.this, R.anim.pulse);
- pulseAnimation.setRepeatCount(Animation.INFINITE);
- pulseAnimation.setRepeatMode(Animation.RESTART);
- backgroundView.startAnimation(pulseAnimation);
- } else if (pulseAnimation != null && distance >= 0.5f * circleDiameterSize) {
- backgroundView.clearAnimation();
- pulseAnimation = null;
- }
- }
- }
- });
-
- //Track location updates to move the user marker
- LocationServices.getLocationServices(getApplicationContext()).addLocationListener(new LocationListener() {
- @Override
- public void onLocationChanged(Location location) {
- if (location != null && markerView != null) {
- markerView.setPosition(new LatLng(location));
- }
- }
- });
+ private static final int REQUEST_PERMISSIONS = 101;
+
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+
+ private ImageView dropPinView;
+ private Marker addressPin;
+ private ImageButton clearDisplayViewButton;
+ private MarkerView userMarker;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_location_picker);
+
+ setupActionBar();
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+
+ //Create ui elements
+ createDropPin();
+ createSelectLocationButton();
+ createClearSelectionButton();
+
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ //Store for later
+ mapboxMap = map;
+
+ //Add user marker
+ mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
+ new PulseMarkerViewAdapter(LocationPickerActivity.this));
+ userMarker = createCustomUserMarker(new LatLng(0, 0));
+
+ //Fix the focal point to the center of the map
+ PointF focalPoint = new PointF(
+ (mapView.getX() + mapView.getWidth() / 2), (mapView.getY() + mapView.getHeight() / 2));
+ mapboxMap.getUiSettings().setFocalPoint(focalPoint);
+
+ //Track camera updates to animate the user location views
+ trackUserLocationView(userMarker);
+ }
+ });
+ }
+
+ private void zoomInOn(Location location) {
+ //Move the camera to the user
+ if (location != null) {
+ mapboxMap.setCameraPosition(new CameraPosition.Builder()
+ .target(new LatLng(location))
+ .zoom(16)
+ .bearing(0)
+ .tilt(0)
+ .build());
}
+ }
- private MarkerView createCustomUserMarker(LatLng markerPosition) {
- return mapboxMap.addMarker(new PulseMarkerViewOptions()
- .icon(IconFactory.getInstance(getApplicationContext()).fromResource(R.drawable.ic_my_location_24dp))
- .position(markerPosition)
- );
- }
- private void createClearSelectionButton() {
- clearDisplayViewButton = (ImageButton) findViewById(R.id.clearDisplayViewButton);
- clearDisplayViewButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- removeAddressPin();
- hide(clearDisplayViewButton);
- showDropPin();
- }
- });
- }
+ /**
+ * Tracks the camera to animate the marker when overlapping with the picker.
+ * Makes sure the marker actually points to the user's position by tracking it.
+ */
+ private void trackUserLocationView(final MarkerView markerView) {
+ final float circleDiameterSize = getResources().getDimension(R.dimen.circle_size);
- private void createSelectLocationButton() {
- Button selectLocationButton = (Button) findViewById(R.id.selectLocationButton);
- //noinspection ConstantConditions
- selectLocationButton.setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Timber.i("Location Selected!");
- if (mapboxMap != null) {
- //Control button's state
- clearDisplayViewButton.setVisibility(View.VISIBLE);
- dropPinView.setVisibility(View.INVISIBLE);
-
- //Get position for the drop pin
- LatLng position = getLocationPickerLocation();
-
- //Show the address pin (result)
- showAddressPin(position);
-
- //Get the address for that location and update the marker
- geocode(position, new GeocodeCallbacks() {
- @Override
- public void onResult(String result) {
- updateAddressPin(result);
- }
-
- @Override
- public void onFailure(Throwable failure) {
- showFeedbackMessage("Could not retrieve address: " + failure.getMessage());
- }
- });
- }
- }
- }
- );
- }
+ //Track camera changes to check for overlap
+ mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
- private void createDropPin() {
- float density = getResources().getDisplayMetrics().density;
+ private Animation pulseAnimation;
- dropPinView = new ImageView(this);
- dropPinView.setImageResource(R.drawable.ic_droppin_24dp);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
- params.bottomMargin = (int) (12 * density);
- dropPinView.setLayoutParams(params);
+ @Override
+ public void onCameraChange(CameraPosition position) {
+ if (markerView == null) {
+ return;
+ }
- mapView.addView(dropPinView);
- }
+ //Make drop pin visible, if it wasn't already
+ showDropPin();
- private void showDropPin() {
- if (dropPinView != null && dropPinView.getVisibility() != View.VISIBLE) {
- dropPinView.setVisibility(View.VISIBLE);
- }
- }
+ //Get the distance from the tip of the location picker to the MarkerView
+ double distance = getLocationPickerLocation().distanceTo(markerView.getPosition());
- private void hide(View view) {
+ //If closeby, animate, otherwise, stop animation
+ View view = mapboxMap.getMarkerViewManager().getView(markerView);
if (view != null) {
- view.setVisibility(View.INVISIBLE);
+ View backgroundView = view.findViewById(R.id.background_imageview);
+ if (pulseAnimation == null && distance < 0.5f * circleDiameterSize) {
+ pulseAnimation = AnimationUtils.loadAnimation(LocationPickerActivity.this, R.anim.pulse);
+ pulseAnimation.setRepeatCount(Animation.INFINITE);
+ pulseAnimation.setRepeatMode(Animation.RESTART);
+ backgroundView.startAnimation(pulseAnimation);
+ } else if (pulseAnimation != null && distance >= 0.5f * circleDiameterSize) {
+ backgroundView.clearAnimation();
+ pulseAnimation = null;
+ }
}
- }
-
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
+ }
+ });
+
+ //Track location updates to move the user marker
+ LocationServices.getLocationServices(getApplicationContext()).addLocationListener(new LocationListener() {
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location != null && markerView != null) {
+ markerView.setPosition(new LatLng(location));
}
- }
-
- /**
- * Get address for the given location
- */
- private void geocode(LatLng point, final GeocodeCallbacks callbacks) {
- try {
- //Create Geocoding client
- MapboxGeocoding client = new MapboxGeocoding.Builder()
- .setAccessToken(getString(R.string.mapbox_access_token))
- .setCoordinates(Position.fromCoordinates(point.getLongitude(), point.getLatitude()))
- .setGeocodingType(GeocodingCriteria.TYPE_ADDRESS)
- .build();
-
- //Place the request
- client.enqueueCall(new Callback<GeocodingResponse>() {
- @Override
- public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) {
-
- List<CarmenFeature> results = response.body().getFeatures();
- String address = null;
- if (results.size() > 0) {
- CarmenFeature feature = results.get(0);
- address = feature.getAddress() + " " + feature.getText();
- Timber.i("address " + address);
- } else {
- showFeedbackMessage("No results for search.");
- }
-
- callbacks.onResult(address);
- }
-
- @Override
- public void onFailure(Call<GeocodingResponse> call, Throwable throwable) {
- Timber.e("Geocoding Failure: " + throwable.getMessage());
- callbacks.onFailure(throwable);
- }
+ }
+ });
+ }
+
+ private MarkerView createCustomUserMarker(LatLng markerPosition) {
+ return mapboxMap.addMarker(new PulseMarkerViewOptions()
+ .icon(IconFactory.getInstance(getApplicationContext()).fromResource(R.drawable.ic_my_location_24dp))
+ .position(markerPosition)
+ );
+ }
+
+ private void createClearSelectionButton() {
+ clearDisplayViewButton = (ImageButton) findViewById(R.id.clearDisplayViewButton);
+ clearDisplayViewButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ removeAddressPin();
+ hide(clearDisplayViewButton);
+ showDropPin();
+ }
+ });
+ }
+
+ private void createSelectLocationButton() {
+ Button selectLocationButton = (Button) findViewById(R.id.selectLocationButton);
+ //noinspection ConstantConditions
+ selectLocationButton.setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Timber.i("Location Selected!");
+ if (mapboxMap != null) {
+ //Control button's state
+ clearDisplayViewButton.setVisibility(View.VISIBLE);
+ dropPinView.setVisibility(View.INVISIBLE);
+
+ //Get position for the drop pin
+ LatLng position = getLocationPickerLocation();
+
+ //Show the address pin (result)
+ showAddressPin(position);
+
+ //Get the address for that location and update the marker
+ geocode(position, new GeocodeCallbacks() {
+ @Override
+ public void onResult(String result) {
+ updateAddressPin(result);
+ }
+
+ @Override
+ public void onFailure(Throwable failure) {
+ showFeedbackMessage("Could not retrieve address: " + failure.getMessage());
+ }
});
- } catch (ServicesException servicesException) {
- Timber.e("Error geocoding: " + servicesException.toString());
- callbacks.onFailure(servicesException);
+ }
}
+ }
+ );
+ }
+
+ private void createDropPin() {
+ float density = getResources().getDisplayMetrics().density;
+
+ dropPinView = new ImageView(this);
+ dropPinView.setImageResource(R.drawable.ic_droppin_24dp);
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
+ params.bottomMargin = (int) (12 * density);
+ dropPinView.setLayoutParams(params);
+
+ mapView.addView(dropPinView);
+ }
+
+ private void showDropPin() {
+ if (dropPinView != null && dropPinView.getVisibility() != View.VISIBLE) {
+ dropPinView.setVisibility(View.VISIBLE);
}
+ }
- private LatLng getLocationPickerLocation() {
- return mapboxMap.getProjection().fromScreenLocation(
- new PointF(dropPinView.getLeft() + (dropPinView.getWidth() / 2), dropPinView.getBottom())
- );
+ private void hide(View view) {
+ if (view != null) {
+ view.setVisibility(View.INVISIBLE);
}
+ }
- private Marker showAddressPin(LatLng position) {
- if (addressPin != null) {
- //Remove previous pin
- removeAddressPin();
- }
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- //Create new one
- addressPin = mapboxMap.addMarker(new MarkerViewOptions().title("Loading address...").position(position));
- mapboxMap.selectMarker(addressPin);
- return addressPin;
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
-
- private void removeAddressPin() {
- if (mapboxMap != null && addressPin != null) {
- mapboxMap.removeMarker(addressPin);
+ }
+
+ /**
+ * Get address for the given location
+ */
+ private void geocode(LatLng point, final GeocodeCallbacks callbacks) {
+ try {
+ //Create Geocoding client
+ MapboxGeocoding client = new MapboxGeocoding.Builder()
+ .setAccessToken(getString(R.string.mapbox_access_token))
+ .setCoordinates(Position.fromCoordinates(point.getLongitude(), point.getLatitude()))
+ .setGeocodingType(GeocodingCriteria.TYPE_ADDRESS)
+ .build();
+
+ //Place the request
+ client.enqueueCall(new Callback<GeocodingResponse>() {
+ @Override
+ public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) {
+
+ List<CarmenFeature> results = response.body().getFeatures();
+ String address = null;
+ if (results.size() > 0) {
+ CarmenFeature feature = results.get(0);
+ address = feature.getAddress() + " " + feature.getText();
+ Timber.i("address " + address);
+ } else {
+ showFeedbackMessage("No results for search.");
+ }
+
+ callbacks.onResult(address);
}
- }
- private void updateAddressPin(@Nullable String address) {
- if (addressPin != null) {
- addressPin.setTitle(address == null ? "No address found" : address);
+ @Override
+ public void onFailure(Call<GeocodingResponse> call, Throwable throwable) {
+ Timber.e("Geocoding Failure: " + throwable.getMessage());
+ callbacks.onFailure(throwable);
}
+ });
+ } catch (ServicesException servicesException) {
+ Timber.e("Error geocoding: " + servicesException.toString());
+ callbacks.onFailure(servicesException);
}
-
- private void showFeedbackMessage(String message) {
- Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
+ }
+
+ private LatLng getLocationPickerLocation() {
+ return mapboxMap.getProjection().fromScreenLocation(
+ new PointF(dropPinView.getLeft() + (dropPinView.getWidth() / 2), dropPinView.getBottom())
+ );
+ }
+
+ private Marker showAddressPin(LatLng position) {
+ if (addressPin != null) {
+ //Remove previous pin
+ removeAddressPin();
}
- private boolean arePermissionsGranted() {
- if (Build.VERSION.SDK_INT >= 23
- && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
- && checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
- Timber.i("Requesting permissions");
- ActivityCompat.requestPermissions(this, new String[]{
- Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSIONS);
- return false;
- }
- Timber.i("Permissions already granted");
- return true;
- }
+ //Create new one
+ addressPin = mapboxMap.addMarker(new MarkerViewOptions().title("Loading address...").position(position));
+ mapboxMap.selectMarker(addressPin);
+ return addressPin;
+ }
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
-
- //Check permissions
- if (arePermissionsGranted()) {
- mapView.getMapAsync(new OnMapReadyCallback() {
-
- @Override
- public void onMapReady(final MapboxMap mapboxMap) {
- //Get the user's location
- final LocationServices locationServices = LocationServices.getLocationServices(getApplicationContext());
-
- Location location = locationServices.getLastLocation();
- if (location != null) {
- zoomInOn(location);
- userMarker.setPosition(new LatLng(location));
- } else {
- final ProgressDialog loadingDialog = ProgressDialog.show(
- LocationPickerActivity.this, "Loading", "Getting user location", false);
- locationServices.addLocationListener(new LocationListener() {
- @Override
- public void onLocationChanged(@Nullable Location location) {
- //Move the camera to the user
- if (location != null) {
- zoomInOn(location);
- userMarker.setPosition(new LatLng(location));
- locationServices.removeLocationListener(this);
- loadingDialog.hide();
- }
- }
- });
- }
-
- locationServices.toggleGPS(true);
- }
- });
- }
+ private void removeAddressPin() {
+ if (mapboxMap != null && addressPin != null) {
+ mapboxMap.removeMarker(addressPin);
}
+ }
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
+ private void updateAddressPin(@Nullable String address) {
+ if (addressPin != null) {
+ addressPin.setTitle(address == null ? "No address found" : address);
}
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ }
+
+ private void showFeedbackMessage(String message) {
+ Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
+ }
+
+ private boolean arePermissionsGranted() {
+ if (Build.VERSION.SDK_INT >= 23
+ && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
+ && checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ Timber.i("Requesting permissions");
+ ActivityCompat.requestPermissions(this, new String[] {
+ Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSIONS);
+ return false;
}
+ Timber.i("Permissions already granted");
+ return true;
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ //Check permissions
+ if (arePermissionsGranted()) {
+ mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ @Override
+ public void onMapReady(final MapboxMap mapboxMap) {
+ //Get the user's location
+ final LocationServices locationServices = LocationServices.getLocationServices(getApplicationContext());
+
+ Location location = locationServices.getLastLocation();
+ if (location != null) {
+ zoomInOn(location);
+ userMarker.setPosition(new LatLng(location));
+ } else {
+ final ProgressDialog loadingDialog = ProgressDialog.show(
+ LocationPickerActivity.this, "Loading", "Getting user location", false);
+ locationServices.addLocationListener(new LocationListener() {
+ @Override
+ public void onLocationChanged(@Nullable Location location) {
+ //Move the camera to the user
+ if (location != null) {
+ zoomInOn(location);
+ userMarker.setPosition(new LatLng(location));
+ locationServices.removeLocationListener(this);
+ loadingDialog.hide();
+ }
+ }
+ });
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ locationServices.toggleGPS(true);
}
+ });
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- /**
- * Custom MarkerViewAdapter for the pulsing marker
- */
- private static class PulseMarkerViewAdapter extends MapboxMap.MarkerViewAdapter<PulseMarkerView> {
+ /**
+ * Custom MarkerViewAdapter for the pulsing marker
+ */
+ private static class PulseMarkerViewAdapter extends MapboxMap.MarkerViewAdapter<PulseMarkerView> {
- private LayoutInflater inflater;
+ private LayoutInflater inflater;
- public PulseMarkerViewAdapter(@NonNull Context context) {
- super(context);
- this.inflater = LayoutInflater.from(context);
- }
+ public PulseMarkerViewAdapter(@NonNull Context context) {
+ super(context);
+ this.inflater = LayoutInflater.from(context);
+ }
- @Nullable
- @Override
- public View getView(@NonNull PulseMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
- ViewHolder viewHolder;
- if (convertView == null) {
- viewHolder = new ViewHolder();
- convertView = inflater.inflate(R.layout.view_pulse_marker, parent, false);
- viewHolder.foregroundImageView = (ImageView) convertView.findViewById(R.id.foreground_imageView);
- viewHolder.backgroundImageView = (ImageView) convertView.findViewById(R.id.background_imageview);
- convertView.setTag(viewHolder);
- }
- return convertView;
- }
+ @Nullable
+ @Override
+ public View getView(@NonNull PulseMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
+ ViewHolder viewHolder;
+ if (convertView == null) {
+ viewHolder = new ViewHolder();
+ convertView = inflater.inflate(R.layout.view_pulse_marker, parent, false);
+ viewHolder.foregroundImageView = (ImageView) convertView.findViewById(R.id.foreground_imageView);
+ viewHolder.backgroundImageView = (ImageView) convertView.findViewById(R.id.background_imageview);
+ convertView.setTag(viewHolder);
+ }
+ return convertView;
+ }
- private static class ViewHolder {
- ImageView foregroundImageView;
- ImageView backgroundImageView;
- }
+ private static class ViewHolder {
+ ImageView foregroundImageView;
+ ImageView backgroundImageView;
}
+ }
- private interface GeocodeCallbacks {
- void onResult(String result);
+ private interface GeocodeCallbacks {
+ void onResult(String result);
- void onFailure(Throwable failure);
- }
+ void onFailure(Throwable failure);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java
index 785217486f..ace0a83c27 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java
@@ -6,7 +6,9 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
@@ -36,320 +38,320 @@ import com.mapbox.mapboxsdk.testapp.utils.OfflineUtils;
import java.util.ArrayList;
public class OfflineActivity extends AppCompatActivity
- implements OfflineDownloadRegionDialog.DownloadRegionDialogListener {
-
- // JSON encoding/decoding
- public static final String JSON_CHARSET = "UTF-8";
- public static final String JSON_FIELD_REGION_NAME = "FIELD_REGION_NAME";
-
- // Style URL
- public static final String STYLE_URL = Style.MAPBOX_STREETS;
-
- /*
- * UI elements
- */
- private MapView mapView;
- private MapboxMap mapboxMap;
- private ProgressBar progressBar;
- private Button downloadRegion;
- private Button listRegions;
-
- private boolean isEndNotified;
-
- /*
- * Offline objects
- */
- private OfflineManager offlineManager;
- private OfflineRegion offlineRegion;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_offline);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- // You can use MapboxAccountManager.setConnected(Boolean) to manually set the connectivity
- // state of your app. This will override any checks performed via the ConnectivityManager.
- //MapboxAccountManager.getInstance().setConnected(false);
- Boolean connected = MapboxAccountManager.getInstance().isConnected();
- Timber.d(String.format(MapboxConstants.MAPBOX_LOCALE,
- "MapboxAccountManager is connected: %b", connected));
-
- // Set up map
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.setStyleUrl(STYLE_URL);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- Timber.d("Map is ready");
- OfflineActivity.this.mapboxMap = mapboxMap;
-
- // Set initial position to UNHQ in NYC
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(new LatLng(40.749851, -73.967966))
- .zoom(14)
- .bearing(0)
- .tilt(0)
- .build()));
- }
- });
-
- // The progress bar
- progressBar = (ProgressBar) findViewById(R.id.progress_bar);
-
- // Set up button listeners
- downloadRegion = (Button) findViewById(R.id.button_download_region);
- downloadRegion.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- handleDownloadRegion();
- }
- });
-
- listRegions = (Button) findViewById(R.id.button_list_regions);
- listRegions.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- handleListRegions();
- }
- });
-
- // Set up the OfflineManager
- offlineManager = OfflineManager.getInstance(this);
+ implements OfflineDownloadRegionDialog.DownloadRegionDialogListener {
+
+ // JSON encoding/decoding
+ public static final String JSON_CHARSET = "UTF-8";
+ public static final String JSON_FIELD_REGION_NAME = "FIELD_REGION_NAME";
+
+ // Style URL
+ public static final String STYLE_URL = Style.MAPBOX_STREETS;
+
+ /*
+ * UI elements
+ */
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private ProgressBar progressBar;
+ private Button downloadRegion;
+ private Button listRegions;
+
+ private boolean isEndNotified;
+
+ /*
+ * Offline objects
+ */
+ private OfflineManager offlineManager;
+ private OfflineRegion offlineRegion;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_offline);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ // You can use MapboxAccountManager.setConnected(Boolean) to manually set the connectivity
+ // state of your app. This will override any checks performed via the ConnectivityManager.
+ //MapboxAccountManager.getInstance().setConnected(false);
+ Boolean connected = MapboxAccountManager.getInstance().isConnected();
+ Timber.d(String.format(MapboxConstants.MAPBOX_LOCALE,
+ "MapboxAccountManager is connected: %b", connected));
+
+ // Set up map
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setStyleUrl(STYLE_URL);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ Timber.d("Map is ready");
+ OfflineActivity.this.mapboxMap = mapboxMap;
+
+ // Set initial position to UNHQ in NYC
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(new LatLng(40.749851, -73.967966))
+ .zoom(14)
+ .bearing(0)
+ .tilt(0)
+ .build()));
+ }
+ });
+
+ // The progress bar
+ progressBar = (ProgressBar) findViewById(R.id.progress_bar);
+
+ // Set up button listeners
+ downloadRegion = (Button) findViewById(R.id.button_download_region);
+ downloadRegion.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ handleDownloadRegion();
+ }
+ });
+
+ listRegions = (Button) findViewById(R.id.button_list_regions);
+ listRegions.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ handleListRegions();
+ }
+ });
+
+ // Set up the OfflineManager
+ offlineManager = OfflineManager.getInstance(this);
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ }
+
+ /*
+ * Buttons logic
+ */
+
+ private void handleDownloadRegion() {
+ Timber.d("handleDownloadRegion");
+
+ // Show dialog
+ OfflineDownloadRegionDialog offlineDownloadRegionDialog = new OfflineDownloadRegionDialog();
+ offlineDownloadRegionDialog.show(getSupportFragmentManager(), "download");
+ }
+
+ private void handleListRegions() {
+ Timber.d("handleListRegions");
+
+ // Query the DB asynchronously
+ offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
+ @Override
+ public void onList(OfflineRegion[] offlineRegions) {
+ // Check result
+ if (offlineRegions == null || offlineRegions.length == 0) {
+ Toast.makeText(OfflineActivity.this, "You have no regions yet.", Toast.LENGTH_SHORT).show();
+ return;
}
- }
- /*
- * Buttons logic
- */
+ // Get regions info
+ ArrayList<String> offlineRegionsNames = new ArrayList<>();
+ for (OfflineRegion offlineRegion : offlineRegions) {
+ offlineRegionsNames.add(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
+ }
- private void handleDownloadRegion() {
- Timber.d("handleDownloadRegion");
+ // Create args
+ Bundle args = new Bundle();
+ args.putStringArrayList(OfflineListRegionsDialog.ITEMS, offlineRegionsNames);
// Show dialog
- OfflineDownloadRegionDialog offlineDownloadRegionDialog = new OfflineDownloadRegionDialog();
- offlineDownloadRegionDialog.show(getSupportFragmentManager(), "download");
- }
-
- private void handleListRegions() {
- Timber.d("handleListRegions");
-
- // Query the DB asynchronously
- offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
- @Override
- public void onList(OfflineRegion[] offlineRegions) {
- // Check result
- if (offlineRegions == null || offlineRegions.length == 0) {
- Toast.makeText(OfflineActivity.this, "You have no regions yet.", Toast.LENGTH_SHORT).show();
- return;
- }
-
- // Get regions info
- ArrayList<String> offlineRegionsNames = new ArrayList<>();
- for (OfflineRegion offlineRegion : offlineRegions) {
- offlineRegionsNames.add(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
- }
-
- // Create args
- Bundle args = new Bundle();
- args.putStringArrayList(OfflineListRegionsDialog.ITEMS, offlineRegionsNames);
-
- // Show dialog
- OfflineListRegionsDialog offlineListRegionsDialog = new OfflineListRegionsDialog();
- offlineListRegionsDialog.setArguments(args);
- offlineListRegionsDialog.show(getSupportFragmentManager(), "list");
- }
-
- @Override
- public void onError(String error) {
- Timber.e("Error: " + error);
- }
- });
+ OfflineListRegionsDialog offlineListRegionsDialog = new OfflineListRegionsDialog();
+ offlineListRegionsDialog.setArguments(args);
+ offlineListRegionsDialog.show(getSupportFragmentManager(), "list");
+ }
+
+ @Override
+ public void onError(String error) {
+ Timber.e("Error: " + error);
+ }
+ });
+ }
+
+ /*
+ * Dialogs
+ */
+
+ @Override
+ public void onDownloadRegionDialogPositiveClick(final String regionName) {
+ if (TextUtils.isEmpty(regionName)) {
+ Toast.makeText(OfflineActivity.this, "Region name cannot be empty.", Toast.LENGTH_SHORT).show();
+ return;
}
- /*
- * Dialogs
- */
-
- @Override
- public void onDownloadRegionDialogPositiveClick(final String regionName) {
- if (TextUtils.isEmpty(regionName)) {
- Toast.makeText(OfflineActivity.this, "Region name cannot be empty.", Toast.LENGTH_SHORT).show();
- return;
+ // Start progress bar
+ Timber.d("Download started: " + regionName);
+ startProgress();
+
+ // Definition
+ LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
+ double minZoom = mapboxMap.getCameraPosition().zoom;
+ double maxZoom = mapboxMap.getMaxZoomLevel();
+ float pixelRatio = this.getResources().getDisplayMetrics().density;
+ OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
+ STYLE_URL, bounds, minZoom, maxZoom, pixelRatio);
+
+ // Sample way of encoding metadata from a JSONObject
+ byte[] metadata = OfflineUtils.convertRegionName(regionName);
+
+ // Create region
+ offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
+ @Override
+ public void onCreate(OfflineRegion offlineRegion) {
+ Timber.d("Offline region created: " + regionName);
+ OfflineActivity.this.offlineRegion = offlineRegion;
+ launchDownload();
+ }
+
+ @Override
+ public void onError(String error) {
+ Timber.e("Error: " + error);
+ }
+ });
+ }
+
+ private void launchDownload() {
+ // Set an observer
+ offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
+ @Override
+ public void onStatusChanged(OfflineRegionStatus status) {
+ // Compute a percentage
+ double percentage = status.getRequiredResourceCount() >= 0
+ ? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
+ 0.0;
+
+ if (status.isComplete()) {
+ // Download complete
+ endProgress("Region downloaded successfully.");
+ return;
+ } else if (status.isRequiredResourceCountPrecise()) {
+ // Switch to determinate state
+ setPercentage((int) Math.round(percentage));
}
- // Start progress bar
- Timber.d("Download started: " + regionName);
- startProgress();
-
- // Definition
- LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
- double minZoom = mapboxMap.getCameraPosition().zoom;
- double maxZoom = mapboxMap.getMaxZoomLevel();
- float pixelRatio = this.getResources().getDisplayMetrics().density;
- OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
- STYLE_URL, bounds, minZoom, maxZoom, pixelRatio);
-
- // Sample way of encoding metadata from a JSONObject
- byte[] metadata = OfflineUtils.convertRegionName(regionName);
-
- // Create region
- offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
- @Override
- public void onCreate(OfflineRegion offlineRegion) {
- Timber.d("Offline region created: " + regionName);
- OfflineActivity.this.offlineRegion = offlineRegion;
- launchDownload();
- }
-
- @Override
- public void onError(String error) {
- Timber.e("Error: " + error);
- }
- });
- }
-
- private void launchDownload() {
- // Set an observer
- offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
- @Override
- public void onStatusChanged(OfflineRegionStatus status) {
- // Compute a percentage
- double percentage = status.getRequiredResourceCount() >= 0
- ? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
- 0.0;
-
- if (status.isComplete()) {
- // Download complete
- endProgress("Region downloaded successfully.");
- return;
- } else if (status.isRequiredResourceCountPrecise()) {
- // Switch to determinate state
- setPercentage((int) Math.round(percentage));
- }
-
- // Debug
- Timber.d(String.format("%s/%s resources; %s bytes downloaded.",
- String.valueOf(status.getCompletedResourceCount()),
- String.valueOf(status.getRequiredResourceCount()),
- String.valueOf(status.getCompletedResourceSize())));
- }
-
- @Override
- public void onError(OfflineRegionError error) {
- Timber.e("onError reason: " + error.getReason());
- Timber.e("onError message: " + error.getMessage());
- }
-
- @Override
- public void mapboxTileCountLimitExceeded(long limit) {
- Timber.e("Mapbox tile count limit exceeded: " + limit);
- }
- });
-
- // Change the region state
- offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
- }
-
- /*
- * Progress bar
- */
-
- private void startProgress() {
- // Disable buttons
- downloadRegion.setEnabled(false);
- listRegions.setEnabled(false);
-
- // Start and show the progress bar
- isEndNotified = false;
- progressBar.setIndeterminate(true);
- progressBar.setVisibility(View.VISIBLE);
- }
-
- private void setPercentage(final int percentage) {
- progressBar.setIndeterminate(false);
- progressBar.setProgress(percentage);
+ // Debug
+ Timber.d(String.format("%s/%s resources; %s bytes downloaded.",
+ String.valueOf(status.getCompletedResourceCount()),
+ String.valueOf(status.getRequiredResourceCount()),
+ String.valueOf(status.getCompletedResourceSize())));
+ }
+
+ @Override
+ public void onError(OfflineRegionError error) {
+ Timber.e("onError reason: " + error.getReason());
+ Timber.e("onError message: " + error.getMessage());
+ }
+
+ @Override
+ public void mapboxTileCountLimitExceeded(long limit) {
+ Timber.e("Mapbox tile count limit exceeded: " + limit);
+ }
+ });
+
+ // Change the region state
+ offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
+ }
+
+ /*
+ * Progress bar
+ */
+
+ private void startProgress() {
+ // Disable buttons
+ downloadRegion.setEnabled(false);
+ listRegions.setEnabled(false);
+
+ // Start and show the progress bar
+ isEndNotified = false;
+ progressBar.setIndeterminate(true);
+ progressBar.setVisibility(View.VISIBLE);
+ }
+
+ private void setPercentage(final int percentage) {
+ progressBar.setIndeterminate(false);
+ progressBar.setProgress(percentage);
+ }
+
+ private void endProgress(final String message) {
+ // Don't notify more than once
+ if (isEndNotified) {
+ return;
}
- private void endProgress(final String message) {
- // Don't notify more than once
- if (isEndNotified) {
- return;
- }
-
- // Enable buttons
- downloadRegion.setEnabled(true);
- listRegions.setEnabled(true);
+ // Enable buttons
+ downloadRegion.setEnabled(true);
+ listRegions.setEnabled(true);
- // Stop and hide the progress bar
- isEndNotified = true;
- progressBar.setIndeterminate(false);
- progressBar.setVisibility(View.GONE);
+ // Stop and hide the progress bar
+ isEndNotified = true;
+ progressBar.setIndeterminate(false);
+ progressBar.setVisibility(View.GONE);
- // Show a toast
- Toast.makeText(OfflineActivity.this, message, Toast.LENGTH_LONG).show();
- }
+ // Show a toast
+ Toast.makeText(OfflineActivity.this, message, Toast.LENGTH_LONG).show();
+ }
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java
index 0530f1c157..a83cabba12 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java
@@ -33,154 +33,158 @@ import java.util.List;
*/
public class UpdateMetadataActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
- private OfflineRegionMetadataAdapter adapter;
+ private OfflineRegionMetadataAdapter adapter;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_metadata_update);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_metadata_update);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
- ListView listView = (ListView) findViewById(R.id.listView);
- listView.setAdapter(adapter = new OfflineRegionMetadataAdapter(this));
- listView.setEmptyView(findViewById(android.R.id.empty));
- listView.setOnItemClickListener(this);
+ ListView listView = (ListView) findViewById(R.id.listView);
+ listView.setAdapter(adapter = new OfflineRegionMetadataAdapter(this));
+ listView.setEmptyView(findViewById(android.R.id.empty));
+ listView.setOnItemClickListener(this);
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ final OfflineRegion region = adapter.getItem(position);
+ String metadata = OfflineUtils.convertRegionName(region.getMetadata());
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle("Rename metadata");
+
+ final EditText input = new EditText(this);
+ input.setText(metadata);
+ input.setInputType(InputType.TYPE_CLASS_TEXT);
+ input.setSelection(metadata.length());
+ builder.setView(input);
+
+ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ updateMetadata(region, OfflineUtils.convertRegionName(input.getText().toString()));
+ }
+ });
+ builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ builder.show();
+ }
+
+ private void updateMetadata(OfflineRegion region, byte[] metadata) {
+ region.updateMetadata(metadata, new OfflineRegion.OfflineRegionUpdateMetadataCallback() {
+ @Override
+ public void onUpdate(byte[] metadata) {
+ adapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void onError(String error) {
+ Toast.makeText(
+ UpdateMetadataActivity.this,
+ "Region metadata update failed with " + error,
+ Toast.LENGTH_LONG
+ ).show();
+ }
+ });
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ loadOfflineRegions();
+ }
+
+ private void loadOfflineRegions() {
+ OfflineManager.getInstance(this).listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
+ @Override
+ public void onList(OfflineRegion[] offlineRegions) {
+ if (offlineRegions != null && offlineRegions.length > 0) {
+ adapter.setOfflineRegions(Arrays.asList(offlineRegions));
+ }
+ }
+
+ @Override
+ public void onError(String error) {
+ Toast.makeText(UpdateMetadataActivity.this, "Error loading regions " + error, Toast.LENGTH_LONG).show();
+ }
+ });
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- final OfflineRegion region = adapter.getItem(position);
- String metadata = OfflineUtils.convertRegionName(region.getMetadata());
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Rename metadata");
-
- final EditText input = new EditText(this);
- input.setText(metadata);
- input.setInputType(InputType.TYPE_CLASS_TEXT);
- input.setSelection(metadata.length());
- builder.setView(input);
-
- builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- updateMetadata(region, OfflineUtils.convertRegionName(input.getText().toString()));
- }
- });
- builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
-
- builder.show();
+ private static class OfflineRegionMetadataAdapter extends BaseAdapter {
+
+ private Context context;
+ private List<OfflineRegion> offlineRegions;
+
+ OfflineRegionMetadataAdapter(Context ctx) {
+ context = ctx;
+ offlineRegions = new ArrayList<>();
}
- private void updateMetadata(OfflineRegion region, byte[] metadata) {
- region.updateMetadata(metadata, new OfflineRegion.OfflineRegionUpdateMetadataCallback() {
- @Override
- public void onUpdate(byte[] metadata) {
- adapter.notifyDataSetChanged();
- }
-
- @Override
- public void onError(String error) {
- Toast.makeText(UpdateMetadataActivity.this, "Region metadata update failed with " + error, Toast.LENGTH_LONG).show();
- }
- });
+ void setOfflineRegions(List<OfflineRegion> offlineRegions) {
+ this.offlineRegions = offlineRegions;
+ notifyDataSetChanged();
}
@Override
- protected void onStart() {
- super.onStart();
- loadOfflineRegions();
+ public int getCount() {
+ return offlineRegions.size();
}
- private void loadOfflineRegions() {
- OfflineManager.getInstance(this).listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
- @Override
- public void onList(OfflineRegion[] offlineRegions) {
- if (offlineRegions != null && offlineRegions.length > 0) {
- adapter.setOfflineRegions(Arrays.asList(offlineRegions));
- }
- }
-
- @Override
- public void onError(String error) {
- Toast.makeText(UpdateMetadataActivity.this, "Error loading regions " + error, Toast.LENGTH_LONG).show();
- }
- });
+ @Override
+ public OfflineRegion getItem(int position) {
+ return offlineRegions.get(position);
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ public long getItemId(int position) {
+ return position;
}
- private static class OfflineRegionMetadataAdapter extends BaseAdapter {
-
- private Context context;
- private List<OfflineRegion> offlineRegions;
-
- OfflineRegionMetadataAdapter(Context ctx) {
- context = ctx;
- offlineRegions = new ArrayList<>();
- }
-
- void setOfflineRegions(List<OfflineRegion> offlineRegions) {
- this.offlineRegions = offlineRegions;
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return offlineRegions.size();
- }
-
- @Override
- public OfflineRegion getItem(int position) {
- return offlineRegions.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder holder;
-
- if (convertView == null) {
- holder = new ViewHolder();
- convertView = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false);
- holder.text = (TextView) convertView.findViewById(android.R.id.text1);
- convertView.setTag(holder);
- } else {
- holder = (ViewHolder) convertView.getTag();
- }
-
- holder.text.setText(OfflineUtils.convertRegionName(getItem(position).getMetadata()));
- return convertView;
- }
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+
+ if (convertView == null) {
+ holder = new ViewHolder();
+ convertView = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false);
+ holder.text = (TextView) convertView.findViewById(android.R.id.text1);
+ convertView.setTag(holder);
+ } else {
+ holder = (ViewHolder) convertView.getTag();
+ }
+
+ holder.text.setText(OfflineUtils.convertRegionName(getItem(position).getMetadata()));
+ return convertView;
+ }
- static class ViewHolder {
- TextView text;
- }
+ static class ViewHolder {
+ TextView text;
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
index 65af3365ec..1d90511888 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
@@ -8,7 +8,9 @@ import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import android.view.View;
@@ -33,120 +35,120 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
*/
public class CircleLayerActivity extends AppCompatActivity {
- private MapboxMap mapboxMap;
- private MapView mapView;
- private Layer circleLayer;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_circlelayer);
-
- 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;
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(CircleLayerActivity.this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (circleLayer == null) {
- // first time
- try {
- mapboxMap.addSource(new GeoJsonSource("point", new URL("https://gist.githubusercontent.com/anonymous/87eca90e80a72b1b42be9d0201ec3c8e/raw/acbb46384fd56044a504f122950d0637d98b4e7a/map.geojson")));
- } catch (MalformedURLException malformedUrlException) {
- Timber.e(
- "That's not an url... " + malformedUrlException.getMessage()
- );
- }
-
- circleLayer = new CircleLayer("circleLayer", "point");
- circleLayer.setProperties(
- circleColor(ResourcesCompat.getColor(getResources(), R.color.primary_dark, getTheme())),
- circleRadius(getResources().getDimension(R.dimen.circle_size))
- );
-
- // lets add a circle below labels!
- mapboxMap.addLayer(circleLayer, "waterway-label");
- } else {
- // change size and color
- circleLayer.setProperties(
- circleRadius(mapView.getTag() == null
- ? getResources().getDimension(R.dimen.activity_horizontal_margin)
- : getResources().getDimension(R.dimen.circle_size)),
- circleColor(mapView.getTag() == null ? ResourcesCompat.getColor(
- getResources(), R.color.blue_accent, getTheme()) : ResourcesCompat.getColor(
- getResources(), R.color.green_accent, getTheme())));
- mapView.setTag(mapView.getTag() == null ? mapboxMap : null);
- }
- }
- });
- }
- });
- }
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private Layer circleLayer;
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_circlelayer);
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @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 onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull final MapboxMap map) {
+ mapboxMap = map;
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(CircleLayerActivity.this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (circleLayer == null) {
+ // first time
+ try {
+ mapboxMap.addSource(new GeoJsonSource("point", new URL("https://gist.githubusercontent.com/anonymous/87eca90e80a72b1b42be9d0201ec3c8e/raw/acbb46384fd56044a504f122950d0637d98b4e7a/map.geojson")));
+ } catch (MalformedURLException malformedUrlException) {
+ Timber.e(
+ "That's not an url... " + malformedUrlException.getMessage()
+ );
+ }
+
+ circleLayer = new CircleLayer("circleLayer", "point");
+ circleLayer.setProperties(
+ circleColor(ResourcesCompat.getColor(getResources(), R.color.primary_dark, getTheme())),
+ circleRadius(getResources().getDimension(R.dimen.circle_size))
+ );
+
+ // lets add a circle below labels!
+ mapboxMap.addLayer(circleLayer, "waterway-label");
+ } else {
+ // change size and color
+ circleLayer.setProperties(
+ circleRadius(mapView.getTag() == null
+ ? getResources().getDimension(R.dimen.activity_horizontal_margin)
+ : getResources().getDimension(R.dimen.circle_size)),
+ circleColor(mapView.getTag() == null ? ResourcesCompat.getColor(
+ getResources(), R.color.blue_accent, getTheme()) : ResourcesCompat.getColor(
+ getResources(), R.color.green_accent, getTheme())));
+ mapView.setTag(mapView.getTag() == null ? mapboxMap : null);
+ }
+ }
+ });
+ }
+ });
+ }
+
+ @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 onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
index 96c74bfcd3..d68872a5ba 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
@@ -8,7 +8,9 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import android.view.View;
@@ -32,126 +34,133 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
* Example to add a sprite image and use it in a Symbol Layer
*/
public class CustomSpriteActivity extends AppCompatActivity {
- private static final String CUSTOM_ICON = "custom-icon";
-
- private MapboxMap mapboxMap;
- private MapView mapView;
- private Layer layer;
- private GeoJsonSource source;
-
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_sprite);
-
- 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;
- final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(CustomSpriteActivity.this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- private Point point;
-
- @Override
- public void onClick(View view) {
- if (point == null) {
- Timber.i("First click -> Car");
- // Add an icon to reference later
- mapboxMap.addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top));
-
- //Add a source with a geojson point
- point = Point.fromCoordinates(Position.fromCoordinates(13.400972d, 52.519003d));
- source = new GeoJsonSource("point", FeatureCollection.fromFeatures(new Feature[]{Feature.fromGeometry(point)}));
- mapboxMap.addSource(source);
-
- //Add a symbol layer that references that point source
- layer = new SymbolLayer("layer", "point");
- layer.setProperties(
- //Set the id of the sprite to use
- iconImage(CUSTOM_ICON)
- );
-
- // lets add a circle below labels!
- mapboxMap.addLayer(layer, "waterway-label");
-
- fab.setImageResource(R.drawable.ic_directions_car_black_24dp);
- } else {
- //Update point
- point = Point.fromCoordinates(Position.fromCoordinates(point.getCoordinates().getLongitude() + 0.001, point.getCoordinates().getLatitude() + 0.001));
- source.setGeoJson(FeatureCollection.fromFeatures(new Feature[]{Feature.fromGeometry(point)}));
-
- //Move the camera as well
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(point.getCoordinates().getLatitude(), point.getCoordinates().getLongitude())));
- }
- }
- });
- }
- });
- }
+ private static final String CUSTOM_ICON = "custom-icon";
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private Layer layer;
+ private GeoJsonSource source;
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add_sprite);
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @Override
- public void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull final MapboxMap map) {
+ mapboxMap = map;
+ final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(CustomSpriteActivity.this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
+ private Point point;
+
+ @Override
+ public void onClick(View view) {
+ if (point == null) {
+ Timber.i("First click -> Car");
+ // Add an icon to reference later
+ mapboxMap.addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top));
+
+ //Add a source with a geojson point
+ point = Point.fromCoordinates(Position.fromCoordinates(13.400972d, 52.519003d));
+ source = new GeoJsonSource(
+ "point",
+ FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)})
+ );
+ mapboxMap.addSource(source);
+
+ //Add a symbol layer that references that point source
+ layer = new SymbolLayer("layer", "point");
+ layer.setProperties(
+ //Set the id of the sprite to use
+ iconImage(CUSTOM_ICON)
+ );
+
+ // lets add a circle below labels!
+ mapboxMap.addLayer(layer, "waterway-label");
+
+ fab.setImageResource(R.drawable.ic_directions_car_black_24dp);
+ } else {
+ //Update point
+ point = Point.fromCoordinates(
+ Position.fromCoordinates(point.getCoordinates().getLongitude() + 0.001,
+ point.getCoordinates().getLatitude() + 0.001)
+ );
+ source.setGeoJson(FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)}));
+
+ //Move the camera as well
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(
+ point.getCoordinates().getLatitude(), point.getCoordinates().getLongitude())));
+ }
+ }
+ });
+ }
+ });
+ }
+
+ @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 onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java
index 0c25c91cdc..33fc7f60a6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java
@@ -6,7 +6,9 @@ import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
@@ -38,150 +40,150 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
*/
public class GeoJsonClusteringActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_geojson_clustering);
-
- setupActionBar();
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- //noinspection ConstantConditions
- mapView.onCreate(savedInstanceState);
-
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0));
-
- //Add a clustered source with some layers
- addClusteredGeoJsonSource();
- }
- });
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_geojson_clustering);
+
+ setupActionBar();
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ //noinspection ConstantConditions
+ mapView.onCreate(savedInstanceState);
+
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0));
+
+ //Add a clustered source with some layers
+ addClusteredGeoJsonSource();
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ }
+
+ private void addClusteredGeoJsonSource() {
+ //Add a clustered source
+ try {
+ mapboxMap.addSource(
+ new GeoJsonSource("earthquakes",
+ new URL("https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"),
+ new GeoJsonOptions()
+ .withCluster(true)
+ .withClusterMaxZoom(14)
+ .withClusterRadius(50)
+ )
+ );
+ } catch (MalformedURLException malformedUrlException) {
+ Timber.e("That's not an url... " + malformedUrlException.getMessage());
}
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ //Add unclustered layer
+ int[][] layers = new int[][] {
+ new int[] {150, ResourcesCompat.getColor(getResources(), R.color.red_accent, getTheme())},
+ new int[] {20, ResourcesCompat.getColor(getResources(), R.color.green_accent, getTheme())},
+ new int[] {0, ResourcesCompat.getColor(getResources(), R.color.blue_accent, getTheme())}
+ };
+
+ SymbolLayer unclustered = new SymbolLayer("unclustered-points", "earthquakes");
+ unclustered.setProperties(iconImage("marker-15"));
+ mapboxMap.addLayer(unclustered);
+
+ for (int i = 0; i < layers.length; i++) {
+ //Add some nice circles
+ CircleLayer circles = new CircleLayer("cluster-" + i, "earthquakes");
+ circles.setProperties(
+ circleColor(layers[i][1]),
+ circleRadius(18f)
+ );
+ circles.setFilter(
+ i == 0
+ ? gte("point_count", layers[i][0]) :
+ all(gte("point_count", layers[i][0]), lt("point_count", layers[i - 1][0]))
+ );
+ mapboxMap.addLayer(circles);
}
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ //Add the count labels
+ SymbolLayer count = new SymbolLayer("count", "earthquakes");
+ count.setProperties(
+ textField("{point_count}"),
+ textSize(12f),
+ textColor(Color.WHITE)
+ );
+ mapboxMap.addLayer(count);
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- private void addClusteredGeoJsonSource() {
- //Add a clustered source
- try {
- mapboxMap.addSource(
- new GeoJsonSource("earthquakes",
- new URL("https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"),
- new GeoJsonOptions()
- .withCluster(true)
- .withClusterMaxZoom(14)
- .withClusterRadius(50)
- )
- );
- } catch (MalformedURLException malformedUrlException) {
- Timber.e("That's not an url... " + malformedUrlException.getMessage());
- }
-
- //Add unclustered layer
- int[][] layers = new int[][]{
- new int[]{150, ResourcesCompat.getColor(getResources(), R.color.red_accent, getTheme())},
- new int[]{20, ResourcesCompat.getColor(getResources(), R.color.green_accent, getTheme())},
- new int[]{0, ResourcesCompat.getColor(getResources(), R.color.blue_accent, getTheme())}
- };
-
- SymbolLayer unclustered = new SymbolLayer("unclustered-points", "earthquakes");
- unclustered.setProperties(iconImage("marker-15"));
- mapboxMap.addLayer(unclustered);
-
- for (int i = 0; i < layers.length; i++) {
- //Add some nice circles
- CircleLayer circles = new CircleLayer("cluster-" + i, "earthquakes");
- circles.setProperties(
- circleColor(layers[i][1]),
- circleRadius(18f)
- );
- circles.setFilter(
- i == 0
- ? gte("point_count", layers[i][0]) :
- all(gte("point_count", layers[i][0]), lt("point_count", layers[i - 1][0]))
- );
- mapboxMap.addLayer(circles);
- }
-
- //Add the count labels
- SymbolLayer count = new SymbolLayer("count", "earthquakes");
- count.setProperties(
- textField("{point_count}"),
- textSize(12f),
- textColor(Color.WHITE)
- );
- mapboxMap.addLayer(count);
-
-
- //Zoom out to start
- mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1));
- }
+ //Zoom out to start
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1));
+ }
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java
index e995613c96..fad4f9714d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java
@@ -6,7 +6,9 @@ import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
+
import timber.log.Timber;
+
import android.view.MenuItem;
import com.mapbox.mapboxsdk.maps.MapView;
@@ -29,119 +31,119 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
*/
public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapReadyCallback {
- private final static String ID_GEOJSON_LAYER = "wanderdrone";
- private final static String ID_GEOJSON_SOURCE = ID_GEOJSON_LAYER;
- private final static String URL_GEOJSON_SOURCE = "https://wanderdrone.appspot.com/";
+ private static final String ID_GEOJSON_LAYER = "wanderdrone";
+ private static final String ID_GEOJSON_SOURCE = ID_GEOJSON_LAYER;
+ private static final String URL_GEOJSON_SOURCE = "https://wanderdrone.appspot.com/";
- private MapView mapView;
- private MapboxMap mapboxMap;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
- private Handler handler;
- private Runnable runnable;
+ private Handler handler;
+ private Runnable runnable;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_default);
-
- 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(this);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_default);
- @Override
- public void onMapReady(@NonNull final MapboxMap map) {
- mapboxMap = map;
-
- // add source
- try {
- mapboxMap.addSource(new GeoJsonSource(ID_GEOJSON_SOURCE, new URL(URL_GEOJSON_SOURCE)));
- }catch (MalformedURLException e){
- Timber.e("Invalid URL", e);
- }
-
- // add layer
- SymbolLayer layer = new SymbolLayer(ID_GEOJSON_LAYER, ID_GEOJSON_SOURCE);
- layer.setProperties(iconImage("rocket-15"));
- mapboxMap.addLayer(layer);
-
- // loop refresh geojson
- handler = new Handler();
- runnable = new RefreshGeoJsonRunnable(mapboxMap, handler);
- handler.postDelayed(runnable, 2000);
- }
+ 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
- public void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ public void onMapReady(@NonNull final MapboxMap map) {
+ mapboxMap = map;
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- handler.removeCallbacks(runnable);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ // add source
+ try {
+ mapboxMap.addSource(new GeoJsonSource(ID_GEOJSON_SOURCE, new URL(URL_GEOJSON_SOURCE)));
+ } catch (MalformedURLException malformedUrlException) {
+ Timber.e("Invalid URL", malformedUrlException);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ // add layer
+ SymbolLayer layer = new SymbolLayer(ID_GEOJSON_LAYER, ID_GEOJSON_SOURCE);
+ layer.setProperties(iconImage("rocket-15"));
+ mapboxMap.addLayer(layer);
+
+ // loop refresh geojson
+ handler = new Handler();
+ runnable = new RefreshGeoJsonRunnable(mapboxMap, handler);
+ handler.postDelayed(runnable, 2000);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ handler.removeCallbacks(runnable);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
- private static class RefreshGeoJsonRunnable implements Runnable {
+ private static class RefreshGeoJsonRunnable implements Runnable {
- private MapboxMap mapboxMap;
- private Handler handler;
+ private MapboxMap mapboxMap;
+ private Handler handler;
- RefreshGeoJsonRunnable(MapboxMap mapboxMap, Handler handler) {
- this.mapboxMap = mapboxMap;
- this.handler = handler;
- }
+ RefreshGeoJsonRunnable(MapboxMap mapboxMap, Handler handler) {
+ this.mapboxMap = mapboxMap;
+ this.handler = handler;
+ }
- @Override
- public void run() {
- ((GeoJsonSource) mapboxMap.getSource(ID_GEOJSON_SOURCE)).setUrl(URL_GEOJSON_SOURCE);
- handler.postDelayed(this, 2000);
- }
+ @Override
+ public void run() {
+ ((GeoJsonSource) mapboxMap.getSource(ID_GEOJSON_SOURCE)).setUrl(URL_GEOJSON_SOURCE);
+ handler.postDelayed(this, 2000);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
index 8143efb03d..2ac3a6fb00 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
@@ -7,7 +7,6 @@ import android.support.annotation.RawRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import timber.log.Timber;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
@@ -44,7 +43,8 @@ import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
-import static android.os.Looper.getMainLooper;
+import timber.log.Timber;
+
import static com.mapbox.mapboxsdk.style.layers.Filter.all;
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
import static com.mapbox.mapboxsdk.style.layers.Filter.gte;
@@ -75,508 +75,512 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
*/
public class RuntimeStyleActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_runtime_style);
-
- setupActionBar();
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
-
-
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- //Store for later
- mapboxMap = map;
-
- //Center and Zoom (Amsterdam, zoomed to streets)
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
- }
- });
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_runtime_style, menu);
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_runtime_style);
+
+ setupActionBar();
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+
+
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ //Store for later
+ mapboxMap = map;
+
+ //Center and Zoom (Amsterdam, zoomed to streets)
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_runtime_style, menu);
+ return true;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ case R.id.action_water_color:
+ setWaterColor();
+ return true;
+ case R.id.action_background_opacity:
+ setBackgroundOpacity();
+ return true;
+ case R.id.action_road_avoid_edges:
+ setRoadSymbolPlacement();
+ return true;
+ case R.id.action_layer_visibility:
+ setLayerInvisible();
+ return true;
+ case R.id.action_remove_layer:
+ removeBuildings();
+ return true;
+ case R.id.action_add_parks_layer:
+ addParksLayer();
+ return true;
+ case R.id.action_add_dynamic_parks_layer:
+ addDynamicParksLayer();
+ return true;
+ case R.id.action_add_terrain_layer:
+ addTerrainLayer();
+ return true;
+ case R.id.action_add_satellite_layer:
+ addSatelliteLayer();
+ return true;
+ case R.id.action_update_water_color_on_zoom:
+ updateWaterColorOnZoom();
return true;
+ case R.id.action_add_custom_tiles:
+ addCustomTileSource();
+ return true;
+ case R.id.action_fill_filter:
+ styleFillFilterLayer();
+ return true;
+ case R.id.action_line_filter:
+ styleLineFilterLayer();
+ return true;
+ case R.id.action_numeric_filter:
+ styleNumericFillLayer();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ }
+
+ private void setLayerInvisible() {
+ String[] roadLayers = new String[] {"water"};
+ for (String roadLayer : roadLayers) {
+ Layer layer = mapboxMap.getLayer(roadLayer);
+ if (layer != null) {
+ layer.setProperties(visibility(NONE));
+ }
}
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ }
+
+ private void setRoadSymbolPlacement() {
+ //Zoom so that the labels are visible first
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(14), new DefaultCallback() {
+ @Override
+ public void onFinish() {
+ String[] roadLayers = new String[] {"road-label-small", "road-label-medium", "road-label-large"};
+ for (String roadLayer : roadLayers) {
+ Layer layer = mapboxMap.getLayer(roadLayer);
+ if (layer != null) {
+ layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
+ }
+ }
+ }
+ });
+ }
+
+ private void setBackgroundOpacity() {
+ Layer background = mapboxMap.getLayer("background");
+ if (background != null) {
+ background.setProperties(backgroundOpacity(0.2f));
}
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
+ }
+
+ private void setWaterColor() {
+ Layer water = mapboxMap.getLayer("water");
+ if (water != null) {
+ water.setProperties(
+ visibility(VISIBLE),
+ fillColor(Color.RED)
+ );
+ } else {
+ Toast.makeText(RuntimeStyleActivity.this, "No water layer in this style", Toast.LENGTH_SHORT).show();
}
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ }
+
+ private void removeBuildings() {
+ //Zoom to see buildings first
+ try {
+ mapboxMap.removeLayer("building");
+ } catch (NoSuchLayerException noSuchLayerException) {
+ Toast.makeText(RuntimeStyleActivity.this, noSuchLayerException.getMessage(), Toast.LENGTH_SHORT).show();
}
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ }
+
+ private void addParksLayer() {
+ //Add a source
+ Source source;
+ try {
+ source = new GeoJsonSource("amsterdam-spots", readRawResource(R.raw.amsterdam));
+ } catch (IOException ioException) {
+ Toast.makeText(
+ RuntimeStyleActivity.this,
+ "Couldn't add source: " + ioException.getMessage(),
+ Toast.LENGTH_SHORT).show();
+ return;
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ mapboxMap.addSource(source);
+
+ FillLayer layer = new FillLayer("parksLayer", "amsterdam-spots");
+ layer.setProperties(
+ fillColor(Color.RED),
+ fillOutlineColor(Color.BLUE),
+ fillOpacity(0.3f),
+ fillAntialias(true)
+ );
+
+ //Only show me parks (except westerpark with stroke-width == 3)
+ layer.setFilter(all(eq("type", "park"), eq("stroke-width", 2)));
+
+ mapboxMap.addLayer(layer, "building");
+ //layer.setPaintProperty(fillColor(Color.RED)); //XXX But not after the object is attached
+
+ //Or get the object later and set it. It's all good.
+ mapboxMap.getLayer("parksLayer").setProperties(fillColor(Color.RED));
+
+ //You can get a typed layer, if you're sure it's of that type. Use with care
+ layer = mapboxMap.getLayerAs("parksLayer");
+ //And get some properties
+ PropertyValue<Boolean> fillAntialias = layer.getFillAntialias();
+ Timber.d("Fill anti alias: " + fillAntialias.getValue());
+ layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
+ PropertyValue<String> fillTranslateAnchor = layer.getFillTranslateAnchor();
+ Timber.d("Fill translate anchor: " + fillTranslateAnchor.getValue());
+ PropertyValue<String> visibility = layer.getVisibility();
+ Timber.d("Visibility: " + visibility.getValue());
+
+ //Get a good look at it all
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12));
+ }
+
+ private void addDynamicParksLayer() {
+ //Load some data
+ FeatureCollection parks;
+ try {
+ String json = readRawResource(R.raw.amsterdam);
+ parks = FeatureCollection.fromJson(json);
+ } catch (IOException ioException) {
+ Toast.makeText(
+ RuntimeStyleActivity.this,
+ "Couldn't add source: " + ioException.getMessage(),
+ Toast.LENGTH_SHORT
+ ).show();
+ return;
}
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ //Add an empty source
+ mapboxMap.addSource(new GeoJsonSource("dynamic-park-source"));
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- case R.id.action_water_color:
- setWaterColor();
- return true;
- case R.id.action_background_opacity:
- setBackgroundOpacity();
- return true;
- case R.id.action_road_avoid_edges:
- setRoadSymbolPlacement();
- return true;
- case R.id.action_layer_visibility:
- setLayerInvisible();
- return true;
- case R.id.action_remove_layer:
- removeBuildings();
- return true;
- case R.id.action_add_parks_layer:
- addParksLayer();
- return true;
- case R.id.action_add_dynamic_parks_layer:
- addDynamicParksLayer();
- return true;
- case R.id.action_add_terrain_layer:
- addTerrainLayer();
- return true;
- case R.id.action_add_satellite_layer:
- addSatelliteLayer();
- return true;
- case R.id.action_update_water_color_on_zoom:
- updateWaterColorOnZoom();
- return true;
- case R.id.action_add_custom_tiles:
- addCustomTileSource();
- return true;
- case R.id.action_fill_filter:
- styleFillFilterLayer();
- return true;
- case R.id.action_line_filter:
- styleLineFilterLayer();
- return true;
- case R.id.action_numeric_filter:
- styleNumericFillLayer();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ FillLayer layer = new FillLayer("dynamic-parks-layer", "dynamic-park-source");
+ layer.setProperties(
+ fillColor(Color.GREEN),
+ fillOutlineColor(Color.GREEN),
+ fillOpacity(0.8f),
+ fillAntialias(true)
+ );
- private void setLayerInvisible() {
- String[] roadLayers = new String[]{"water"};
- for (String roadLayer : roadLayers) {
- Layer layer = mapboxMap.getLayer(roadLayer);
- if (layer != null) {
- layer.setProperties(visibility(NONE));
- }
- }
- }
+ //Only show me parks
+ layer.setFilter(all(eq("type", "park")));
- private void setRoadSymbolPlacement() {
- //Zoom so that the labels are visible first
- mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(14), new DefaultCallback() {
- @Override
- public void onFinish() {
- String[] roadLayers = new String[]{"road-label-small", "road-label-medium", "road-label-large"};
- for (String roadLayer : roadLayers) {
- Layer layer = mapboxMap.getLayer(roadLayer);
- if (layer != null) {
- layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
- }
- }
- }
- });
- }
+ mapboxMap.addLayer(layer);
- private void setBackgroundOpacity() {
- Layer background = mapboxMap.getLayer("background");
- if (background != null) {
- background.setProperties(backgroundOpacity(0.2f));
- }
- }
+ //Get a good look at it all
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12));
- private void setWaterColor() {
- Layer water = mapboxMap.getLayer("water");
- if (water != null) {
- water.setProperties(
- visibility(VISIBLE),
- fillColor(Color.RED)
- );
- } else {
- Toast.makeText(RuntimeStyleActivity.this, "No water layer in this style", Toast.LENGTH_SHORT).show();
- }
- }
+ //Animate the parks source
+ animateParksSource(parks, 0);
+ }
- private void removeBuildings() {
- //Zoom to see buildings first
- try {
- mapboxMap.removeLayer("building");
- } catch (NoSuchLayerException noSuchLayerException) {
- Toast.makeText(RuntimeStyleActivity.this, noSuchLayerException.getMessage(), Toast.LENGTH_SHORT).show();
+ private void animateParksSource(final FeatureCollection parks, final int counter) {
+ Handler handler = new Handler(getMainLooper());
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (mapboxMap == null) {
+ return;
}
- }
- private void addParksLayer() {
- //Add a source
- Source source;
- try {
- source = new GeoJsonSource("amsterdam-spots", readRawResource(R.raw.amsterdam));
- } catch (IOException ioException) {
- Toast.makeText(
- RuntimeStyleActivity.this,
- "Couldn't add source: " + ioException.getMessage(),
- Toast.LENGTH_SHORT).show();
- return;
- }
+ Timber.d("Updating parks source");
+ //change the source
+ int park = counter < parks.getFeatures().size() - 1 ? counter : 0;
- mapboxMap.addSource(source);
-
- FillLayer layer = new FillLayer("parksLayer", "amsterdam-spots");
- layer.setProperties(
- fillColor(Color.RED),
- fillOutlineColor(Color.BLUE),
- fillOpacity(0.3f),
- fillAntialias(true)
- );
-
- //Only show me parks (except westerpark with stroke-width == 3)
- layer.setFilter(all(eq("type", "park"), eq("stroke-width", 2)));
-
- mapboxMap.addLayer(layer, "building");
- //layer.setPaintProperty(fillColor(Color.RED)); //XXX But not after the object is attached
-
- //Or get the object later and set it. It's all good.
- mapboxMap.getLayer("parksLayer").setProperties(fillColor(Color.RED));
-
- //You can get a typed layer, if you're sure it's of that type. Use with care
- layer = mapboxMap.getLayerAs("parksLayer");
- //And get some properties
- PropertyValue<Boolean> fillAntialias = layer.getFillAntialias();
- Timber.d("Fill anti alias: " + fillAntialias.getValue());
- layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
- PropertyValue<String> fillTranslateAnchor = layer.getFillTranslateAnchor();
- Timber.d("Fill translate anchor: " + fillTranslateAnchor.getValue());
- PropertyValue<String> visibility = layer.getVisibility();
- Timber.d("Visibility: " + visibility.getValue());
-
- //Get a good look at it all
- mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12));
- }
+ GeoJsonSource source = mapboxMap.getSourceAs("dynamic-park-source");
- private void addDynamicParksLayer() {
- //Load some data
- FeatureCollection parks;
- try {
- String json = readRawResource(R.raw.amsterdam);
- parks = FeatureCollection.fromJson(json);
- } catch (IOException e) {
- Toast.makeText(RuntimeStyleActivity.this, "Couldn't add source: " + e.getMessage(), Toast.LENGTH_SHORT).show();
- return;
+ if (source == null) {
+ Timber.e("Source not found");
+ Toast.makeText(RuntimeStyleActivity.this, "Source not found", Toast.LENGTH_SHORT).show();
+ return;
}
- //Add an empty source
- mapboxMap.addSource(new GeoJsonSource("dynamic-park-source"));
-
- FillLayer layer = new FillLayer("dynamic-parks-layer", "dynamic-park-source");
- layer.setProperties(
- fillColor(Color.GREEN),
- fillOutlineColor(Color.GREEN),
- fillOpacity(0.8f),
- fillAntialias(true)
- );
-
- //Only show me parks
- layer.setFilter(all(eq("type", "park")));
-
- mapboxMap.addLayer(layer);
-
- //Get a good look at it all
- mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12));
-
- //Animate the parks source
- animateParksSource(parks, 0);
+ List<Feature> features = new ArrayList<>();
+ features.add(parks.getFeatures().get(park));
+ source.setGeoJson(FeatureCollection.fromFeatures(features));
+
+ //Re-post
+ animateParksSource(parks, park + 1);
+ }
+ }, counter == 0 ? 100 : 1000);
+ }
+
+ private void addTerrainLayer() {
+ //Add a source
+ Source source = new VectorSource("my-terrain-source", "mapbox://mapbox.mapbox-terrain-v2");
+ mapboxMap.addSource(source);
+
+ LineLayer layer = new LineLayer("terrainLayer", "my-terrain-source");
+ layer.setSourceLayer("contour");
+ layer.setProperties(
+ lineJoin(Property.LINE_JOIN_ROUND),
+ lineCap(Property.LINE_CAP_ROUND),
+ lineColor(Color.RED),
+ lineWidth(20f)
+ );
+
+ mapboxMap.addLayer(layer);
+
+ //Need to get a fresh handle
+ layer = mapboxMap.getLayerAs("terrainLayer");
+
+ //Make sure it's also applied after the fact
+ layer.setMinZoom(10);
+ layer.setMaxZoom(15);
+
+ layer = (LineLayer) mapboxMap.getLayer("terrainLayer");
+ Toast.makeText(this, String.format(
+ "Set min/max zoom to %s - %s", layer.getMinZoom(), layer.getMaxZoom()), Toast.LENGTH_SHORT).show();
+ }
+
+ private void addSatelliteLayer() {
+ //Add a source
+ Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite", 512);
+ mapboxMap.addSource(source);
+
+ //Add a layer
+ mapboxMap.addLayer(new RasterLayer("satellite-layer", "my-raster-source"));
+ }
+
+ private void updateWaterColorOnZoom() {
+ FillLayer layer = mapboxMap.getLayerAs("water");
+ if (layer == null) {
+ return;
}
- private void animateParksSource(final FeatureCollection parks, final int counter) {
- Handler handler = new Handler(getMainLooper());
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (mapboxMap == null) {
- return;
- }
-
- Timber.d("Updating parks source");
- //change the source
- int park = counter < parks.getFeatures().size() - 1 ? counter : 0;
-
- GeoJsonSource source = mapboxMap.getSourceAs("dynamic-park-source");
-
- if (source == null) {
- Timber.e("Source not found");
- Toast.makeText(RuntimeStyleActivity.this, "Source not found", Toast.LENGTH_SHORT).show();
- return;
- }
-
- List<Feature> features = new ArrayList<>();
- features.add(parks.getFeatures().get(park));
- source.setGeoJson(FeatureCollection.fromFeatures(features));
-
- //Re-post
- animateParksSource(parks, park + 1);
- }
- }, counter == 0 ? 100 : 1000);
+ //Set a zoom function to update the color of the water
+ layer.setProperties(fillColor(zoom(0.8f,
+ stop(1, fillColor(Color.GREEN)),
+ stop(4, fillColor(Color.BLUE)),
+ stop(12, fillColor(Color.RED)),
+ stop(20, fillColor(Color.BLACK))
+ )));
+
+ //do some animations to show it off properly
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1), 1500);
+
+ PropertyValue<String> fillColor = layer.getFillColor();
+ Function<String> function = fillColor.getFunction();
+ if (function != null) {
+ Timber.d("Fill color base: " + function.getBase());
+ Timber.d("Fill color #stops: " + function.getStops().length);
+ if (function.getStops() != null) {
+ for (Stop stop : function.getStops()) {
+ Timber.d("Fill color #stops: " + stop);
+ }
+ }
+ }
+ }
+
+ private String readRawResource(@RawRes int rawResource) throws IOException {
+ InputStream is = getResources().openRawResource(rawResource);
+ Writer writer = new StringWriter();
+ char[] buffer = new char[1024];
+ try {
+ Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ int numRead;
+ while ((numRead = reader.read(buffer)) != -1) {
+ writer.write(buffer, 0, numRead);
+ }
+ } finally {
+ is.close();
}
- private void addTerrainLayer() {
- //Add a source
- Source source = new VectorSource("my-terrain-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source);
-
- LineLayer layer = new LineLayer("terrainLayer", "my-terrain-source");
- layer.setSourceLayer("contour");
- layer.setProperties(
- lineJoin(Property.LINE_JOIN_ROUND),
- lineCap(Property.LINE_CAP_ROUND),
- lineColor(Color.RED),
- lineWidth(20f)
- );
-
- mapboxMap.addLayer(layer);
-
- //Need to get a fresh handle
- layer = mapboxMap.getLayerAs("terrainLayer");
+ return writer.toString();
+ }
- //Make sure it's also applied after the fact
- layer.setMinZoom(10);
- layer.setMaxZoom(15);
+ private void setupActionBar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- layer = (LineLayer) mapboxMap.getLayer("terrainLayer");
- Toast.makeText(this, String.format(
- "Set min/max zoom to %s - %s", layer.getMinZoom(), layer.getMaxZoom()), Toast.LENGTH_SHORT).show();
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
+ }
+
+ private void addCustomTileSource() {
+ //Add a source
+ Source source = new VectorSource("custom-tile-source", new TileSet("2.1.0", "https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt?api_key=vector-tiles-LM25tq4"));
+ mapboxMap.addSource(source);
+
+ //Add a layer
+ mapboxMap.addLayer(
+ new FillLayer("custom-tile-layers", "custom-tile-source")
+ .withSourceLayer("water")
+ );
+ }
+
+ private void styleFillFilterLayer() {
+ mapboxMap.setStyleUrl("asset://fill_filter_style.json");
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(31, -100), 3));
+
+ Handler handler = new Handler(getMainLooper());
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (mapboxMap == null) {
+ return;
+ }
- private void addSatelliteLayer() {
- //Add a source
- Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite", 512);
- mapboxMap.addSource(source);
+ Timber.d("Styling filtered fill layer");
- //Add a layer
- mapboxMap.addLayer(new RasterLayer("satellite-layer", "my-raster-source"));
- }
+ FillLayer states = (FillLayer) mapboxMap.getLayer("states");
- private void updateWaterColorOnZoom() {
- FillLayer layer = mapboxMap.getLayerAs("water");
- if (layer == null) {
- return;
- }
+ if (states != null) {
+ states.setFilter(eq("name", "Texas"));
- //Set a zoom function to update the color of the water
- layer.setProperties(fillColor(zoom(0.8f,
- stop(1, fillColor(Color.GREEN)),
- stop(4, fillColor(Color.BLUE)),
- stop(12, fillColor(Color.RED)),
- stop(20, fillColor(Color.BLACK))
- )));
-
- //do some animations to show it off properly
- mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1), 1500);
-
- PropertyValue<String> fillColor = layer.getFillColor();
- Function<String> function = fillColor.getFunction();
- if (function != null) {
- Timber.d("Fill color base: " + function.getBase());
- Timber.d("Fill color #stops: " + function.getStops().length);
- if (function.getStops() != null) {
- for (Stop stop : function.getStops()) {
- Timber.d("Fill color #stops: " + stop);
- }
- }
+ states.setProperties(
+ fillColor(Color.RED),
+ fillOpacity(0.25f)
+ );
+ } else {
+ Toast.makeText(RuntimeStyleActivity.this, "No states layer in this style", Toast.LENGTH_SHORT).show();
}
- }
-
- private String readRawResource(@RawRes int rawResource) throws IOException {
- InputStream is = getResources().openRawResource(rawResource);
- Writer writer = new StringWriter();
- char[] buffer = new char[1024];
- try {
- Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- int n;
- while ((n = reader.read(buffer)) != -1) {
- writer.write(buffer, 0, n);
- }
- } finally {
- is.close();
+ }
+ }, 2000);
+ }
+
+ private void styleLineFilterLayer() {
+ mapboxMap.setStyleUrl("asset://line_filter_style.json");
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -97), 5));
+
+ Handler handler = new Handler(getMainLooper());
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (mapboxMap == null) {
+ return;
}
- return writer.toString();
- }
+ Timber.d("Styling filtered line layer");
- private void setupActionBar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
- }
+ if (counties != null) {
+ counties.setFilter(eq("NAME10", "Washington"));
- private void addCustomTileSource() {
- //Add a source
- Source source = new VectorSource("custom-tile-source", new TileSet("2.1.0", "https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt?api_key=vector-tiles-LM25tq4"));
- mapboxMap.addSource(source);
+ counties.setProperties(
+ lineColor(Color.RED),
+ lineOpacity(0.75f),
+ lineWidth(5f)
+ );
+ } else {
+ Toast.makeText(RuntimeStyleActivity.this, "No counties layer in this style", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }, 2000);
+ }
+
+ private void styleNumericFillLayer() {
+ mapboxMap.setStyleUrl("asset://numeric_filter_style.json");
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -97), 5));
+
+ Handler handler = new Handler(getMainLooper());
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (mapboxMap == null) {
+ return;
+ }
- //Add a layer
- mapboxMap.addLayer(
- new FillLayer("custom-tile-layers", "custom-tile-source")
- .withSourceLayer("water")
- );
- }
+ Timber.d("Styling numeric fill layer");
- private void styleFillFilterLayer() {
- mapboxMap.setStyleUrl("asset://fill_filter_style.json");
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(31, -100), 3));
-
- Handler handler = new Handler(getMainLooper());
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (mapboxMap == null) {
- return;
- }
-
- Timber.d("Styling filtered fill layer");
-
- FillLayer states = (FillLayer) mapboxMap.getLayer("states");
-
- if (states != null) {
- states.setFilter(eq("name", "Texas"));
-
- states.setProperties(
- fillColor(Color.RED),
- fillOpacity(0.25f)
- );
- } else {
- Toast.makeText(RuntimeStyleActivity.this, "No states layer in this style", Toast.LENGTH_SHORT).show();
- }
- }
- }, 2000);
- }
+ FillLayer regions = (FillLayer) mapboxMap.getLayer("regions");
- private void styleLineFilterLayer() {
- mapboxMap.setStyleUrl("asset://line_filter_style.json");
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -97), 5));
-
- Handler handler = new Handler(getMainLooper());
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (mapboxMap == null) {
- return;
- }
-
- Timber.d("Styling filtered line layer");
-
- LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
-
- if (counties != null) {
- counties.setFilter(eq("NAME10", "Washington"));
-
- counties.setProperties(
- lineColor(Color.RED),
- lineOpacity(0.75f),
- lineWidth(5f)
- );
- } else {
- Toast.makeText(RuntimeStyleActivity.this, "No counties layer in this style", Toast.LENGTH_SHORT).show();
- }
- }
- }, 2000);
- }
+ if (regions != null) {
+ regions.setFilter(all(gte("HRRNUM", 200), lt("HRRNUM", 300)));
- private void styleNumericFillLayer() {
- mapboxMap.setStyleUrl("asset://numeric_filter_style.json");
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -97), 5));
-
- Handler handler = new Handler(getMainLooper());
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (mapboxMap == null) {
- return;
- }
-
- Timber.d("Styling numeric fill layer");
-
- FillLayer regions = (FillLayer) mapboxMap.getLayer("regions");
-
- if (regions != null) {
- regions.setFilter(all(gte("HRRNUM", 200), lt("HRRNUM", 300)));
-
- regions.setProperties(
- fillColor(Color.BLUE),
- fillOpacity(0.5f)
- );
- } else {
- Toast.makeText(RuntimeStyleActivity.this, "No regions layer in this style", Toast.LENGTH_SHORT).show();
- }
- }
- }, 2000);
- }
+ regions.setProperties(
+ fillColor(Color.BLUE),
+ fillOpacity(0.5f)
+ );
+ } else {
+ Toast.makeText(RuntimeStyleActivity.this, "No regions layer in this style", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }, 2000);
+ }
- private static class DefaultCallback implements MapboxMap.CancelableCallback {
+ private static class DefaultCallback implements MapboxMap.CancelableCallback {
- @Override
- public void onCancel() {
- //noop
- }
+ @Override
+ public void onCancel() {
+ //noop
+ }
- @Override
- public void onFinish() {
- //noop
- }
+ @Override
+ public void onFinish() {
+ //noop
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java
index 841bf12ed8..1d242359bc 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java
@@ -13,68 +13,68 @@ import com.mapbox.mapboxsdk.testapp.R;
*/
public class RuntimeStyleTestActivity extends AppCompatActivity {
- public MapView mapView;
- private MapboxMap mapboxMap;
+ public MapView mapView;
+ private MapboxMap mapboxMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_runtime_style);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_runtime_style);
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- RuntimeStyleTestActivity.this.mapboxMap = mapboxMap;
- }
- });
- }
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ RuntimeStyleTestActivity.this.mapboxMap = mapboxMap;
+ }
+ });
+ }
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ }
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ @Override
+ protected void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mapView.onStop();
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
index b633698cc1..c57bc0069a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
@@ -21,80 +21,80 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
*/
public class RuntimeStyleTimingTestActivity extends AppCompatActivity {
- public MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_runtime_style);
-
- //Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
- VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
- mapboxMap.addSource(museums);
-
- CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
- museumsLayer.setSourceLayer("museum-cusco");
- museumsLayer.setProperties(
- visibility(VISIBLE),
- circleRadius(8f),
- circleColor(Color.argb(1, 55, 148, 179))
- );
-
- mapboxMap.addLayer(museumsLayer);
- }
- });
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ public MapView mapView;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_runtime_style);
+
+ //Initialize map as normal
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
+ VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
+ mapboxMap.addSource(museums);
+
+ CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
+ museumsLayer.setSourceLayer("museum-cusco");
+ museumsLayer.setProperties(
+ visibility(VISIBLE),
+ circleRadius(8f),
+ circleColor(Color.argb(1, 55, 148, 179))
+ );
+
+ mapboxMap.addLayer(museumsLayer);
+ }
+ });
+ }
+
+ public MapboxMap getMapboxMap() {
+ return mapboxMap;
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java
index 2634401407..73e6bc985a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java
@@ -9,7 +9,6 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
-import timber.log.Timber;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
@@ -30,8 +29,7 @@ import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
+import timber.log.Timber;
/**
* Example on how to use a file:// resource for the style.json
@@ -88,10 +86,10 @@ public class StyleFileActivity extends AppCompatActivity {
cacheStyleFile.createNewFile();
Timber.i("Writing style file to: " + cacheStyleFile.getAbsolutePath());
writeToFile(cacheStyleFile, readRawResource(R.raw.local_style));
- } catch (Exception e) {
+ } catch (Exception exception) {
Toast.makeText(StyleFileActivity.this, "Could not create style file in cache dir", Toast.LENGTH_SHORT).show();
}
- return 1l;
+ return 1L;
}
protected void onPostExecute(Long result) {
@@ -105,9 +103,9 @@ public class StyleFileActivity extends AppCompatActivity {
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- int n;
- while ((n = reader.read(buffer)) != -1) {
- writer.write(buffer, 0, n);
+ int numRead;
+ while ((numRead = reader.read(buffer)) != -1) {
+ writer.write(buffer, 0, numRead);
}
} finally {
is.close();
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
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
index 4a9e472cc8..e20455b1ce 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
@@ -29,154 +29,154 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MyLocationDrawableActivity extends AppCompatActivity implements LocationListener {
- private static final int PERMISSIONS_LOCATION = 0;
-
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_customization);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- findViewById(R.id.progress).setVisibility(View.GONE);
-
- MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
- mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
-
- // configure MyLocationView drawables
- mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_chelsea));
- mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arsenal));
- mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN);
- mapboxMapOptions.myLocationBackgroundTintColor(Color.YELLOW);
- mapboxMapOptions.myLocationBackgroundPadding(new int[]{0, 0,
- (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding),
- (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)});
-
- mapboxMapOptions.myLocationAccuracyTint(Color.RED);
- mapboxMapOptions.myLocationAccuracyAlpha(155);
-
- mapView = new MapView(this, mapboxMapOptions);
- mapView.setId(R.id.mapView);
- ViewGroup parent = (ViewGroup) findViewById(R.id.container);
- parent.addView(mapView);
-
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- toggleGps(true);
- }
- });
+ private static final int PERMISSIONS_LOCATION = 0;
+
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_my_location_customization);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- public void toggleGps(boolean enableGps) {
- if (enableGps) {
- if ((ContextCompat.checkSelfPermission(this,
- Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
- != PackageManager.PERMISSION_GRANTED)) {
- ActivityCompat.requestPermissions(this, new String[]{
- Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
- } else {
- enableLocation(true);
- }
- } else {
- enableLocation(false);
- }
+ findViewById(R.id.progress).setVisibility(View.GONE);
+
+ MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
+ mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
+
+ // configure MyLocationView drawables
+ mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_chelsea));
+ mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arsenal));
+ mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN);
+ mapboxMapOptions.myLocationBackgroundTintColor(Color.YELLOW);
+ mapboxMapOptions.myLocationBackgroundPadding(new int[] {0, 0,
+ (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding),
+ (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)});
+
+ mapboxMapOptions.myLocationAccuracyTint(Color.RED);
+ mapboxMapOptions.myLocationAccuracyAlpha(155);
+
+ mapView = new MapView(this, mapboxMapOptions);
+ mapView.setId(R.id.mapView);
+ ViewGroup parent = (ViewGroup) findViewById(R.id.container);
+ parent.addView(mapView);
+
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ toggleGps(true);
+ }
+ });
+ }
+
+ public void toggleGps(boolean enableGps) {
+ if (enableGps) {
+ if ((ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(this, new String[] {
+ Manifest.permission.ACCESS_COARSE_LOCATION,
+ Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
+ } else {
+ enableLocation(true);
+ }
+ } else {
+ enableLocation(false);
}
-
- private void enableLocation(boolean enabled) {
- if (enabled) {
- mapboxMap.setMyLocationEnabled(true);
- Location location = mapboxMap.getMyLocation();
- if (location != null) {
- onLocationChanged(location);
- } else {
- LocationServices.getLocationServices(this).addLocationListener(this);
- }
- } else {
- mapboxMap.setMyLocationEnabled(false);
- }
+ }
+
+ private void enableLocation(boolean enabled) {
+ if (enabled) {
+ mapboxMap.setMyLocationEnabled(true);
+ Location location = mapboxMap.getMyLocation();
+ if (location != null) {
+ onLocationChanged(location);
+ } else {
+ LocationServices.getLocationServices(this).addLocationListener(this);
+ }
+ } else {
+ mapboxMap.setMyLocationEnabled(false);
}
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (requestCode == PERMISSIONS_LOCATION) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- enableLocation(true);
- }
- }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == PERMISSIONS_LOCATION) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ enableLocation(true);
+ }
}
+ }
- @Override
- public void onLocationChanged(Location location) {
- if (mapboxMap != null) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14));
- }
+ @Override
+ public void onLocationChanged(Location location) {
+ if (mapboxMap != null) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14));
}
-
- @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
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
index d40747918a..2da3bedcbf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
@@ -32,217 +32,217 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MyLocationTintActivity extends AppCompatActivity implements LocationListener {
- private MapView mapView;
- private MapboxMap mapboxMap;
- private boolean firstRun;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private boolean firstRun;
- private static final int PERMISSIONS_LOCATION = 0;
+ private static final int PERMISSIONS_LOCATION = 0;
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_dot_color);
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_my_location_dot_color);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
+ 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() {
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+
+ // enable location updates
+ toggleGps(!mapboxMap.isMyLocationEnabled());
+
+ // add some padding
+ final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
+ myLocationViewSettings.setPadding(0, 500, 0, 0);
+
+ // enable tracking
+ TrackingSettings settings = mapboxMap.getTrackingSettings();
+ settings.setDismissLocationTrackingOnGesture(false);
+ settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+
+ // handle default button clicks
+ ViewUtils.attachClickListener(
+ MyLocationTintActivity.this,
+ R.id.default_user_dot_coloring_button,
+ new View.OnClickListener() {
@Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
-
- // enable location updates
- toggleGps(!mapboxMap.isMyLocationEnabled());
-
- // add some padding
- final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
- myLocationViewSettings.setPadding(0, 500, 0, 0);
-
- // enable tracking
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setDismissLocationTrackingOnGesture(false);
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
-
- // handle default button clicks
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.default_user_dot_coloring_button,
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor(
- MyLocationTintActivity.this, R.color.mapbox_my_location_ring));
- myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
- MyLocationTintActivity.this, R.color.mapbox_blue));
- myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
- }
- });
-
- // handle tint user dot button clicks
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.tint_user_dot_button,
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- myLocationViewSettings.setAccuracyTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green));
- myLocationViewSettings.setForegroundTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green));
- myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
- }
- });
-
- // handle tint accuracy ring button clicks
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.user_accuracy_ring_tint_button,
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- myLocationViewSettings.setAccuracyTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
- myLocationViewSettings.setForegroundTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
- myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
- }
- });
-
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.user_dot_transparent_button,
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
- myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
- }
- }
- );
+ public void onClick(View view) {
+ myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor(
+ MyLocationTintActivity.this, R.color.mapbox_blue));
+ myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
+ MyLocationTintActivity.this, R.color.mapbox_blue));
+ myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
}
- });
-
- }
-
- @Override
- public void onLocationChanged(Location location) {
- if (mapboxMap != null && firstRun) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
- firstRun = false;
- }
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- LocationServices.getLocationServices(this).addLocationListener(this);
- }
+ });
- @Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- LocationServices.getLocationServices(this).removeLocationListener(this);
- mapView.onStop();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
+ // handle tint user dot button clicks
+ ViewUtils.attachClickListener(
+ MyLocationTintActivity.this,
+ R.id.tint_user_dot_button,
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ myLocationViewSettings.setAccuracyTintColor(
+ ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green));
+ myLocationViewSettings.setForegroundTintColor(
+ ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green));
+ myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
+ }
+ });
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ // handle tint accuracy ring button clicks
+ ViewUtils.attachClickListener(
+ MyLocationTintActivity.this,
+ R.id.user_accuracy_ring_tint_button,
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ myLocationViewSettings.setAccuracyTintColor(
+ ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
+ myLocationViewSettings.setForegroundTintColor(
+ ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
+ myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
+ }
+ });
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ ViewUtils.attachClickListener(
+ MyLocationTintActivity.this,
+ R.id.user_dot_transparent_button,
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
+ myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
+ }
+ }
+ );
+ }
+ });
+
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (mapboxMap != null && firstRun) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
+ firstRun = false;
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mapView.onStart();
+ LocationServices.getLocationServices(this).addLocationListener(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mapView.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ LocationServices.getLocationServices(this).removeLocationListener(this);
+ mapView.onStop();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- @UiThread
- public void toggleGps(boolean enableGps) {
- if (enableGps) {
- if ((ContextCompat.checkSelfPermission(this,
- Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
- != PackageManager.PERMISSION_GRANTED)) {
- ActivityCompat.requestPermissions(this, new String[]{
- Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
- } else {
- enableLocation(true);
- }
- } else {
- enableLocation(false);
- }
+ }
+
+ @UiThread
+ public void toggleGps(boolean enableGps) {
+ if (enableGps) {
+ if ((ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(this, new String[] {
+ Manifest.permission.ACCESS_COARSE_LOCATION,
+ Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
+ } else {
+ enableLocation(true);
+ }
+ } else {
+ enableLocation(false);
}
-
- private void enableLocation(boolean enabled) {
- if (enabled) {
- mapboxMap.setMyLocationEnabled(true);
- if (mapboxMap.getMyLocation() != null) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
- new LatLng(mapboxMap.getMyLocation().getLatitude(),
- mapboxMap.getMyLocation().getLongitude()), 15));
- }
- } else {
- mapboxMap.setMyLocationEnabled(false);
- }
+ }
+
+ private void enableLocation(boolean enabled) {
+ if (enabled) {
+ mapboxMap.setMyLocationEnabled(true);
+ if (mapboxMap.getMyLocation() != null) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
+ new LatLng(mapboxMap.getMyLocation().getLatitude(),
+ mapboxMap.getMyLocation().getLongitude()), 15));
+ }
+ } else {
+ mapboxMap.setMyLocationEnabled(false);
}
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (requestCode == PERMISSIONS_LOCATION) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- enableLocation(true);
- }
- }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == PERMISSIONS_LOCATION) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ enableLocation(true);
+ }
}
+ }
- private static class ViewUtils {
+ private static class ViewUtils {
- public static void attachClickListener(
- @NonNull Activity activity, @IdRes int buttonId, @Nullable View.OnClickListener clickListener) {
- View view = activity.findViewById(buttonId);
- if (view != null) {
- view.setOnClickListener(clickListener);
- }
- }
+ public static void attachClickListener(
+ @NonNull Activity activity, @IdRes int buttonId, @Nullable View.OnClickListener clickListener) {
+ View view = activity.findViewById(buttonId);
+ if (view != null) {
+ view.setOnClickListener(clickListener);
+ }
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
index 1c8f739bdd..e522840038 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
@@ -15,6 +15,7 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
+
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
@@ -24,150 +25,150 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MyLocationToggleActivity extends AppCompatActivity {
- private MapView mapView;
- private MapboxMap mapboxMap;
- private FloatingActionButton locationToggleFab;
-
- private static final int PERMISSIONS_LOCATION = 0;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_toggle);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap map) {
- mapboxMap = map;
- }
- });
-
- locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
- locationToggleFab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mapboxMap != null) {
- toggleGps(!mapboxMap.isMyLocationEnabled());
- }
- }
- });
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private FloatingActionButton locationToggleFab;
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
+ private static final int PERMISSIONS_LOCATION = 0;
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_my_location_toggle);
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayShowTitleEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- default:
- return false;
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ }
+ });
+
+ locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
+ locationToggleFab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mapboxMap != null) {
+ toggleGps(!mapboxMap.isMyLocationEnabled());
}
+ }
+ });
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ default:
+ return false;
}
-
- @UiThread
- public void toggleGps(boolean enableGps) {
- if (enableGps) {
- if ((ContextCompat.checkSelfPermission(this,
- Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
- != PackageManager.PERMISSION_GRANTED)) {
- ActivityCompat.requestPermissions(this, new String[]{
- Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
- } else {
- enableLocation(true);
- }
- } else {
- enableLocation(false);
- }
+ }
+
+ @UiThread
+ public void toggleGps(boolean enableGps) {
+ if (enableGps) {
+ if ((ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(this, new String[] {
+ Manifest.permission.ACCESS_COARSE_LOCATION,
+ Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
+ } else {
+ enableLocation(true);
+ }
+ } else {
+ enableLocation(false);
}
-
- private void enableLocation(boolean enabled) {
- if (enabled) {
- mapboxMap.setOnMyLocationChangeListener(new MapboxMap.OnMyLocationChangeListener() {
- @Override
- public void onMyLocationChange(@Nullable Location location) {
- if (location != null) {
- mapboxMap.setCameraPosition(new CameraPosition.Builder()
- .target(new LatLng(location))
- .zoom(16)
- .bearing(0)
- .tilt(0)
- .build());
- mapboxMap.setOnMyLocationChangeListener(null);
- }
- }
- });
- locationToggleFab.setImageResource(R.drawable.ic_location_disabled_24dp);
- } else {
- locationToggleFab.setImageResource(R.drawable.ic_my_location_24dp);
+ }
+
+ private void enableLocation(boolean enabled) {
+ if (enabled) {
+ mapboxMap.setOnMyLocationChangeListener(new MapboxMap.OnMyLocationChangeListener() {
+ @Override
+ public void onMyLocationChange(@Nullable Location location) {
+ if (location != null) {
+ mapboxMap.setCameraPosition(new CameraPosition.Builder()
+ .target(new LatLng(location))
+ .zoom(16)
+ .bearing(0)
+ .tilt(0)
+ .build());
+ mapboxMap.setOnMyLocationChangeListener(null);
+ }
}
-
- mapboxMap.setMyLocationEnabled(enabled);
+ });
+ locationToggleFab.setImageResource(R.drawable.ic_location_disabled_24dp);
+ } else {
+ locationToggleFab.setImageResource(R.drawable.ic_my_location_24dp);
}
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (requestCode == PERMISSIONS_LOCATION) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- enableLocation(true);
- }
- }
+ mapboxMap.setMyLocationEnabled(enabled);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == PERMISSIONS_LOCATION) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ enableLocation(true);
+ }
}
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
index 50d2eb841a..3d08399abf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
@@ -34,320 +34,320 @@ import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
public class MyLocationTrackingModeActivity extends AppCompatActivity
- implements MapboxMap.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener {
-
- public static final int TRACKING_NONE_INDEX = 0;
- public static final int TRACKING_FOLLOW_INDEX = 1;
- public static final int BEARING_NONE_INDEX = 0;
- public static final int BEARING_GPS_INDEX = 1;
- public static final int BEARING_COMPASS_INDEX = 2;
- private MapView mapView;
- private MapboxMap mapboxMap;
- private Spinner locationSpinner;
- private Spinner bearingSpinner;
- private Location location;
- private static final int PERMISSIONS_LOCATION = 0;
- private MenuItem dismissLocationTrackingOnGestureItem;
- private MenuItem dismissBearingTrackingOnGestureItem;
- private MenuItem enableRotateGesturesItem;
- private MenuItem enableScrollGesturesItem;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_tracking);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayShowTitleEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
-
- locationSpinner = (Spinner) findViewById(R.id.spinner_location);
- ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource(
- actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item);
- locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- locationSpinner.setAdapter(locationTrackingAdapter);
-
- bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing);
- ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource(
- actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item);
- bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- bearingSpinner.setAdapter(bearingTrackingAdapter);
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
-
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap;
-
- locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- setCheckBoxes();
-
- mapboxMap.setOnMyLocationChangeListener(MyLocationTrackingModeActivity.this);
-
- mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() {
- @Override
- public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) {
- locationSpinner.setOnItemSelectedListener(null);
- switch (myLocationTrackingMode) {
- case MyLocationTracking.TRACKING_NONE:
- locationSpinner.setSelection(TRACKING_NONE_INDEX);
- break;
- case MyLocationTracking.TRACKING_FOLLOW:
- locationSpinner.setSelection(TRACKING_FOLLOW_INDEX);
- break;
- }
- locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- }
- });
-
- mapboxMap.setOnMyBearingTrackingModeChangeListener(new MapboxMap.OnMyBearingTrackingModeChangeListener() {
- @Override
- public void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode) {
- bearingSpinner.setOnItemSelectedListener(null);
- switch (myBearingTrackingMode) {
- case MyBearingTracking.NONE:
- bearingSpinner.setSelection(BEARING_NONE_INDEX);
- break;
-
- case MyBearingTracking.GPS:
- bearingSpinner.setSelection(BEARING_GPS_INDEX);
- break;
-
- case MyBearingTracking.COMPASS:
- bearingSpinner.setSelection(BEARING_COMPASS_INDEX);
- break;
- }
- bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- }
- });
-
- if (savedInstanceState == null) {
- toggleGps(true);
- }
- }
- });
+ implements MapboxMap.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener {
+
+ public static final int TRACKING_NONE_INDEX = 0;
+ public static final int TRACKING_FOLLOW_INDEX = 1;
+ public static final int BEARING_NONE_INDEX = 0;
+ public static final int BEARING_GPS_INDEX = 1;
+ public static final int BEARING_COMPASS_INDEX = 2;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private Spinner locationSpinner;
+ private Spinner bearingSpinner;
+ private Location location;
+ private static final int PERMISSIONS_LOCATION = 0;
+ private MenuItem dismissLocationTrackingOnGestureItem;
+ private MenuItem dismissBearingTrackingOnGestureItem;
+ private MenuItem enableRotateGesturesItem;
+ private MenuItem enableScrollGesturesItem;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_my_location_tracking);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
}
- @UiThread
- public void toggleGps(boolean enableGps) {
- if (enableGps) {
- if ((ContextCompat.checkSelfPermission(this,
- Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
- != PackageManager.PERMISSION_GRANTED)) {
- ActivityCompat.requestPermissions(this, new String[]{
- Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
- } else {
- enableLocation(true);
- }
- } else {
- enableLocation(false);
- }
- }
+ locationSpinner = (Spinner) findViewById(R.id.spinner_location);
+ ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource(
+ actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item);
+ locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ locationSpinner.setAdapter(locationTrackingAdapter);
- private void enableLocation(boolean enabled) {
- if (enabled) {
- mapboxMap.setMyLocationEnabled(true);
- Location location = mapboxMap.getMyLocation();
- if (location != null) {
- setInitialPosition(new LatLng(location));
- }
- } else {
- mapboxMap.setMyLocationEnabled(false);
- }
- }
+ bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing);
+ ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource(
+ actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item);
+ bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ bearingSpinner.setAdapter(bearingTrackingAdapter);
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (requestCode == PERMISSIONS_LOCATION) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- enableLocation(true);
- }
- }
- }
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
- private void setInitialPosition(LatLng latLng) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
- mapboxMap.setMyLocationEnabled(true);
- locationSpinner.setEnabled(true);
- bearingSpinner.setEnabled(true);
- }
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(@NonNull MapboxMap mapboxMap) {
+ MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap;
+
+ locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
+ bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
+ setCheckBoxes();
- @Override
- public void onMyLocationChange(@Nullable Location location) {
- if (location != null) {
- if (this.location == null) {
- // initial location to reposition map
- setInitialPosition(new LatLng(location));
+ mapboxMap.setOnMyLocationChangeListener(MyLocationTrackingModeActivity.this);
+
+ mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() {
+ @Override
+ public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) {
+ locationSpinner.setOnItemSelectedListener(null);
+ switch (myLocationTrackingMode) {
+ case MyLocationTracking.TRACKING_NONE:
+ locationSpinner.setSelection(TRACKING_NONE_INDEX);
+ break;
+ case MyLocationTracking.TRACKING_FOLLOW:
+ locationSpinner.setSelection(TRACKING_FOLLOW_INDEX);
+ break;
}
- this.location = location;
- showSnackBar();
- }
- }
+ locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
+ }
+ });
- private void showSnackBar() {
- String desc = "Loc Chg: ";
- boolean noInfo = true;
- if (location.hasSpeed()) {
- desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Spd = %.1f km/h ", location.getSpeed() * 3.6f);
- noInfo = false;
- }
- if (location.hasAltitude()) {
- desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Alt = %.0f m ", location.getAltitude());
- noInfo = false;
- }
- if (location.hasAccuracy()) {
- desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Acc = %.0f m", location.getAccuracy());
- }
+ mapboxMap.setOnMyBearingTrackingModeChangeListener(new MapboxMap.OnMyBearingTrackingModeChangeListener() {
+ @Override
+ public void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode) {
+ bearingSpinner.setOnItemSelectedListener(null);
+ switch (myBearingTrackingMode) {
+ case MyBearingTracking.NONE:
+ bearingSpinner.setSelection(BEARING_NONE_INDEX);
+ break;
+
+ case MyBearingTracking.GPS:
+ bearingSpinner.setSelection(BEARING_GPS_INDEX);
+ break;
+
+ case MyBearingTracking.COMPASS:
+ bearingSpinner.setSelection(BEARING_COMPASS_INDEX);
+ break;
+ }
+ bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
+ }
+ });
- if (noInfo) {
- desc += "No extra info";
+ if (savedInstanceState == null) {
+ toggleGps(true);
}
- Snackbar.make(findViewById(android.R.id.content), desc, Snackbar.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ @UiThread
+ public void toggleGps(boolean enableGps) {
+ if (enableGps) {
+ if ((ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(this, new String[] {
+ Manifest.permission.ACCESS_COARSE_LOCATION,
+ Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
+ } else {
+ enableLocation(true);
+ }
+ } else {
+ enableLocation(false);
}
-
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) throws SecurityException {
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- if (parent.getId() == R.id.spinner_location) {
- switch (position) {
- case TRACKING_NONE_INDEX:
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
- break;
-
- case TRACKING_FOLLOW_INDEX:
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- break;
- }
- } else if (parent.getId() == R.id.spinner_bearing) {
- switch (position) {
- case BEARING_NONE_INDEX:
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.NONE);
- break;
-
- case BEARING_GPS_INDEX:
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS);
- break;
-
- case BEARING_COMPASS_INDEX:
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.COMPASS);
- break;
- }
- }
+ }
+
+ private void enableLocation(boolean enabled) {
+ if (enabled) {
+ mapboxMap.setMyLocationEnabled(true);
+ Location location = mapboxMap.getMyLocation();
+ if (location != null) {
+ setInitialPosition(new LatLng(location));
+ }
+ } else {
+ mapboxMap.setMyLocationEnabled(false);
}
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
-
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == PERMISSIONS_LOCATION) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ enableLocation(true);
+ }
}
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
+ }
+
+ private void setInitialPosition(LatLng latLng) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
+ mapboxMap.setMyLocationEnabled(true);
+ locationSpinner.setEnabled(true);
+ bearingSpinner.setEnabled(true);
+ }
+
+ @Override
+ public void onMyLocationChange(@Nullable Location location) {
+ if (location != null) {
+ if (this.location == null) {
+ // initial location to reposition map
+ setInitialPosition(new LatLng(location));
+ }
+ this.location = location;
+ showSnackBar();
}
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
+ }
+
+ private void showSnackBar() {
+ String desc = "Loc Chg: ";
+ boolean noInfo = true;
+ if (location.hasSpeed()) {
+ desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Spd = %.1f km/h ", location.getSpeed() * 3.6f);
+ noInfo = false;
}
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
+ if (location.hasAltitude()) {
+ desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Alt = %.0f m ", location.getAltitude());
+ noInfo = false;
}
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
+ if (location.hasAccuracy()) {
+ desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Acc = %.0f m", location.getAccuracy());
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
+ if (noInfo) {
+ desc += "No extra info";
}
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
+ Snackbar.make(findViewById(android.R.id.content), desc, Snackbar.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) throws SecurityException {
+ TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
+ if (parent.getId() == R.id.spinner_location) {
+ switch (position) {
+ case TRACKING_NONE_INDEX:
+ trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
+ break;
+
+ case TRACKING_FOLLOW_INDEX:
+ trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+ break;
+ }
+ } else if (parent.getId() == R.id.spinner_bearing) {
+ switch (position) {
+ case BEARING_NONE_INDEX:
+ trackingSettings.setMyBearingTrackingMode(MyBearingTracking.NONE);
+ break;
+
+ case BEARING_GPS_INDEX:
+ trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS);
+ break;
+
+ case BEARING_COMPASS_INDEX:
+ trackingSettings.setMyBearingTrackingMode(MyBearingTracking.COMPASS);
+ break;
+ }
}
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+
+ }
+
+ @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
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mapView.onDestroy();
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ mapView.onLowMemory();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_tracking, menu);
+ dismissLocationTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_location);
+ dismissBearingTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_bearing);
+ enableRotateGesturesItem = menu.findItem(R.id.action_toggle_rotate_gesture_enabled);
+ enableScrollGesturesItem = menu.findItem(R.id.action_toggle_scroll_gesture_enabled);
+ setCheckBoxes();
+ return true;
+ }
+
+ private void setCheckBoxes() {
+ if (mapboxMap != null && dismissBearingTrackingOnGestureItem != null) {
+ TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
+ UiSettings uiSettings = mapboxMap.getUiSettings();
+ dismissBearingTrackingOnGestureItem.setChecked(trackingSettings.isDismissBearingTrackingOnGesture());
+ dismissLocationTrackingOnGestureItem.setChecked(trackingSettings.isDismissLocationTrackingOnGesture());
+ enableRotateGesturesItem.setChecked(uiSettings.isRotateGesturesEnabled());
+ enableScrollGesturesItem.setChecked(uiSettings.isScrollGesturesEnabled());
}
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_tracking, menu);
- dismissLocationTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_location);
- dismissBearingTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_bearing);
- enableRotateGesturesItem = menu.findItem(R.id.action_toggle_rotate_gesture_enabled);
- enableScrollGesturesItem = menu.findItem(R.id.action_toggle_scroll_gesture_enabled);
- setCheckBoxes();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ boolean state;
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
return true;
+ case R.id.action_toggle_dismissible_location:
+ state = !item.isChecked();
+ mapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state);
+ Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show();
+ item.setChecked(state);
+ return true;
+ case R.id.action_toggle_dismissible_bearing:
+ state = !item.isChecked();
+ mapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state);
+ Toast.makeText(this, "Dismiss bearing mode on gesture = " + state, Toast.LENGTH_SHORT).show();
+ item.setChecked(state);
+ return true;
+ case R.id.action_toggle_rotate_gesture_enabled:
+ state = !item.isChecked();
+ mapboxMap.getUiSettings().setRotateGesturesEnabled(state);
+ Toast.makeText(this, "Rotate gesture enabled = " + state, Toast.LENGTH_SHORT).show();
+ item.setChecked(state);
+ return true;
+ case R.id.action_toggle_scroll_gesture_enabled:
+ state = !item.isChecked();
+ mapboxMap.getUiSettings().setScrollGesturesEnabled(state);
+ Toast.makeText(this, "Scroll gesture enabled = " + state, Toast.LENGTH_SHORT).show();
+ item.setChecked(state);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
-
- private void setCheckBoxes() {
- if (mapboxMap != null && dismissBearingTrackingOnGestureItem != null) {
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- UiSettings uiSettings = mapboxMap.getUiSettings();
- dismissBearingTrackingOnGestureItem.setChecked(trackingSettings.isDismissBearingTrackingOnGesture());
- dismissLocationTrackingOnGestureItem.setChecked(trackingSettings.isDismissLocationTrackingOnGesture());
- enableRotateGesturesItem.setChecked(uiSettings.isRotateGesturesEnabled());
- enableScrollGesturesItem.setChecked(uiSettings.isScrollGesturesEnabled());
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- boolean state;
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- case R.id.action_toggle_dismissible_location:
- state = !item.isChecked();
- mapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state);
- Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- case R.id.action_toggle_dismissible_bearing:
- state = !item.isChecked();
- mapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state);
- Toast.makeText(this, "Dismiss bearing mode on gesture = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- case R.id.action_toggle_rotate_gesture_enabled:
- state = !item.isChecked();
- mapboxMap.getUiSettings().setRotateGesturesEnabled(state);
- Toast.makeText(this, "Rotate gesture enabled = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- case R.id.action_toggle_scroll_gesture_enabled:
- state = !item.isChecked();
- mapboxMap.getUiSettings().setScrollGesturesEnabled(state);
- Toast.makeText(this, "Scroll gesture enabled = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java
index 71adba8ac7..a935c2134f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java
@@ -15,41 +15,41 @@ import java.util.List;
public class FeatureAdapter extends RecyclerView.Adapter<FeatureAdapter.ViewHolder> {
- private List<Feature> features;
+ private List<Feature> features;
- public static class ViewHolder extends RecyclerView.ViewHolder {
+ public static class ViewHolder extends RecyclerView.ViewHolder {
- public TextView labelView;
- public TextView descriptionView;
+ public TextView labelView;
+ public TextView descriptionView;
- public ViewHolder(View view) {
- super(view);
- Typeface typeface = FontCache.get("Roboto-Regular.ttf",view.getContext());
- labelView = (TextView) view.findViewById(R.id.nameView);
- labelView.setTypeface(typeface);
- descriptionView = (TextView) view.findViewById(R.id.descriptionView);
- descriptionView.setTypeface(typeface);
- }
- }
-
- public FeatureAdapter(List<Feature> features) {
- this.features = features;
- }
-
- @Override
- public FeatureAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_feature, parent, false);
- return new ViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- holder.labelView.setText(features.get(position).getLabel());
- holder.descriptionView.setText(features.get(position).getDescription());
- }
-
- @Override
- public int getItemCount() {
- return features.size();
+ public ViewHolder(View view) {
+ super(view);
+ Typeface typeface = FontCache.get("Roboto-Regular.ttf", view.getContext());
+ labelView = (TextView) view.findViewById(R.id.nameView);
+ labelView.setTypeface(typeface);
+ descriptionView = (TextView) view.findViewById(R.id.descriptionView);
+ descriptionView.setTypeface(typeface);
}
+ }
+
+ public FeatureAdapter(List<Feature> features) {
+ this.features = features;
+ }
+
+ @Override
+ public FeatureAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_feature, parent, false);
+ return new ViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(ViewHolder holder, int position) {
+ holder.labelView.setText(features.get(position).getLabel());
+ holder.descriptionView.setText(features.get(position).getDescription());
+ }
+
+ @Override
+ public int getItemCount() {
+ return features.size();
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java
index d86e06ea6d..012bbed4ca 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java
@@ -18,161 +18,162 @@ import java.util.Comparator;
public class FeatureSectionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
- private static final int SECTION_TYPE = 0;
-
- private final Context context;
- private final SparseArray<Section> sections;
- private final RecyclerView.Adapter adapter;
-
- @LayoutRes
- private final int sectionRes;
-
- @IdRes
- private final int textRes;
-
- private boolean valid = true;
-
- public FeatureSectionAdapter(Context ctx, int sectionResourceId, int textResourceId, RecyclerView.Adapter baseAdapter) {
- context = ctx;
- sectionRes = sectionResourceId;
- textRes = textResourceId;
- adapter = baseAdapter;
- sections = new SparseArray<>();
- adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
- @Override
- public void onChanged() {
- valid = adapter.getItemCount() > 0;
- notifyDataSetChanged();
- }
-
- @Override
- public void onItemRangeChanged(int positionStart, int itemCount) {
- valid = adapter.getItemCount() > 0;
- notifyItemRangeChanged(positionStart, itemCount);
- }
-
- @Override
- public void onItemRangeInserted(int positionStart, int itemCount) {
- valid = adapter.getItemCount() > 0;
- notifyItemRangeInserted(positionStart, itemCount);
- }
-
- @Override
- public void onItemRangeRemoved(int positionStart, int itemCount) {
- valid = adapter.getItemCount() > 0;
- notifyItemRangeRemoved(positionStart, itemCount);
- }
- });
- }
+ private static final int SECTION_TYPE = 0;
+
+ private final Context context;
+ private final SparseArray<Section> sections;
+ private final RecyclerView.Adapter adapter;
+
+ @LayoutRes
+ private final int sectionRes;
+
+ @IdRes
+ private final int textRes;
+
+ private boolean valid = true;
+
+ public FeatureSectionAdapter(Context ctx, int sectionResourceId, int textResourceId,
+ RecyclerView.Adapter baseAdapter) {
+ context = ctx;
+ sectionRes = sectionResourceId;
+ textRes = textResourceId;
+ adapter = baseAdapter;
+ sections = new SparseArray<>();
+ adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
+ @Override
+ public void onChanged() {
+ valid = adapter.getItemCount() > 0;
+ notifyDataSetChanged();
+ }
+ @Override
+ public void onItemRangeChanged(int positionStart, int itemCount) {
+ valid = adapter.getItemCount() > 0;
+ notifyItemRangeChanged(positionStart, itemCount);
+ }
- public static class SectionViewHolder extends RecyclerView.ViewHolder {
+ @Override
+ public void onItemRangeInserted(int positionStart, int itemCount) {
+ valid = adapter.getItemCount() > 0;
+ notifyItemRangeInserted(positionStart, itemCount);
+ }
- public TextView title;
+ @Override
+ public void onItemRangeRemoved(int positionStart, int itemCount) {
+ valid = adapter.getItemCount() > 0;
+ notifyItemRangeRemoved(positionStart, itemCount);
+ }
+ });
+ }
- public SectionViewHolder(@NonNull View view, @IdRes int textRes) {
- super(view);
- title = (TextView) view.findViewById(textRes);
- title.setTypeface(FontCache.get("Roboto-Medium.ttf", view.getContext()));
- }
- }
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int typeView) {
- if (typeView == SECTION_TYPE) {
- final View view = LayoutInflater.from(context).inflate(sectionRes, parent, false);
- return new SectionViewHolder(view, textRes);
- } else {
- return adapter.onCreateViewHolder(parent, typeView - 1);
- }
- }
+ public static class SectionViewHolder extends RecyclerView.ViewHolder {
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder sectionViewHolder, int position) {
- if (isSectionHeaderPosition(position)) {
- ((SectionViewHolder) sectionViewHolder).title.setText(sections.get(position).title);
- } else {
- adapter.onBindViewHolder(sectionViewHolder, getConvertedPosition(position));
- }
+ public TextView title;
+ public SectionViewHolder(@NonNull View view, @IdRes int textRes) {
+ super(view);
+ title = (TextView) view.findViewById(textRes);
+ title.setTypeface(FontCache.get("Roboto-Medium.ttf", view.getContext()));
}
-
- @Override
- public int getItemViewType(int position) {
- return isSectionHeaderPosition(position)
- ? SECTION_TYPE
- : adapter.getItemViewType(getConvertedPosition(position)) + 1;
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int typeView) {
+ if (typeView == SECTION_TYPE) {
+ final View view = LayoutInflater.from(context).inflate(sectionRes, parent, false);
+ return new SectionViewHolder(view, textRes);
+ } else {
+ return adapter.onCreateViewHolder(parent, typeView - 1);
}
-
-
- public static class Section {
- int firstPosition;
- int sectionedPosition;
- CharSequence title;
-
- public Section(int firstPosition, CharSequence title) {
- this.firstPosition = firstPosition;
- this.title = title;
- }
-
- public CharSequence getTitle() {
- return title;
- }
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder sectionViewHolder, int position) {
+ if (isSectionHeaderPosition(position)) {
+ ((SectionViewHolder) sectionViewHolder).title.setText(sections.get(position).title);
+ } else {
+ adapter.onBindViewHolder(sectionViewHolder, getConvertedPosition(position));
}
+ }
- public void setSections(Section[] sections) {
- this.sections.clear();
+ @Override
+ public int getItemViewType(int position) {
+ return isSectionHeaderPosition(position)
+ ? SECTION_TYPE
+ : adapter.getItemViewType(getConvertedPosition(position)) + 1;
+ }
- Arrays.sort(sections, new Comparator<Section>() {
- @Override
- public int compare(Section o, Section o1) {
- return (o.firstPosition == o1.firstPosition)
- ? 0
- : ((o.firstPosition < o1.firstPosition) ? -1 : 1);
- }
- });
- int offset = 0;
- for (Section section : sections) {
- section.sectionedPosition = section.firstPosition + offset;
- this.sections.append(section.sectionedPosition, section);
- ++offset;
- }
+ public static class Section {
+ int firstPosition;
+ int sectionedPosition;
+ CharSequence title;
- notifyDataSetChanged();
+ public Section(int firstPosition, CharSequence title) {
+ this.firstPosition = firstPosition;
+ this.title = title;
}
- public int getConvertedPosition(int sectionedPosition) {
- if (isSectionHeaderPosition(sectionedPosition)) {
- return RecyclerView.NO_POSITION;
- }
-
- int offset = 0;
- for (int i = 0; i < sections.size(); i++) {
- if (sections.valueAt(i).sectionedPosition > sectionedPosition) {
- break;
- }
- --offset;
- }
- return sectionedPosition + offset;
+ public CharSequence getTitle() {
+ return title;
}
-
- public boolean isSectionHeaderPosition(int position) {
- return sections.get(position) != null;
+ }
+
+
+ public void setSections(Section[] sections) {
+ this.sections.clear();
+
+ Arrays.sort(sections, new Comparator<Section>() {
+ @Override
+ public int compare(Section section, Section section1) {
+ return (section.firstPosition == section1.firstPosition)
+ ? 0
+ : ((section.firstPosition < section1.firstPosition) ? -1 : 1);
+ }
+ });
+
+ int offset = 0;
+ for (Section section : sections) {
+ section.sectionedPosition = section.firstPosition + offset;
+ this.sections.append(section.sectionedPosition, section);
+ ++offset;
}
+ notifyDataSetChanged();
+ }
- @Override
- public long getItemId(int position) {
- return isSectionHeaderPosition(position)
- ? Integer.MAX_VALUE - sections.indexOfKey(position)
- : adapter.getItemId(getConvertedPosition(position));
+ public int getConvertedPosition(int sectionedPosition) {
+ if (isSectionHeaderPosition(sectionedPosition)) {
+ return RecyclerView.NO_POSITION;
}
- @Override
- public int getItemCount() {
- return (valid ? adapter.getItemCount() + sections.size() : 0);
+ int offset = 0;
+ for (int i = 0; i < sections.size(); i++) {
+ if (sections.valueAt(i).sectionedPosition > sectionedPosition) {
+ break;
+ }
+ --offset;
}
+ return sectionedPosition + offset;
+ }
+
+ public boolean isSectionHeaderPosition(int position) {
+ return sections.get(position) != null;
+ }
+
+
+ @Override
+ public long getItemId(int position) {
+ return isSectionHeaderPosition(position)
+ ? Integer.MAX_VALUE - sections.indexOfKey(position)
+ : adapter.getItemId(getConvertedPosition(position));
+ }
+
+ @Override
+ public int getItemCount() {
+ return (valid ? adapter.getItemCount() + sections.size() : 0);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
index a54e55529e..d745982388 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
@@ -5,73 +5,73 @@ import android.os.Parcelable;
public class Feature implements Parcelable {
- private String name;
- private String label;
- private String description;
- private String category;
- private boolean requiresLocationPermission;
+ private String name;
+ private String label;
+ private String description;
+ private String category;
+ private boolean requiresLocationPermission;
- public Feature(String name, String label, String description, String category, boolean requiresLocationPermission) {
- this.name = name;
- this.label = label;
- this.description = description;
- this.category = category;
- this.requiresLocationPermission = requiresLocationPermission;
- }
+ public Feature(String name, String label, String description, String category, boolean requiresLocationPermission) {
+ this.name = name;
+ this.label = label;
+ this.description = description;
+ this.category = category;
+ this.requiresLocationPermission = requiresLocationPermission;
+ }
- private Feature(Parcel in) {
- name = in.readString();
- label = in.readString();
- description = in.readString();
- category = in.readString();
- requiresLocationPermission = in.readByte() != 0;
- }
+ private Feature(Parcel in) {
+ name = in.readString();
+ label = in.readString();
+ description = in.readString();
+ category = in.readString();
+ requiresLocationPermission = in.readByte() != 0;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public String getSimpleName() {
- String[] split = name.split("\\.");
- return split[split.length - 1];
- }
+ public String getSimpleName() {
+ String[] split = name.split("\\.");
+ return split[split.length - 1];
+ }
- public String getLabel() {
- return label != null ? label : getSimpleName();
- }
+ public String getLabel() {
+ return label != null ? label : getSimpleName();
+ }
- public String getDescription() {
- return description != null ? description : "-";
- }
+ public String getDescription() {
+ return description != null ? description : "-";
+ }
- public String getCategory() {
- return category;
- }
+ public String getCategory() {
+ return category;
+ }
- public boolean isRequiresLocationPermission() {
- return requiresLocationPermission;
- }
+ public boolean isRequiresLocationPermission() {
+ return requiresLocationPermission;
+ }
- public int describeContents() {
- return 0;
- }
+ public int describeContents() {
+ return 0;
+ }
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(name);
- out.writeString(label);
- out.writeString(description);
- out.writeString(category);
- out.writeByte((byte) (requiresLocationPermission ? 1 : 0));
- }
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeString(name);
+ out.writeString(label);
+ out.writeString(description);
+ out.writeString(category);
+ out.writeByte((byte) (requiresLocationPermission ? 1 : 0));
+ }
- public static final Parcelable.Creator<Feature> CREATOR
- = new Parcelable.Creator<Feature>() {
- public Feature createFromParcel(Parcel in) {
- return new Feature(in);
- }
+ public static final Parcelable.Creator<Feature> CREATOR
+ = new Parcelable.Creator<Feature>() {
+ public Feature createFromParcel(Parcel in) {
+ return new Feature(in);
+ }
- public Feature[] newArray(int size) {
- return new Feature[size];
- }
+ public Feature[] newArray(int size) {
+ return new Feature[size];
+ }
};
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java
index 4eabb0a3bb..3b9f67aa1e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java
@@ -4,15 +4,15 @@ import com.mapbox.mapboxsdk.annotations.Marker;
public class CityStateMarker extends Marker {
- private String infoWindowBackgroundColor;
+ private String infoWindowBackgroundColor;
- public CityStateMarker(CityStateMarkerOptions cityStateOptions, String color) {
- super(cityStateOptions);
- infoWindowBackgroundColor = color;
- }
+ public CityStateMarker(CityStateMarkerOptions cityStateOptions, String color) {
+ super(cityStateOptions);
+ infoWindowBackgroundColor = color;
+ }
- public String getInfoWindowBackgroundColor() {
- return infoWindowBackgroundColor;
- }
+ public String getInfoWindowBackgroundColor() {
+ return infoWindowBackgroundColor;
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarkerOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarkerOptions.java
index a4c32da92c..874c644af7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarkerOptions.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarkerOptions.java
@@ -11,58 +11,58 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
public class CityStateMarkerOptions extends BaseMarkerOptions<CityStateMarker, CityStateMarkerOptions> {
- private String infoWindowBackgroundColor;
+ private String infoWindowBackgroundColor;
- public CityStateMarkerOptions infoWindowBackground(String color) {
- infoWindowBackgroundColor = color;
- return getThis();
- }
+ public CityStateMarkerOptions infoWindowBackground(String color) {
+ infoWindowBackgroundColor = color;
+ return getThis();
+ }
- public CityStateMarkerOptions() {
- }
+ public CityStateMarkerOptions() {
+ }
- private CityStateMarkerOptions(Parcel in) {
- position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
- snippet(in.readString());
- String iconId = in.readString();
- Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
- Icon icon = IconFactory.recreate(iconId, iconBitmap);
- icon(icon);
- title(in.readString());
- }
+ private CityStateMarkerOptions(Parcel in) {
+ position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
+ snippet(in.readString());
+ String iconId = in.readString();
+ Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
+ Icon icon = IconFactory.recreate(iconId, iconBitmap);
+ icon(icon);
+ title(in.readString());
+ }
- @Override
- public CityStateMarkerOptions getThis() {
- return this;
- }
+ @Override
+ public CityStateMarkerOptions getThis() {
+ return this;
+ }
- @Override
- public CityStateMarker getMarker() {
- return new CityStateMarker(this, infoWindowBackgroundColor);
- }
+ @Override
+ public CityStateMarker getMarker() {
+ return new CityStateMarker(this, infoWindowBackgroundColor);
+ }
- public static final Parcelable.Creator<CityStateMarkerOptions> CREATOR
- = new Parcelable.Creator<CityStateMarkerOptions>() {
- public CityStateMarkerOptions createFromParcel(Parcel in) {
- return new CityStateMarkerOptions(in);
- }
+ public static final Parcelable.Creator<CityStateMarkerOptions> CREATOR
+ = new Parcelable.Creator<CityStateMarkerOptions>() {
+ public CityStateMarkerOptions createFromParcel(Parcel in) {
+ return new CityStateMarkerOptions(in);
+ }
- public CityStateMarkerOptions[] newArray(int size) {
- return new CityStateMarkerOptions[size];
- }
+ public CityStateMarkerOptions[] newArray(int size) {
+ return new CityStateMarkerOptions[size];
+ }
};
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(position, flags);
- out.writeString(snippet);
- out.writeString(icon.getId());
- out.writeParcelable(icon.getBitmap(), flags);
- out.writeString(title);
- }
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(position, flags);
+ out.writeString(snippet);
+ out.writeString(icon.getId());
+ out.writeParcelable(icon.getBitmap(), flags);
+ out.writeString(title);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java
index 7503b48df3..af97c9df69 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java
@@ -5,20 +5,20 @@ import com.mapbox.mapboxsdk.annotations.Marker;
public class CountryMarker extends Marker {
- private String abbrevName;
- private int flagRes;
+ private String abbrevName;
+ private int flagRes;
- public CountryMarker(BaseMarkerOptions baseMarkerOptions, String abbrevName, int iconRes) {
- super(baseMarkerOptions);
- this.abbrevName = abbrevName;
- this.flagRes = iconRes;
- }
+ public CountryMarker(BaseMarkerOptions baseMarkerOptions, String abbrevName, int iconRes) {
+ super(baseMarkerOptions);
+ this.abbrevName = abbrevName;
+ this.flagRes = iconRes;
+ }
- public String getAbbrevName() {
- return abbrevName;
- }
+ public String getAbbrevName() {
+ return abbrevName;
+ }
- public int getFlagRes() {
- return flagRes;
- }
+ public int getFlagRes() {
+ return flagRes;
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerOptions.java
index ac1ff25bf2..0a64359979 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerOptions.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerOptions.java
@@ -11,65 +11,65 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
public class CountryMarkerOptions extends BaseMarkerOptions<CountryMarker, CountryMarkerOptions> {
- private String abbrevName;
- private int flagRes;
+ private String abbrevName;
+ private int flagRes;
- public CountryMarkerOptions abbrevName(String name) {
- abbrevName = name;
- return getThis();
- }
+ public CountryMarkerOptions abbrevName(String name) {
+ abbrevName = name;
+ return getThis();
+ }
- public CountryMarkerOptions flagRes(int imageRes) {
- flagRes = imageRes;
- return getThis();
- }
+ public CountryMarkerOptions flagRes(int imageRes) {
+ flagRes = imageRes;
+ return getThis();
+ }
- public CountryMarkerOptions() {
- }
+ public CountryMarkerOptions() {
+ }
- private CountryMarkerOptions(Parcel in) {
- position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
- snippet(in.readString());
- String iconId = in.readString();
- Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
- Icon icon = IconFactory.recreate(iconId, iconBitmap);
- icon(icon);
- title(in.readString());
- }
+ private CountryMarkerOptions(Parcel in) {
+ position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
+ snippet(in.readString());
+ String iconId = in.readString();
+ Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
+ Icon icon = IconFactory.recreate(iconId, iconBitmap);
+ icon(icon);
+ title(in.readString());
+ }
- @Override
- public CountryMarkerOptions getThis() {
- return this;
- }
+ @Override
+ public CountryMarkerOptions getThis() {
+ return this;
+ }
- @Override
- public CountryMarker getMarker() {
- return new CountryMarker(this, abbrevName, flagRes);
- }
+ @Override
+ public CountryMarker getMarker() {
+ return new CountryMarker(this, abbrevName, flagRes);
+ }
- public static final Parcelable.Creator<CountryMarkerOptions> CREATOR
- = new Parcelable.Creator<CountryMarkerOptions>() {
- public CountryMarkerOptions createFromParcel(Parcel in) {
- return new CountryMarkerOptions(in);
- }
+ public static final Parcelable.Creator<CountryMarkerOptions> CREATOR
+ = new Parcelable.Creator<CountryMarkerOptions>() {
+ public CountryMarkerOptions createFromParcel(Parcel in) {
+ return new CountryMarkerOptions(in);
+ }
- public CountryMarkerOptions[] newArray(int size) {
- return new CountryMarkerOptions[size];
- }
+ public CountryMarkerOptions[] newArray(int size) {
+ return new CountryMarkerOptions[size];
+ }
};
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(position, flags);
- out.writeString(snippet);
- out.writeString(icon.getId());
- out.writeParcelable(icon.getBitmap(), flags);
- out.writeString(title);
- }
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(position, flags);
+ out.writeString(snippet);
+ out.writeString(icon.getId());
+ out.writeParcelable(icon.getBitmap(), flags);
+ out.writeString(title);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java
index 64f0565026..cab03e4f7a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java
@@ -5,20 +5,20 @@ import com.mapbox.mapboxsdk.annotations.MarkerView;
public class CountryMarkerView extends MarkerView {
- private String abbrevName;
- private int flagRes;
+ private String abbrevName;
+ private int flagRes;
- public CountryMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String abbrevName, int flagRes) {
- super(baseMarkerViewOptions);
- this.abbrevName = abbrevName;
- this.flagRes = flagRes;
- }
+ public CountryMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String abbrevName, int flagRes) {
+ super(baseMarkerViewOptions);
+ this.abbrevName = abbrevName;
+ this.flagRes = flagRes;
+ }
- public String getAbbrevName() {
- return abbrevName;
- }
+ public String getAbbrevName() {
+ return abbrevName;
+ }
- public int getFlagRes() {
- return flagRes;
- }
+ public int getFlagRes() {
+ return flagRes;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java
index 9059b5978b..4dc9195ffd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java
@@ -11,91 +11,89 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
public class CountryMarkerViewOptions extends BaseMarkerViewOptions<CountryMarkerView, CountryMarkerViewOptions> {
- private String abbrevName;
- private int flagRes;
-
- public CountryMarkerViewOptions() {
- }
-
- protected CountryMarkerViewOptions(Parcel in) {
- position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
- snippet(in.readString());
- title(in.readString());
- flat(in.readByte() != 0);
- anchor(in.readFloat(), in.readFloat());
- infoWindowAnchor(in.readFloat(), in.readFloat());
- rotation(in.readFloat());
- visible(in.readByte() != 0);
- alpha(in.readFloat());
- if (in.readByte() != 0) {
- // this means we have an icon
- String iconId = in.readString();
- Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
- Icon icon = IconFactory.recreate(iconId, iconBitmap);
- icon(icon);
- }
- abbrevName(in.readString());
- flagRes(in.readInt());
- }
-
- @Override
- public CountryMarkerViewOptions getThis() {
- return this;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(getPosition(), flags);
- out.writeString(getSnippet());
- out.writeString(getTitle());
- out.writeByte((byte) (isFlat() ? 1 : 0));
- out.writeFloat(getAnchorU());
- out.writeFloat(getAnchorV());
- out.writeFloat(getInfoWindowAnchorU());
- out.writeFloat(getInfoWindowAnchorV());
- out.writeFloat(getRotation());
- out.writeByte((byte) (isVisible() ? 1 : 0));
- out.writeFloat(getAlpha());
- Icon icon = getIcon();
- out.writeByte((byte) (icon != null ? 1 : 0));
- if (icon != null) {
- out.writeString(getIcon().getId());
- out.writeParcelable(getIcon().getBitmap(), flags);
- }
- out.writeString(abbrevName);
- out.writeInt(flagRes);
+ private String abbrevName;
+ private int flagRes;
+
+ public CountryMarkerViewOptions() {
+ }
+
+ protected CountryMarkerViewOptions(Parcel in) {
+ position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
+ snippet(in.readString());
+ title(in.readString());
+ flat(in.readByte() != 0);
+ anchor(in.readFloat(), in.readFloat());
+ infoWindowAnchor(in.readFloat(), in.readFloat());
+ rotation(in.readFloat());
+ visible(in.readByte() != 0);
+ alpha(in.readFloat());
+ if (in.readByte() != 0) {
+ // this means we have an icon
+ String iconId = in.readString();
+ Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
+ Icon icon = IconFactory.recreate(iconId, iconBitmap);
+ icon(icon);
}
-
- @Override
- public CountryMarkerView getMarker() {
- return new CountryMarkerView(this, abbrevName, flagRes);
- }
-
- public CountryMarkerViewOptions abbrevName(String abbrevName) {
- this.abbrevName = abbrevName;
- return getThis();
- }
-
- public CountryMarkerViewOptions flagRes(int flagRes) {
- this.flagRes = flagRes;
- return getThis();
+ abbrevName(in.readString());
+ flagRes(in.readInt());
+ }
+
+ @Override
+ public CountryMarkerViewOptions getThis() {
+ return this;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(getPosition(), flags);
+ out.writeString(getSnippet());
+ out.writeString(getTitle());
+ out.writeByte((byte) (isFlat() ? 1 : 0));
+ out.writeFloat(getAnchorU());
+ out.writeFloat(getAnchorV());
+ out.writeFloat(getInfoWindowAnchorU());
+ out.writeFloat(getInfoWindowAnchorV());
+ out.writeFloat(getRotation());
+ out.writeByte((byte) (isVisible() ? 1 : 0));
+ out.writeFloat(getAlpha());
+ Icon icon = getIcon();
+ out.writeByte((byte) (icon != null ? 1 : 0));
+ if (icon != null) {
+ out.writeString(getIcon().getId());
+ out.writeParcelable(getIcon().getBitmap(), flags);
}
-
- public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
- = new Parcelable.Creator<CountryMarkerViewOptions>() {
- public CountryMarkerViewOptions createFromParcel(Parcel in) {
- return new CountryMarkerViewOptions(in);
- }
-
- public CountryMarkerViewOptions[] newArray(int size) {
- return new CountryMarkerViewOptions[size];
- }
+ out.writeString(abbrevName);
+ out.writeInt(flagRes);
+ }
+
+ @Override
+ public CountryMarkerView getMarker() {
+ return new CountryMarkerView(this, abbrevName, flagRes);
+ }
+
+ public CountryMarkerViewOptions abbrevName(String abbrevName) {
+ this.abbrevName = abbrevName;
+ return getThis();
+ }
+
+ public CountryMarkerViewOptions flagRes(int flagRes) {
+ this.flagRes = flagRes;
+ return getThis();
+ }
+
+ public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
+ = new Parcelable.Creator<CountryMarkerViewOptions>() {
+ public CountryMarkerViewOptions createFromParcel(Parcel in) {
+ return new CountryMarkerViewOptions(in);
+ }
+
+ public CountryMarkerViewOptions[] newArray(int size) {
+ return new CountryMarkerViewOptions[size];
+ }
};
-
-
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java
index 48867ea5eb..971c3359b2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java
@@ -5,7 +5,7 @@ import com.mapbox.mapboxsdk.annotations.MarkerView;
public class PulseMarkerView extends MarkerView {
- public PulseMarkerView(BaseMarkerViewOptions baseMarkerViewOptions) {
- super(baseMarkerViewOptions);
- }
+ public PulseMarkerView(BaseMarkerViewOptions baseMarkerViewOptions) {
+ super(baseMarkerViewOptions);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java
index 70ff6a22e2..20c479fc9b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java
@@ -11,69 +11,69 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
public class PulseMarkerViewOptions extends BaseMarkerViewOptions<PulseMarkerView, PulseMarkerViewOptions> {
- public PulseMarkerViewOptions() {
- }
+ public PulseMarkerViewOptions() {
+ }
- protected PulseMarkerViewOptions(Parcel in) {
- position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
- snippet(in.readString());
- title(in.readString());
- flat(in.readByte() != 0);
- anchor(in.readFloat(), in.readFloat());
- selected = in.readByte() != 0;
- rotation(in.readFloat());
- if (in.readByte() != 0) {
- // this means we have an icon
- String iconId = in.readString();
- Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
- Icon icon = IconFactory.recreate(iconId, iconBitmap);
- icon(icon);
- }
+ protected PulseMarkerViewOptions(Parcel in) {
+ position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
+ snippet(in.readString());
+ title(in.readString());
+ flat(in.readByte() != 0);
+ anchor(in.readFloat(), in.readFloat());
+ selected = in.readByte() != 0;
+ rotation(in.readFloat());
+ if (in.readByte() != 0) {
+ // this means we have an icon
+ String iconId = in.readString();
+ Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
+ Icon icon = IconFactory.recreate(iconId, iconBitmap);
+ icon(icon);
}
+ }
- @Override
- public PulseMarkerViewOptions getThis() {
- return this;
- }
+ @Override
+ public PulseMarkerViewOptions getThis() {
+ return this;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(getPosition(), flags);
- out.writeString(getSnippet());
- out.writeString(getTitle());
- out.writeByte((byte) (isFlat() ? 1 : 0));
- out.writeFloat(getAnchorU());
- out.writeFloat(getAnchorV());
- out.writeFloat(getInfoWindowAnchorU());
- out.writeFloat(getInfoWindowAnchorV());
- out.writeByte((byte) (selected ? 1 : 0));
- out.writeFloat(getRotation());
- Icon icon = getIcon();
- out.writeByte((byte) (icon != null ? 1 : 0));
- if (icon != null) {
- out.writeString(getIcon().getId());
- out.writeParcelable(getIcon().getBitmap(), flags);
- }
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(getPosition(), flags);
+ out.writeString(getSnippet());
+ out.writeString(getTitle());
+ out.writeByte((byte) (isFlat() ? 1 : 0));
+ out.writeFloat(getAnchorU());
+ out.writeFloat(getAnchorV());
+ out.writeFloat(getInfoWindowAnchorU());
+ out.writeFloat(getInfoWindowAnchorV());
+ out.writeByte((byte) (selected ? 1 : 0));
+ out.writeFloat(getRotation());
+ Icon icon = getIcon();
+ out.writeByte((byte) (icon != null ? 1 : 0));
+ if (icon != null) {
+ out.writeString(getIcon().getId());
+ out.writeParcelable(getIcon().getBitmap(), flags);
}
+ }
- @Override
- public PulseMarkerView getMarker() {
- return new PulseMarkerView(this);
- }
+ @Override
+ public PulseMarkerView getMarker() {
+ return new PulseMarkerView(this);
+ }
- public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
- = new Parcelable.Creator<CountryMarkerViewOptions>() {
- public CountryMarkerViewOptions createFromParcel(Parcel in) {
- return new CountryMarkerViewOptions(in);
- }
+ public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
+ = new Parcelable.Creator<CountryMarkerViewOptions>() {
+ public CountryMarkerViewOptions createFromParcel(Parcel in) {
+ return new CountryMarkerViewOptions(in);
+ }
- public CountryMarkerViewOptions[] newArray(int size) {
- return new CountryMarkerViewOptions[size];
- }
+ public CountryMarkerViewOptions[] newArray(int size) {
+ return new CountryMarkerViewOptions[size];
+ }
};
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java
index c0a589cb57..f507c5f1ab 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java
@@ -5,14 +5,14 @@ import com.mapbox.mapboxsdk.annotations.MarkerView;
public class TextMarkerView extends MarkerView {
- private String text;
+ private String text;
- public TextMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String text) {
- super(baseMarkerViewOptions);
- this.text = text;
- }
+ public TextMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String text) {
+ super(baseMarkerViewOptions);
+ this.text = text;
+ }
- public String getText() {
- return text;
- }
+ public String getText() {
+ return text;
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java
index a91ec5e541..df7c575f74 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java
@@ -11,81 +11,81 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
public class TextMarkerViewOptions extends BaseMarkerViewOptions<TextMarkerView, TextMarkerViewOptions> {
- private String text;
+ private String text;
- public TextMarkerViewOptions() {
- }
+ public TextMarkerViewOptions() {
+ }
- protected TextMarkerViewOptions(Parcel in) {
- position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
- snippet(in.readString());
- title(in.readString());
- flat(in.readByte() != 0);
- anchor(in.readFloat(), in.readFloat());
- infoWindowAnchor(in.readFloat(), in.readFloat());
- rotation(in.readFloat());
- visible(in.readByte() != 0);
- alpha(in.readFloat());
- if (in.readByte() != 0) {
- // this means we have an icon
- String iconId = in.readString();
- Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
- Icon icon = IconFactory.recreate(iconId, iconBitmap);
- icon(icon);
- }
- text(in.readString());
+ protected TextMarkerViewOptions(Parcel in) {
+ position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
+ snippet(in.readString());
+ title(in.readString());
+ flat(in.readByte() != 0);
+ anchor(in.readFloat(), in.readFloat());
+ infoWindowAnchor(in.readFloat(), in.readFloat());
+ rotation(in.readFloat());
+ visible(in.readByte() != 0);
+ alpha(in.readFloat());
+ if (in.readByte() != 0) {
+ // this means we have an icon
+ String iconId = in.readString();
+ Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
+ Icon icon = IconFactory.recreate(iconId, iconBitmap);
+ icon(icon);
}
+ text(in.readString());
+ }
- @Override
- public TextMarkerViewOptions getThis() {
- return this;
- }
+ @Override
+ public TextMarkerViewOptions getThis() {
+ return this;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(getPosition(), flags);
- out.writeString(getSnippet());
- out.writeString(getTitle());
- out.writeByte((byte) (isFlat() ? 1 : 0));
- out.writeFloat(getAnchorU());
- out.writeFloat(getAnchorV());
- out.writeFloat(getInfoWindowAnchorU());
- out.writeFloat(getInfoWindowAnchorV());
- out.writeFloat(getRotation());
- out.writeByte((byte) (isVisible() ? 1 : 0));
- out.writeFloat(alpha);
- Icon icon = getIcon();
- out.writeByte((byte) (icon != null ? 1 : 0));
- if (icon != null) {
- out.writeString(getIcon().getId());
- out.writeParcelable(getIcon().getBitmap(), flags);
- }
- out.writeString(text);
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(getPosition(), flags);
+ out.writeString(getSnippet());
+ out.writeString(getTitle());
+ out.writeByte((byte) (isFlat() ? 1 : 0));
+ out.writeFloat(getAnchorU());
+ out.writeFloat(getAnchorV());
+ out.writeFloat(getInfoWindowAnchorU());
+ out.writeFloat(getInfoWindowAnchorV());
+ out.writeFloat(getRotation());
+ out.writeByte((byte) (isVisible() ? 1 : 0));
+ out.writeFloat(alpha);
+ Icon icon = getIcon();
+ out.writeByte((byte) (icon != null ? 1 : 0));
+ if (icon != null) {
+ out.writeString(getIcon().getId());
+ out.writeParcelable(getIcon().getBitmap(), flags);
}
+ out.writeString(text);
+ }
- @Override
- public TextMarkerView getMarker() {
- return new TextMarkerView(this, text);
- }
+ @Override
+ public TextMarkerView getMarker() {
+ return new TextMarkerView(this, text);
+ }
- public TextMarkerViewOptions text(String text) {
- this.text = text;
- return getThis();
- }
+ public TextMarkerViewOptions text(String text) {
+ this.text = text;
+ return getThis();
+ }
- public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
- = new Parcelable.Creator<CountryMarkerViewOptions>() {
- public CountryMarkerViewOptions createFromParcel(Parcel in) {
- return new CountryMarkerViewOptions(in);
- }
+ public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
+ = new Parcelable.Creator<CountryMarkerViewOptions>() {
+ public CountryMarkerViewOptions createFromParcel(Parcel in) {
+ return new CountryMarkerViewOptions(in);
+ }
- public CountryMarkerViewOptions[] newArray(int size) {
- return new CountryMarkerViewOptions[size];
- }
+ public CountryMarkerViewOptions[] newArray(int size) {
+ return new CountryMarkerViewOptions[size];
+ }
};
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/constants/AppConstant.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/constants/AppConstant.java
index 095e47a3d2..aaef7f8a51 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/constants/AppConstant.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/constants/AppConstant.java
@@ -2,5 +2,5 @@ package com.mapbox.mapboxsdk.testapp.model.constants;
public class AppConstant {
- public static final int STYLE_VERSION = 9;
+ public static final int STYLE_VERSION = 9;
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java
index a75061bc9b..8c049d7730 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java
@@ -1,15 +1,15 @@
package com.mapbox.mapboxsdk.testapp.model.customlayer;
public class ExampleCustomLayer {
- static {
- System.loadLibrary("example-custom-layer");
- }
+ static {
+ System.loadLibrary("example-custom-layer");
+ }
- public native static long createContext();
+ public static native long createContext();
- public native static void setColor(float red, float green, float blue, float alpha);
+ public static native void setColor(float red, float green, float blue, float alpha);
- public static long InitializeFunction;
- public static long RenderFunction;
- public static long DeinitializeFunction;
+ public static long InitializeFunction;
+ public static long RenderFunction;
+ public static long DeinitializeFunction;
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java
index aee55ed712..b70144123f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java
@@ -7,49 +7,51 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
+
import timber.log.Timber;
+
import android.widget.EditText;
import com.mapbox.mapboxsdk.testapp.R;
public class OfflineDownloadRegionDialog extends DialogFragment {
- public interface DownloadRegionDialogListener {
- void onDownloadRegionDialogPositiveClick(String regionName);
- }
-
- DownloadRegionDialogListener listener;
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- listener = (DownloadRegionDialogListener) activity;
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-
- // Let the user choose a name for the region
- final EditText regionNameEdit = new EditText(getActivity());
-
- builder.setTitle("Choose a name for the region")
- .setIcon(R.drawable.ic_airplanemode_active_black_24dp)
- .setView(regionNameEdit)
- .setPositiveButton("Start", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- String regionName = regionNameEdit.getText().toString();
- listener.onDownloadRegionDialogPositiveClick(regionName);
- }
- }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Timber.d("Download cancelled.");
- }
- });
-
- return builder.create();
- }
+ public interface DownloadRegionDialogListener {
+ void onDownloadRegionDialogPositiveClick(String regionName);
+ }
+
+ DownloadRegionDialogListener listener;
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ listener = (DownloadRegionDialogListener) activity;
+ }
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+
+ // Let the user choose a name for the region
+ final EditText regionNameEdit = new EditText(getActivity());
+
+ builder.setTitle("Choose a name for the region")
+ .setIcon(R.drawable.ic_airplanemode_active_black_24dp)
+ .setView(regionNameEdit)
+ .setPositiveButton("Start", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String regionName = regionNameEdit.getText().toString();
+ listener.onDownloadRegionDialogPositiveClick(regionName);
+ }
+ }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Timber.d("Download cancelled.");
+ }
+ });
+
+ return builder.create();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java
index 9b4134f479..65c4102a8c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java
@@ -6,6 +6,7 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
+
import timber.log.Timber;
import com.mapbox.mapboxsdk.testapp.R;
@@ -14,33 +15,33 @@ import java.util.ArrayList;
public class OfflineListRegionsDialog extends DialogFragment {
- public static final String ITEMS = "ITEMS";
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-
- // Read args
- Bundle args = getArguments();
- ArrayList<String> offlineRegionsNames = (args == null ? null : args.getStringArrayList(ITEMS));
- CharSequence[] items = offlineRegionsNames.toArray(new CharSequence[offlineRegionsNames.size()]);
-
- builder.setTitle("List of offline regions")
- .setIcon(R.drawable.ic_airplanemode_active_black_24dp)
- .setItems(items, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Timber.d("Selected item: " + which);
- }
- })
- .setPositiveButton("Accept", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Timber.d("Dialog dismissed");
- }
- });
-
- return builder.create();
- }
+ public static final String ITEMS = "ITEMS";
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+
+ // Read args
+ Bundle args = getArguments();
+ ArrayList<String> offlineRegionsNames = (args == null ? null : args.getStringArrayList(ITEMS));
+ CharSequence[] items = offlineRegionsNames.toArray(new CharSequence[offlineRegionsNames.size()]);
+
+ builder.setTitle("List of offline regions")
+ .setIcon(R.drawable.ic_airplanemode_active_black_24dp)
+ .setItems(items, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Timber.d("Selected item: " + which);
+ }
+ })
+ .setPositiveButton("Accept", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Timber.d("Dialog dismissed");
+ }
+ });
+
+ return builder.create();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java
index 3d885dba18..e2271bd5ff 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java
@@ -2,24 +2,25 @@ package com.mapbox.mapboxsdk.testapp.utils;
import android.content.Context;
import android.graphics.Typeface;
+
import timber.log.Timber;
import java.util.Hashtable;
public class FontCache {
- private static Hashtable<String, Typeface> fontCache = new Hashtable<>();
+ private static Hashtable<String, Typeface> fontCache = new Hashtable<>();
- public static Typeface get(String name, Context context) {
- Typeface tf = fontCache.get(name);
- if (tf == null) {
- try {
- tf = Typeface.createFromAsset(context.getAssets(), name);
- fontCache.put(name, tf);
- } catch (Exception exception) {
- Timber.e("Font not found");
- }
- }
- return tf;
+ public static Typeface get(String name, Context context) {
+ Typeface tf = fontCache.get(name);
+ if (tf == null) {
+ try {
+ tf = Typeface.createFromAsset(context.getAssets(), name);
+ fontCache.put(name, tf);
+ } catch (Exception exception) {
+ Timber.e("Font not found");
+ }
}
+ return tf;
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/GeoParseUtil.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/GeoParseUtil.java
index d6a8280c6a..0d21fd2c71 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/GeoParseUtil.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/GeoParseUtil.java
@@ -20,54 +20,54 @@ import java.util.List;
public class GeoParseUtil {
- public static String loadStringFromAssets(final Context context, final String fileName) throws IOException {
- if (TextUtils.isEmpty(fileName)) {
- throw new NullPointerException("No GeoJSON File Name passed in.");
- }
- InputStream is = context.getAssets().open(fileName);
- BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
- return readAll(rd);
+ public static String loadStringFromAssets(final Context context, final String fileName) throws IOException {
+ if (TextUtils.isEmpty(fileName)) {
+ throw new NullPointerException("No GeoJSON File Name passed in.");
}
+ InputStream is = context.getAssets().open(fileName);
+ BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
+ return readAll(rd);
+ }
- public static List<LatLng> parseGeoJSONCoordinates(String geojsonStr) throws JSONException {
- List<LatLng> latLngs = new ArrayList<>();
- JSONObject jsonObject = new JSONObject(geojsonStr);
- JSONArray features = jsonObject.getJSONArray("features");
- int featureLength = features.length();
- for (int j = 0; j < featureLength; ++j) {
- JSONObject feature = features.getJSONObject(j);
- JSONObject geometry = feature.getJSONObject("geometry");
- String type = geometry.getString("type");
- JSONArray coordinates;
- if (type.equals("Polygon")) {
- coordinates = geometry.getJSONArray("coordinates").getJSONArray(0);
- } else {
- coordinates = geometry.getJSONArray("coordinates");
- }
- int len = coordinates.length();
- for (int i = 0; i < len; ++i) {
- if (coordinates.get(i) instanceof JSONArray) {
- JSONArray coord = coordinates.getJSONArray(i);
- double lng = coord.getDouble(0);
- double lat = coord.getDouble(1);
- latLngs.add(new LatLng(lat, lng));
- } else {
- double lng = coordinates.getDouble(0);
- double lat = coordinates.getDouble(1);
- latLngs.add(new LatLng(lat, lng));
- break;
- }
- }
+ public static List<LatLng> parseGeoJsonCoordinates(String geojsonStr) throws JSONException {
+ List<LatLng> latLngs = new ArrayList<>();
+ JSONObject jsonObject = new JSONObject(geojsonStr);
+ JSONArray features = jsonObject.getJSONArray("features");
+ int featureLength = features.length();
+ for (int j = 0; j < featureLength; ++j) {
+ JSONObject feature = features.getJSONObject(j);
+ JSONObject geometry = feature.getJSONObject("geometry");
+ String type = geometry.getString("type");
+ JSONArray coordinates;
+ if (type.equals("Polygon")) {
+ coordinates = geometry.getJSONArray("coordinates").getJSONArray(0);
+ } else {
+ coordinates = geometry.getJSONArray("coordinates");
+ }
+ int len = coordinates.length();
+ for (int i = 0; i < len; ++i) {
+ if (coordinates.get(i) instanceof JSONArray) {
+ JSONArray coord = coordinates.getJSONArray(i);
+ double lng = coord.getDouble(0);
+ double lat = coord.getDouble(1);
+ latLngs.add(new LatLng(lat, lng));
+ } else {
+ double lng = coordinates.getDouble(0);
+ double lat = coordinates.getDouble(1);
+ latLngs.add(new LatLng(lat, lng));
+ break;
}
- return latLngs;
+ }
}
+ return latLngs;
+ }
- private static String readAll(Reader rd) throws IOException {
- StringBuilder sb = new StringBuilder();
- int cp;
- while ((cp = rd.read()) != -1) {
- sb.append((char) cp);
- }
- return sb.toString();
+ private static String readAll(Reader rd) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ int cp;
+ while ((cp = rd.read()) != -1) {
+ sb.append((char) cp);
}
+ return sb.toString();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java
index ba74d1d837..414a781544 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java
@@ -6,90 +6,90 @@ import android.view.View;
import com.mapbox.mapboxsdk.testapp.R;
public class ItemClickSupport {
- private final RecyclerView recyclerView;
- private OnItemClickListener onItemClickListener;
- private OnItemLongClickListener onItemLongClickListener;
- private View.OnClickListener onClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (onItemClickListener != null) {
- RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
- onItemClickListener.onItemClicked(recyclerView, holder.getAdapterPosition(), view);
- }
+ private final RecyclerView recyclerView;
+ private OnItemClickListener onItemClickListener;
+ private OnItemLongClickListener onItemLongClickListener;
+ private View.OnClickListener onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (onItemClickListener != null) {
+ RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
+ onItemClickListener.onItemClicked(recyclerView, holder.getAdapterPosition(), view);
+ }
+ }
+ };
+ private View.OnLongClickListener onLongClickListener = new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ if (onItemLongClickListener != null) {
+ RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
+ return onItemLongClickListener.onItemLongClicked(recyclerView, holder.getAdapterPosition(), view);
+ }
+ return false;
+ }
+ };
+ private RecyclerView.OnChildAttachStateChangeListener attachListener
+ = new RecyclerView.OnChildAttachStateChangeListener() {
+ @Override
+ public void onChildViewAttachedToWindow(View view) {
+ if (onItemClickListener != null) {
+ view.setOnClickListener(onClickListener);
}
- };
- private View.OnLongClickListener onLongClickListener = new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- if (onItemLongClickListener != null) {
- RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
- return onItemLongClickListener.onItemLongClicked(recyclerView, holder.getAdapterPosition(), view);
- }
- return false;
- }
- };
- private RecyclerView.OnChildAttachStateChangeListener attachListener
- = new RecyclerView.OnChildAttachStateChangeListener() {
- @Override
- public void onChildViewAttachedToWindow(View view) {
- if (onItemClickListener != null) {
- view.setOnClickListener(onClickListener);
- }
- if (onItemLongClickListener != null) {
- view.setOnLongClickListener(onLongClickListener);
- }
+ if (onItemLongClickListener != null) {
+ view.setOnLongClickListener(onLongClickListener);
}
+ }
- @Override
- public void onChildViewDetachedFromWindow(View view) {
+ @Override
+ public void onChildViewDetachedFromWindow(View view) {
- }
+ }
};
- private ItemClickSupport(RecyclerView recyclerView) {
- this.recyclerView = recyclerView;
- this.recyclerView.setTag(R.id.item_click_support, this);
- this.recyclerView.addOnChildAttachStateChangeListener(attachListener);
- }
+ private ItemClickSupport(RecyclerView recyclerView) {
+ this.recyclerView = recyclerView;
+ this.recyclerView.setTag(R.id.item_click_support, this);
+ this.recyclerView.addOnChildAttachStateChangeListener(attachListener);
+ }
- public static ItemClickSupport addTo(RecyclerView view) {
- ItemClickSupport support = (ItemClickSupport) view.getTag(R.id.item_click_support);
- if (support == null) {
- support = new ItemClickSupport(view);
- }
- return support;
+ public static ItemClickSupport addTo(RecyclerView view) {
+ ItemClickSupport support = (ItemClickSupport) view.getTag(R.id.item_click_support);
+ if (support == null) {
+ support = new ItemClickSupport(view);
}
+ return support;
+ }
- public static ItemClickSupport removeFrom(RecyclerView view) {
- ItemClickSupport support = (ItemClickSupport) view.getTag(R.id.item_click_support);
- if (support != null) {
- support.detach(view);
- }
- return support;
+ public static ItemClickSupport removeFrom(RecyclerView view) {
+ ItemClickSupport support = (ItemClickSupport) view.getTag(R.id.item_click_support);
+ if (support != null) {
+ support.detach(view);
}
+ return support;
+ }
- public ItemClickSupport setOnItemClickListener(OnItemClickListener listener) {
- onItemClickListener = listener;
- return this;
- }
+ public ItemClickSupport setOnItemClickListener(OnItemClickListener listener) {
+ onItemClickListener = listener;
+ return this;
+ }
- public ItemClickSupport setOnItemLongClickListener(OnItemLongClickListener listener) {
- onItemLongClickListener = listener;
- return this;
- }
+ public ItemClickSupport setOnItemLongClickListener(OnItemLongClickListener listener) {
+ onItemLongClickListener = listener;
+ return this;
+ }
- private void detach(RecyclerView view) {
- view.removeOnChildAttachStateChangeListener(attachListener);
- view.setTag(R.id.item_click_support, null);
- }
+ private void detach(RecyclerView view) {
+ view.removeOnChildAttachStateChangeListener(attachListener);
+ view.setTag(R.id.item_click_support, null);
+ }
- public interface OnItemClickListener {
+ public interface OnItemClickListener {
- void onItemClicked(RecyclerView recyclerView, int position, View view);
- }
+ void onItemClicked(RecyclerView recyclerView, int position, View view);
+ }
- public interface OnItemLongClickListener {
+ public interface OnItemLongClickListener {
- boolean onItemLongClicked(RecyclerView recyclerView, int position, View view);
- }
+ boolean onItemLongClicked(RecyclerView recyclerView, int position, View view);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/OfflineUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/OfflineUtils.java
index a00cb230c9..8c6ab3e211 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/OfflineUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/OfflineUtils.java
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.testapp.utils;
import android.support.annotation.NonNull;
+
import timber.log.Timber;
import org.json.JSONObject;
@@ -10,27 +11,27 @@ import static com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity.JSON
public class OfflineUtils {
- public static String convertRegionName(@NonNull byte[] metadata) {
- try {
- String json = new String(metadata, JSON_CHARSET);
- JSONObject jsonObject = new JSONObject(json);
- return jsonObject.getString(JSON_FIELD_REGION_NAME);
- } catch (Exception exception) {
- return null;
- }
+ public static String convertRegionName(@NonNull byte[] metadata) {
+ try {
+ String json = new String(metadata, JSON_CHARSET);
+ JSONObject jsonObject = new JSONObject(json);
+ return jsonObject.getString(JSON_FIELD_REGION_NAME);
+ } catch (Exception exception) {
+ return null;
}
+ }
- public static byte[] convertRegionName(String regionName) {
- byte[] metadata = null;
- try {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
- String json = jsonObject.toString();
- metadata = json.getBytes(JSON_CHARSET);
- } catch (Exception exception) {
- Timber.e("Failed to encode metadata: " + exception.getMessage());
- }
- return metadata;
+ public static byte[] convertRegionName(String regionName) {
+ byte[] metadata = null;
+ try {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
+ String json = jsonObject.toString();
+ metadata = json.getBytes(JSON_CHARSET);
+ } catch (Exception exception) {
+ Timber.e("Failed to encode metadata: " + exception.getMessage());
}
-
+ return metadata;
+ }
+
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java
index 9d1fee4990..e096aa202d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java
@@ -1,3 +1,4 @@
+package com.mapbox.mapboxsdk.testapp.utils;
/*
* Copyright (C) 2007 The Android Open Source Project
*
@@ -13,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.mapbox.mapboxsdk.testapp.utils;
+
+import android.os.SystemClock;
import java.util.ArrayList;
-import android.os.SystemClock;
import timber.log.Timber;
/**
* A utility class to help log timings splits throughout a method call.
* Typical usage is:
- *
+ * <p>
* <pre>
* TimingLogger timings = new TimingLogger(TAG, "methodA");
* // ... do some work A ...
@@ -34,9 +35,9 @@ import timber.log.Timber;
* timings.addSplit("work C");
* timings.dumpToLog();
* </pre>
- *
+ * <p>
* <p>The dumpToLog call would add the following to the log:</p>
- *
+ * <p>
* <pre>
* D/TAG ( 3459): methodA: begin
* D/TAG ( 3459): methodA: 9 ms, work A
@@ -46,108 +47,114 @@ import timber.log.Timber;
* </pre>
*/
public class TimingLogger {
- /**
- * The Log tag to use for checking Log.isLoggable and for
- * logging the timings.
- */
- private String mTag;
- /**
- * A label to be included in every log.
- */
- private String mLabel;
- /**
- * Used to track whether Log.isLoggable was enabled at reset time.
- */
- private boolean mDisabled;
- /**
- * Stores the time of each split.
- */
- ArrayList<Long> mSplits;
- /**
- * Stores the labels for each split.
- */
- ArrayList<String> mSplitLabels;
+ /**
+ * The Log tag to use for checking Log.isLoggable and for
+ * logging the timings.
+ */
+ private String tag;
+ /**
+ * A label to be included in every log.
+ */
+ private String label;
+ /**
+ * Used to track whether Log.isLoggable was enabled at reset time.
+ */
+ private boolean disabled;
+ /**
+ * Stores the time of each split.
+ */
+ private ArrayList<Long> splits;
+ /**
+ * Stores the labels for each split.
+ */
+ private ArrayList<String> splitLabels;
- /**
- * Create and initialize a TimingLogger object that will log using
- * the specific tag. If the Log.isLoggable is not enabled to at
- * least the Log.VERBOSE level for that tag at creation time then
- * the addSplit and dumpToLog call will do nothing.
- *
- * @param tag the log tag to use while logging the timings
- * @param label a string to be displayed with each log
- */
- public TimingLogger(String tag, String label) {
- reset(tag, label);
- }
+ /**
+ * Create and initialize a TimingLogger object that will log using
+ * the specific tag. If the Log.isLoggable is not enabled to at
+ * least the Log.VERBOSE level for that tag at creation time then
+ * the addSplit and dumpToLog call will do nothing.
+ *
+ * @param tag the log tag to use while logging the timings
+ * @param label a string to be displayed with each log
+ */
+ public TimingLogger(String tag, String label) {
+ reset(tag, label);
+ }
- /**
- * Clear and initialize a TimingLogger object that will log using
- * the specific tag. If the Log.isLoggable is not enabled to at
- * least the Log.VERBOSE level for that tag at creation time then
- * the addSplit and dumpToLog call will do nothing.
- *
- * @param tag the log tag to use while logging the timings
- * @param label a string to be displayed with each log
- */
- public void reset(String tag, String label) {
- mTag = tag;
- mLabel = label;
- reset();
- }
+ /**
+ * Clear and initialize a TimingLogger object that will log using
+ * the specific tag. If the Log.isLoggable is not enabled to at
+ * least the Log.VERBOSE level for that tag at creation time then
+ * the addSplit and dumpToLog call will do nothing.
+ *
+ * @param tag the log tag to use while logging the timings
+ * @param label a string to be displayed with each log
+ */
+ public void reset(String tag, String label) {
+ this.tag = tag;
+ this.label = label;
+ reset();
+ }
- /**
- * Clear and initialize a TimingLogger object that will log using
- * the tag and label that was specified previously, either via
- * the constructor or a call to reset(tag, label). If the
- * Log.isLoggable is not enabled to at least the Log.VERBOSE
- * level for that tag at creation time then the addSplit and
- * dumpToLog call will do nothing.
- */
- public void reset() {
- mDisabled = false; //!Log.isLoggable(mTag, Log.VERBOSE);
- if (mDisabled) return;
- if (mSplits == null) {
- mSplits = new ArrayList<Long>();
- mSplitLabels = new ArrayList<String>();
- } else {
- mSplits.clear();
- mSplitLabels.clear();
- }
- addSplit(null);
+ /**
+ * Clear and initialize a TimingLogger object that will log using
+ * the tag and label that was specified previously, either via
+ * the constructor or a call to reset(tag, label). If the
+ * Log.isLoggable is not enabled to at least the Log.VERBOSE
+ * level for that tag at creation time then the addSplit and
+ * dumpToLog call will do nothing.
+ */
+ public void reset() {
+ disabled = false; //!Log.isLoggable(tag, Log.VERBOSE);
+ if (disabled) {
+ return;
+ }
+ if (splits == null) {
+ splits = new ArrayList<Long>();
+ splitLabels = new ArrayList<String>();
+ } else {
+ splits.clear();
+ splitLabels.clear();
}
+ addSplit(null);
+ }
- /**
- * Add a split for the current time, labeled with splitLabel. If
- * Log.isLoggable was not enabled to at least the Log.VERBOSE for
- * the specified tag at construction or reset() time then this
- * call does nothing.
- *
- * @param splitLabel a label to associate with this split.
- */
- public void addSplit(String splitLabel) {
- if (mDisabled) return;
- long now = SystemClock.elapsedRealtime();
- mSplits.add(now);
- mSplitLabels.add(splitLabel);
+ /**
+ * Add a split for the current time, labeled with splitLabel. If
+ * Log.isLoggable was not enabled to at least the Log.VERBOSE for
+ * the specified tag at construction or reset() time then this
+ * call does nothing.
+ *
+ * @param splitLabel a label to associate with this split.
+ */
+ public void addSplit(String splitLabel) {
+ if (disabled) {
+ return;
}
+ long now = SystemClock.elapsedRealtime();
+ splits.add(now);
+ splitLabels.add(splitLabel);
+ }
- /**
- * Dumps the timings to the log using Timber.d(). If Log.isLoggable was
- * not enabled to at least the Log.VERBOSE for the specified tag at
- * construction or reset() time then this call does nothing.
- */
- public void dumpToLog() {
- if (mDisabled) return;
- Timber.d(mLabel + ": begin");
- final long first = mSplits.get(0);
- long now = first;
- for (int i = 1; i < mSplits.size(); i++) {
- now = mSplits.get(i);
- final String splitLabel = mSplitLabels.get(i);
- final long prev = mSplits.get(i - 1);
- Timber.d(mLabel + ": " + (now - prev) + " ms, " + splitLabel);
- }
- Timber.d(mLabel + ": end, " + (now - first) + " ms");
+ /**
+ * Dumps the timings to the log using Timber.d(). If Log.isLoggable was
+ * not enabled to at least the Log.VERBOSE for the specified tag at
+ * construction or reset() time then this call does nothing.
+ */
+ public void dumpToLog() {
+ if (disabled) {
+ return;
+ }
+ Timber.d(label + ": begin");
+ final long first = splits.get(0);
+ long now = first;
+ for (int i = 1; i < splits.size(); i++) {
+ now = splits.get(i);
+ final String splitLabel = splitLabels.get(i);
+ final long prev = splits.get(i - 1);
+ Timber.d(label + ": " + (now - prev) + " ms, " + splitLabel);
}
+ Timber.d(label + ": end, " + (now - first) + " ms");
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java
index 7822e41bd9..3fa3bcd26f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java
@@ -15,35 +15,35 @@ import com.mapbox.mapboxsdk.testapp.R;
public class ToolbarComposer {
- /**
- * Initialises an up navigation toolbar with id R.id.toolbar on an AppCompatActivity.
- *
- * @param activity The activity hosting the Toolbar with id R.id.toolbar
- */
- @Nullable
- public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity) {
- return initDefaultUpToolbar(activity, R.id.toolbar);
- }
-
- /**
- * Initialises an up navigation toolbar given a view id on an AppCompatActivity.
- *
- * @param activity The activity hosting the Toolbar
- * @param toolbarRes The view id resource used to look up the Toolbar
- */
- @Nullable
- public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity, @IdRes int toolbarRes) {
- Toolbar toolbar = (Toolbar) activity.findViewById(toolbarRes);
- if (toolbar != null) {
- activity.setSupportActionBar(toolbar);
-
- ActionBar actionBar = activity.getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- }
- }
- return toolbar;
+ /**
+ * Initialises an up navigation toolbar with id R.id.toolbar on an AppCompatActivity.
+ *
+ * @param activity The activity hosting the Toolbar with id R.id.toolbar
+ */
+ @Nullable
+ public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity) {
+ return initDefaultUpToolbar(activity, R.id.toolbar);
+ }
+
+ /**
+ * Initialises an up navigation toolbar given a view id on an AppCompatActivity.
+ *
+ * @param activity The activity hosting the Toolbar
+ * @param toolbarRes The view id resource used to look up the Toolbar
+ */
+ @Nullable
+ public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity, @IdRes int toolbarRes) {
+ Toolbar toolbar = (Toolbar) activity.findViewById(toolbarRes);
+ if (toolbar != null) {
+ activity.setSupportActionBar(toolbar);
+
+ ActionBar actionBar = activity.getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
}
+ return toolbar;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java
index 76658c242f..611e4f978c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java
@@ -17,75 +17,75 @@ import static org.mockito.Mockito.verify;
public class AnnotationTest {
- @InjectMocks
- private MapboxMap mapboxMap = mock(MapboxMap.class);
- private Annotation annotation;
- private Annotation compare = new Annotation() {
- @Override
- public long getId() {
- return 1;
- }
- };
-
- @Before
- public void beforeTest() {
- annotation = new Annotation() {
- // empty child
- };
+ @InjectMocks
+ private MapboxMap mapboxMap = mock(MapboxMap.class);
+ private Annotation annotation;
+ private Annotation compare = new Annotation() {
+ @Override
+ public long getId() {
+ return 1;
}
+ };
- @Test
- public void testSanity() {
- assertNotNull("markerOptions should not be null", annotation);
- }
+ @Before
+ public void beforeTest() {
+ annotation = new Annotation() {
+ // empty child
+ };
+ }
- @Test
- public void testRemove() {
- annotation.setId(1);
- annotation.setMapboxMap(mapboxMap);
- annotation.remove();
- verify(mapboxMap, times(1)).removeAnnotation(annotation);
- }
+ @Test
+ public void testSanity() {
+ assertNotNull("markerOptions should not be null", annotation);
+ }
- @Test
- public void testRemoveUnboundMapboxMap() {
- annotation.setId(1);
- annotation.remove();
- verify(mapboxMap, times(0)).removeAnnotation(annotation);
- }
+ @Test
+ public void testRemove() {
+ annotation.setId(1);
+ annotation.setMapboxMap(mapboxMap);
+ annotation.remove();
+ verify(mapboxMap, times(1)).removeAnnotation(annotation);
+ }
- @Test
- public void testCompareToEqual() {
- annotation.setId(1);
- assertEquals("conparable equal", 0, annotation.compareTo(compare));
- }
+ @Test
+ public void testRemoveUnboundMapboxMap() {
+ annotation.setId(1);
+ annotation.remove();
+ verify(mapboxMap, times(0)).removeAnnotation(annotation);
+ }
- @Test
- public void testCompareToHigher() {
- annotation.setId(3);
- assertEquals("conparable higher", -1, annotation.compareTo(compare));
- }
+ @Test
+ public void testCompareToEqual() {
+ annotation.setId(1);
+ assertEquals("conparable equal", 0, annotation.compareTo(compare));
+ }
- @Test
- public void testCompareTolower() {
- annotation.setId(0);
- assertEquals("conparable lower", 1, annotation.compareTo(compare));
- }
+ @Test
+ public void testCompareToHigher() {
+ annotation.setId(3);
+ assertEquals("conparable higher", -1, annotation.compareTo(compare));
+ }
- @Test
- public void testEquals() {
- Annotation holder = null;
- assertFalse(annotation.equals(holder));
- holder = annotation;
- assertTrue(annotation.equals(holder));
- assertFalse(annotation.equals(new Object()));
- }
+ @Test
+ public void testCompareTolower() {
+ annotation.setId(0);
+ assertEquals("conparable lower", 1, annotation.compareTo(compare));
+ }
- @Test
- public void testHashcode() {
- int id = 1;
- annotation.setId(id);
- assertSame("hashcode should match", annotation.hashCode(), id);
- }
+ @Test
+ public void testEquals() {
+ Annotation holder = null;
+ assertFalse(annotation.equals(holder));
+ holder = annotation;
+ assertTrue(annotation.equals(holder));
+ assertFalse(annotation.equals(new Object()));
+ }
+
+ @Test
+ public void testHashcode() {
+ int id = 1;
+ annotation.setId(id);
+ assertSame("hashcode should match", annotation.hashCode(), id);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
index 9e95451cb1..5f6f6b6c6d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
@@ -12,44 +12,44 @@ import static junit.framework.Assert.assertNotSame;
public class IconTest {
- @Mock
- Bitmap mBitmap;
-
- @Before
- public void beforeTest() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testId() {
- String id = "test";
- Icon icon = IconFactory.recreate(id, Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
- assertEquals("id should match", id, icon.getId());
- }
-
- @Test
- public void testBitmap() {
- Icon icon = IconFactory.recreate("test", mBitmap);
- assertEquals("bitmap should match", mBitmap, icon.getBitmap());
- }
-
- @Test
- public void testEquals() {
- Icon icon1 = IconFactory.recreate("test", mBitmap);
- Icon icon2 = IconFactory.recreate("test", mBitmap);
- assertEquals("icons should not match", icon1, icon2);
- }
-
- @Test
- public void testEqualsObject() {
- Icon icon = IconFactory.recreate("test", Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
- assertNotSame("icon should not match", new Object(), icon);
- }
-
- @Test
- public void testHashcode() {
- Icon icon = IconFactory.recreate("test", mBitmap);
- long expectedHashcode = 31 * mBitmap.hashCode() + "test".hashCode();
- assertEquals("hashcode should match", expectedHashcode, icon.hashCode());
- }
+ @Mock
+ Bitmap bitmap;
+
+ @Before
+ public void beforeTest() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testId() {
+ String id = "test";
+ Icon icon = IconFactory.recreate(id, Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
+ assertEquals("id should match", id, icon.getId());
+ }
+
+ @Test
+ public void testBitmap() {
+ Icon icon = IconFactory.recreate("test", bitmap);
+ assertEquals("bitmap should match", bitmap, icon.getBitmap());
+ }
+
+ @Test
+ public void testEquals() {
+ Icon icon1 = IconFactory.recreate("test", bitmap);
+ Icon icon2 = IconFactory.recreate("test", bitmap);
+ assertEquals("icons should not match", icon1, icon2);
+ }
+
+ @Test
+ public void testEqualsObject() {
+ Icon icon = IconFactory.recreate("test", Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
+ assertNotSame("icon should not match", new Object(), icon);
+ }
+
+ @Test
+ public void testHashcode() {
+ Icon icon = IconFactory.recreate("test", bitmap);
+ long expectedHashcode = 31 * bitmap.hashCode() + "test".hashCode();
+ assertEquals("hashcode should match", expectedHashcode, icon.hashCode());
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java
index 1398f40009..94b629860e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java
@@ -17,70 +17,70 @@ import static org.mockito.Mockito.when;
public class InfoWindowTest {
- @InjectMocks
- MapView mMapView = mock(MapView.class);
-
- @InjectMocks
- MapboxMap mMapboxMap = mock(MapboxMap.class);
-
- @Test
- public void testSanity() {
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- assertNotNull("infoWindow should exist", infoWindow);
- }
-
- @Test
- public void testBoundMarker() {
- MarkerOptions markerOptions = new MarkerOptions();
- Marker marker = markerOptions.position(new LatLng()).getMarker();
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap).setBoundMarker(marker);
- assertEquals("marker should match", marker, infoWindow.getBoundMarker());
- }
-
- @Test
- public void testClose() {
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.close();
- assertEquals("infowindow should not be visible", false, infoWindow.isVisible());
- }
-
-
- @Test
- public void testOpen() {
- LatLng latLng = new LatLng(0, 0);
- Projection projection = mock(Projection.class);
- when(mMapboxMap.getProjection()).thenReturn(projection);
- when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
-
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.open(mMapView, new MarkerOptions().position(new LatLng()).getMarker(), latLng, 0, 0);
- assertEquals("infowindow should not be visible", true, infoWindow.isVisible());
- }
-
- @Test
- public void testOpenClose() {
- LatLng latLng = new LatLng(0, 0);
- Projection projection = mock(Projection.class);
- when(mMapboxMap.getProjection()).thenReturn(projection);
- when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
-
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.open(mMapView, new MarkerOptions().position(new LatLng()).getMarker(), latLng, 0, 0);
- infoWindow.close();
- assertEquals("infowindow should not be visible", false, infoWindow.isVisible());
- }
-
-
- @Test
- public void testUpdate() {
- LatLng latLng = new LatLng(0, 0);
- Projection projection = mock(Projection.class);
- when(mMapboxMap.getProjection()).thenReturn(projection);
- when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
-
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.open(mMapView, new MarkerOptions().position(latLng).getMarker(), latLng, 0, 0);
- infoWindow.update();
- }
+ @InjectMocks
+ MapView mMapView = mock(MapView.class);
+
+ @InjectMocks
+ MapboxMap mMapboxMap = mock(MapboxMap.class);
+
+ @Test
+ public void testSanity() {
+ InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
+ assertNotNull("infoWindow should exist", infoWindow);
+ }
+
+ @Test
+ public void testBoundMarker() {
+ MarkerOptions markerOptions = new MarkerOptions();
+ Marker marker = markerOptions.position(new LatLng()).getMarker();
+ InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap).setBoundMarker(marker);
+ assertEquals("marker should match", marker, infoWindow.getBoundMarker());
+ }
+
+ @Test
+ public void testClose() {
+ InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
+ infoWindow.close();
+ assertEquals("infowindow should not be visible", false, infoWindow.isVisible());
+ }
+
+
+ @Test
+ public void testOpen() {
+ LatLng latLng = new LatLng(0, 0);
+ Projection projection = mock(Projection.class);
+ when(mMapboxMap.getProjection()).thenReturn(projection);
+ when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
+
+ InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
+ infoWindow.open(mMapView, new MarkerOptions().position(new LatLng()).getMarker(), latLng, 0, 0);
+ assertEquals("infowindow should not be visible", true, infoWindow.isVisible());
+ }
+
+ @Test
+ public void testOpenClose() {
+ LatLng latLng = new LatLng(0, 0);
+ Projection projection = mock(Projection.class);
+ when(mMapboxMap.getProjection()).thenReturn(projection);
+ when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
+
+ InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
+ infoWindow.open(mMapView, new MarkerOptions().position(new LatLng()).getMarker(), latLng, 0, 0);
+ infoWindow.close();
+ assertEquals("infowindow should not be visible", false, infoWindow.isVisible());
+ }
+
+
+ @Test
+ public void testUpdate() {
+ LatLng latLng = new LatLng(0, 0);
+ Projection projection = mock(Projection.class);
+ when(mMapboxMap.getProjection()).thenReturn(projection);
+ when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
+
+ InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
+ infoWindow.open(mMapView, new MarkerOptions().position(latLng).getMarker(), latLng, 0, 0);
+ infoWindow.update();
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java
index c4c294fb98..fa571e06b1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java
@@ -16,145 +16,145 @@ import static org.mockito.Mockito.mock;
public class MarkerTest {
- @Test
- public void testSanity() {
- MarkerOptions markerOptions = new MarkerOptions();
- assertNotNull("markerOptions should not be null", markerOptions);
- }
-
- @Test
- public void testMarker() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- assertNotNull("marker should not be null", markerOptions.getMarker());
- }
-
- @Test(expected = InvalidMarkerPositionException.class)
- public void testInvalidMarker(){
- new MarkerOptions().getMarker();
- }
-
- @Test
- public void testPosition() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
- Marker marker = markerOptions.getMarker();
- assertEquals(marker.getPosition(), new LatLng(10, 12));
- assertEquals(markerOptions.getPosition(), new LatLng(10, 12));
- }
-
- @Test
- public void testTitle() {
- MarkerOptions markerOptions = new MarkerOptions().title("Mapbox").position(new LatLng());
- Marker marker = markerOptions.getMarker();
- assertEquals(marker.getTitle(), "Mapbox");
- assertEquals(markerOptions.getTitle(), "Mapbox");
- }
-
- @Test
- public void testSnippet() {
- MarkerOptions markerOptions = new MarkerOptions().snippet("Mapbox").position(new LatLng());
- Marker marker = markerOptions.getMarker();
- assertEquals(marker.getSnippet(), "Mapbox");
- }
-
- @Test
- public void testBuilder() {
- Marker marker = new MarkerOptions().title("title").snippet("snippet").position(new LatLng(10, 12)).getMarker();
- assertEquals(marker.getSnippet(), "snippet");
-
- assertEquals(marker.getPosition(), new LatLng(10, 12));
- }
-
- @Test
- public void testIcon() {
- Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
- Icon icon = IconFactory.recreate("test", bitmap);
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()).icon(icon);
- Marker marker = markerOptions.getMarker();
- assertEquals("Icon should match", icon, marker.getIcon());
- assertEquals("Icon should match", icon, markerOptions.getIcon());
- }
-
- @Test
- public void testHashCode() {
- Marker marker = new MarkerOptions().position(new LatLng()).getMarker();
- assertEquals("hash code should match", marker.hashCode(), 0);
- }
-
- @Test
- public void testHashCodeBuilder() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
- assertEquals("hash code should match", markerOptions.hashCode(), 579999617);
- }
-
- @Test
- public void testEquals() {
- Marker markerOne = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
- Marker markerTwo = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
- assertEquals(markerOne, markerTwo);
- }
-
- @Test
- public void testEqualityDifferentLocation() {
- MarkerOptions marker = new MarkerOptions().position(new LatLng(0, 0));
- MarkerOptions other = new MarkerOptions().position(new LatLng(1, 0));
- assertNotEquals("Should not match", other, marker);
- }
-
-
- @Test
- public void testEqualityDifferentSnippet() {
- MarkerOptions marker = new MarkerOptions().snippet("s");
- MarkerOptions other = new MarkerOptions();
- assertNotEquals("Should not match", other, marker);
- }
-
- @Test
- public void testEqualityDifferentIcon() {
- MarkerOptions marker = new MarkerOptions().icon(mock(Icon.class));
- MarkerOptions other = new MarkerOptions();
- assertNotEquals("Should not match", other, marker);
- }
-
- @Test
- public void testEqualityDifferentTitle() {
- MarkerOptions marker = new MarkerOptions().title("t");
- MarkerOptions other = new MarkerOptions();
- assertNotEquals("Should not match", other, marker);
- }
-
- @Test
- public void testEqualsItself() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
- Marker marker = markerOptions.getMarker();
- assertEquals("Marker should match", marker, marker);
- assertEquals("MarkerOptions should match", markerOptions, markerOptions);
- }
-
- @Test
- public void testNotEquals() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
- Marker marker = markerOptions.getMarker();
- assertNotEquals("MarkerOptions should match", markerOptions, new Object());
- assertNotEquals("Marker should match", marker, new Object());
- }
-
- @Test
- public void testEqualityBuilder() {
- MarkerOptions markerOne = new MarkerOptions().position(new LatLng(0, 0));
- MarkerOptions markerTwo = new MarkerOptions().position(new LatLng(0, 0));
- assertEquals(markerOne, markerTwo);
- }
-
- @Test
- public void testToString() {
- Marker marker = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
- assertEquals(marker.toString(), "Marker [position[" + "LatLng [latitude=0.0, longitude=0.0, altitude=0.0]" + "]]");
- }
-
- @Test
- public void testParcelable() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()).title("t").snippet("s");
- Parcelable parcelable = MockParcel.obtain(markerOptions);
- assertEquals("Parcel should match original object", parcelable, markerOptions);
- }
+ @Test
+ public void testSanity() {
+ MarkerOptions markerOptions = new MarkerOptions();
+ assertNotNull("markerOptions should not be null", markerOptions);
+ }
+
+ @Test
+ public void testMarker() {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
+ assertNotNull("marker should not be null", markerOptions.getMarker());
+ }
+
+ @Test(expected = InvalidMarkerPositionException.class)
+ public void testInvalidMarker() {
+ new MarkerOptions().getMarker();
+ }
+
+ @Test
+ public void testPosition() {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
+ Marker marker = markerOptions.getMarker();
+ assertEquals(marker.getPosition(), new LatLng(10, 12));
+ assertEquals(markerOptions.getPosition(), new LatLng(10, 12));
+ }
+
+ @Test
+ public void testTitle() {
+ MarkerOptions markerOptions = new MarkerOptions().title("Mapbox").position(new LatLng());
+ Marker marker = markerOptions.getMarker();
+ assertEquals(marker.getTitle(), "Mapbox");
+ assertEquals(markerOptions.getTitle(), "Mapbox");
+ }
+
+ @Test
+ public void testSnippet() {
+ MarkerOptions markerOptions = new MarkerOptions().snippet("Mapbox").position(new LatLng());
+ Marker marker = markerOptions.getMarker();
+ assertEquals(marker.getSnippet(), "Mapbox");
+ }
+
+ @Test
+ public void testBuilder() {
+ Marker marker = new MarkerOptions().title("title").snippet("snippet").position(new LatLng(10, 12)).getMarker();
+ assertEquals(marker.getSnippet(), "snippet");
+
+ assertEquals(marker.getPosition(), new LatLng(10, 12));
+ }
+
+ @Test
+ public void testIcon() {
+ Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
+ Icon icon = IconFactory.recreate("test", bitmap);
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()).icon(icon);
+ Marker marker = markerOptions.getMarker();
+ assertEquals("Icon should match", icon, marker.getIcon());
+ assertEquals("Icon should match", icon, markerOptions.getIcon());
+ }
+
+ @Test
+ public void testHashCode() {
+ Marker marker = new MarkerOptions().position(new LatLng()).getMarker();
+ assertEquals("hash code should match", marker.hashCode(), 0);
+ }
+
+ @Test
+ public void testHashCodeBuilder() {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
+ assertEquals("hash code should match", markerOptions.hashCode(), 579999617);
+ }
+
+ @Test
+ public void testEquals() {
+ Marker markerOne = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
+ Marker markerTwo = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
+ assertEquals(markerOne, markerTwo);
+ }
+
+ @Test
+ public void testEqualityDifferentLocation() {
+ MarkerOptions marker = new MarkerOptions().position(new LatLng(0, 0));
+ MarkerOptions other = new MarkerOptions().position(new LatLng(1, 0));
+ assertNotEquals("Should not match", other, marker);
+ }
+
+
+ @Test
+ public void testEqualityDifferentSnippet() {
+ MarkerOptions marker = new MarkerOptions().snippet("s");
+ MarkerOptions other = new MarkerOptions();
+ assertNotEquals("Should not match", other, marker);
+ }
+
+ @Test
+ public void testEqualityDifferentIcon() {
+ MarkerOptions marker = new MarkerOptions().icon(mock(Icon.class));
+ MarkerOptions other = new MarkerOptions();
+ assertNotEquals("Should not match", other, marker);
+ }
+
+ @Test
+ public void testEqualityDifferentTitle() {
+ MarkerOptions marker = new MarkerOptions().title("t");
+ MarkerOptions other = new MarkerOptions();
+ assertNotEquals("Should not match", other, marker);
+ }
+
+ @Test
+ public void testEqualsItself() {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
+ Marker marker = markerOptions.getMarker();
+ assertEquals("Marker should match", marker, marker);
+ assertEquals("MarkerOptions should match", markerOptions, markerOptions);
+ }
+
+ @Test
+ public void testNotEquals() {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
+ Marker marker = markerOptions.getMarker();
+ assertNotEquals("MarkerOptions should match", markerOptions, new Object());
+ assertNotEquals("Marker should match", marker, new Object());
+ }
+
+ @Test
+ public void testEqualityBuilder() {
+ MarkerOptions markerOne = new MarkerOptions().position(new LatLng(0, 0));
+ MarkerOptions markerTwo = new MarkerOptions().position(new LatLng(0, 0));
+ assertEquals(markerOne, markerTwo);
+ }
+
+ @Test
+ public void testToString() {
+ Marker marker = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
+ assertEquals(marker.toString(), "Marker [position[" + "LatLng [latitude=0.0, longitude=0.0, altitude=0.0]" + "]]");
+ }
+
+ @Test
+ public void testParcelable() {
+ MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()).title("t").snippet("s");
+ Parcelable parcelable = MockParcel.obtain(markerOptions);
+ assertEquals("Parcel should match original object", parcelable, markerOptions);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
index eaeae78abb..3c52c16422 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
@@ -23,261 +23,264 @@ import static org.mockito.Mockito.when;
public class MarkerViewTest {
- @Mock
- MapboxMap mapboxMap;
-
- @Mock
- MarkerViewManager markerViewManager;
-
- @Before
- public void beforeTest() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testSanity() {
- MarkerViewOptions markerOptions = new MarkerViewOptions();
- assertNotNull("markerOptions should not be null", markerOptions);
- }
-
- @Test
- public void testMarker() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng());
- assertNotNull("marker should not be null", markerOptions.getMarker());
- }
-
- @Test(expected = InvalidMarkerPositionException.class)
- public void testInvalidMarker() {
- new MarkerViewOptions().getMarker();
- }
-
- @Test
- public void testPosition() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(10, 12));
- MarkerView marker = markerOptions.getMarker();
- assertEquals(marker.getPosition(), new LatLng(10, 12));
- assertEquals(markerOptions.getPosition(), new LatLng(10, 12));
- }
-
- @Test
- public void testSnippet() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().snippet("Mapbox").position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertEquals(marker.getSnippet(), "Mapbox");
- }
-
- @Test
- public void testTitle() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().title("Mapbox").position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertEquals(marker.getTitle(), "Mapbox");
- assertEquals(markerOptions.getTitle(), "Mapbox");
- }
-
- @Test
- public void testFlat() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().flat(true).position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertTrue("flat should be true", marker.isFlat());
- }
-
- @Test
- public void testFlatDefault() {
- assertFalse("default value of flat should be false", new MarkerViewOptions().position(new LatLng()).getMarker().isFlat());
- }
-
- @Test
- public void testAnchor() {
- float anchorU = 1;
- float anchorV = 1;
- MarkerViewOptions markerOptions = new MarkerViewOptions().anchor(anchorU, anchorV).position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertEquals("anchorU should match ", anchorU, marker.getAnchorU(), 0);
- assertEquals("anchorU should match ", anchorV, marker.getAnchorV(), 0);
- }
-
- @Test
- public void testAnchorDefault() {
- MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker();
- assertEquals("anchorU should match ", 0.5, marker.getAnchorU(), 0);
- assertEquals("anchorU should match ", 1, marker.getAnchorV(), 0);
- }
-
- @Test
- public void testInfoWindowAnchor() {
- float anchorU = 1;
- float anchorV = 1;
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).infoWindowAnchor(anchorU, anchorV);
- MarkerView marker = markerOptions.getMarker();
- assertEquals("anchorU should match ", 1, marker.getInfoWindowAnchorU(), 0);
- assertEquals("anchorU should match ", 1, marker.getInfoWindowAnchorV(), 0);
- }
-
- @Test
- public void testInfoWindowAnchorDefault() {
- MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker();
- assertEquals("anchorU should match ", 0.5, marker.getInfoWindowAnchorU(), 0);
- assertEquals("anchorU should match ", 0, marker.getInfoWindowAnchorV(), 0);
- }
-
- @Test
- public void testRotation() {
- int rotation = 90;
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(rotation);
- MarkerView marker = markerOptions.getMarker();
- assertEquals("rotation should match ", rotation, marker.getRotation(), 0);
- }
-
- @Test
- public void testRotationAboveMax() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(390).position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertEquals(marker.getRotation(), 30, 0);
- }
-
- @Test
- public void testRotationBelowMin() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(-10).position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertEquals(marker.getRotation(), 350, 0);
- }
-
- @Test
- public void testRotationUpdatePositive() {
- float startRotation = 45;
- float endRotation = 180;
-
- // allow calls to our mock
- when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
-
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
- MarkerView marker = markerOptions.getMarker();
- marker.setMapboxMap(mapboxMap);
-
- marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
- }
-
- @Test
- public void testRotationUpdateNegative() {
- float startRotation = 10;
- float endRotation = 270;
-
- // allow calls to our mock
- when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
-
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
- MarkerView marker = markerOptions.getMarker();
- marker.setMapboxMap(mapboxMap);
-
- marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
- }
-
- @Test
- public void testRotationUpdateMax() {
- float startRotation = 359;
- float endRotation = 0;
-
- // allow calls to our mock
- when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
-
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
- MarkerView marker = markerOptions.getMarker();
- marker.setMapboxMap(mapboxMap);
-
- marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, 0);
- }
-
- @Test
- public void testRotationUpdateMin() {
- float startRotation = 0;
- float endRotation = 359;
-
- // allow calls to our mock
- when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
-
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
- MarkerView marker = markerOptions.getMarker();
- marker.setMapboxMap(mapboxMap);
-
- marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
- }
-
- @Test
- public void testVisible() {
- boolean visible = false;
- MarkerViewOptions markerOptions = new MarkerViewOptions().visible(visible).position(new LatLng());
- MarkerView marker = markerOptions.getMarker();
- assertEquals("visible should match ", visible, marker.isVisible());
- }
-
- @Test
- public void testVisibleDefault() {
- assertTrue(new MarkerViewOptions().position(new LatLng()).getMarker().isVisible());
- }
-
- @Test
- public void testBuilder() {
- MarkerView marker = new MarkerViewOptions().title("title").snippet("snippet").position(new LatLng(10, 12)).getMarker();
- assertEquals(marker.getSnippet(), "snippet");
- assertEquals(marker.getPosition(), new LatLng(10, 12));
- }
-
- @Test
- public void testHashCode() {
- MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker();
- assertEquals("hash code should match", marker.hashCode(), 0);
- }
-
- @Test
- public void testHashCodeBuilder() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(10, 12));
- assertEquals("hash code should match", markerOptions.hashCode(), 0);
- }
-
- @Test
- public void testEquals() {
- MarkerView markerOne = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker();
- MarkerView markerTwo = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker();
- assertEquals(markerOne, markerTwo);
- }
-
- @Test
- public void testEqualsItself() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(0, 0));
- MarkerView marker = markerOptions.getMarker();
- assertEquals("MarkerView should match", marker, marker);
- assertEquals("MarkerViewOptions should match", markerOptions, markerOptions);
- }
-
- @Test
- public void testNotEquals() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(0, 0));
- MarkerView marker = markerOptions.getMarker();
- assertNotEquals("MarkerViewOptions should match", markerOptions, new Object());
- assertNotEquals("MarkerView should match", marker, new Object());
- }
-
- @Test
- public void testEqualityBuilder() {
- MarkerViewOptions markerOne = new MarkerViewOptions().position(new LatLng(0, 0));
- MarkerViewOptions markerTwo = new MarkerViewOptions().position(new LatLng(0, 0));
- assertEquals(markerOne, markerTwo);
- }
-
- @Test
- public void testToString() {
- MarkerView marker = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker();
- assertEquals(marker.toString(), "MarkerView [position[" + "LatLng [latitude=0.0, longitude=0.0, altitude=0.0]" + "]]");
- }
-
- @Test
- public void testParcelable() {
- MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).title("t").snippet("s");
- Parcelable parcelable = MockParcel.obtain(markerOptions);
- assertEquals("Parcel should match original object", parcelable, markerOptions);
- }
+ @Mock
+ MapboxMap mapboxMap;
+
+ @Mock
+ MarkerViewManager markerViewManager;
+
+ @Before
+ public void beforeTest() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testSanity() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions();
+ assertNotNull("markerOptions should not be null", markerOptions);
+ }
+
+ @Test
+ public void testMarker() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng());
+ assertNotNull("marker should not be null", markerOptions.getMarker());
+ }
+
+ @Test(expected = InvalidMarkerPositionException.class)
+ public void testInvalidMarker() {
+ new MarkerViewOptions().getMarker();
+ }
+
+ @Test
+ public void testPosition() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(10, 12));
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getPosition(), new LatLng(10, 12));
+ assertEquals(markerOptions.getPosition(), new LatLng(10, 12));
+ }
+
+ @Test
+ public void testSnippet() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().snippet("Mapbox").position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getSnippet(), "Mapbox");
+ }
+
+ @Test
+ public void testTitle() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().title("Mapbox").position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getTitle(), "Mapbox");
+ assertEquals(markerOptions.getTitle(), "Mapbox");
+ }
+
+ @Test
+ public void testFlat() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().flat(true).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertTrue("flat should be true", marker.isFlat());
+ }
+
+ @Test
+ public void testFlatDefault() {
+ assertFalse("default value of flat should be false", new MarkerViewOptions().position(
+ new LatLng()).getMarker().isFlat());
+ }
+
+ @Test
+ public void testAnchor() {
+ float anchorU = 1;
+ float anchorV = 1;
+ MarkerViewOptions markerOptions = new MarkerViewOptions().anchor(anchorU, anchorV).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals("anchorU should match ", anchorU, marker.getAnchorU(), 0);
+ assertEquals("anchorU should match ", anchorV, marker.getAnchorV(), 0);
+ }
+
+ @Test
+ public void testAnchorDefault() {
+ MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker();
+ assertEquals("anchorU should match ", 0.5, marker.getAnchorU(), 0);
+ assertEquals("anchorU should match ", 1, marker.getAnchorV(), 0);
+ }
+
+ @Test
+ public void testInfoWindowAnchor() {
+ float anchorU = 1;
+ float anchorV = 1;
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).infoWindowAnchor(anchorU, anchorV);
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals("anchorU should match ", 1, marker.getInfoWindowAnchorU(), 0);
+ assertEquals("anchorU should match ", 1, marker.getInfoWindowAnchorV(), 0);
+ }
+
+ @Test
+ public void testInfoWindowAnchorDefault() {
+ MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker();
+ assertEquals("anchorU should match ", 0.5, marker.getInfoWindowAnchorU(), 0);
+ assertEquals("anchorU should match ", 0, marker.getInfoWindowAnchorV(), 0);
+ }
+
+ @Test
+ public void testRotation() {
+ int rotation = 90;
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(rotation);
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals("rotation should match ", rotation, marker.getRotation(), 0);
+ }
+
+ @Test
+ public void testRotationAboveMax() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(390).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getRotation(), 30, 0);
+ }
+
+ @Test
+ public void testRotationBelowMin() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(-10).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getRotation(), 350, 0);
+ }
+
+ @Test
+ public void testRotationUpdatePositive() {
+ float startRotation = 45;
+ float endRotation = 180;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
+ }
+
+ @Test
+ public void testRotationUpdateNegative() {
+ float startRotation = 10;
+ float endRotation = 270;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
+ }
+
+ @Test
+ public void testRotationUpdateMax() {
+ float startRotation = 359;
+ float endRotation = 0;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, 0);
+ }
+
+ @Test
+ public void testRotationUpdateMin() {
+ float startRotation = 0;
+ float endRotation = 359;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
+ }
+
+ @Test
+ public void testVisible() {
+ boolean visible = false;
+ MarkerViewOptions markerOptions = new MarkerViewOptions().visible(visible).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals("visible should match ", visible, marker.isVisible());
+ }
+
+ @Test
+ public void testVisibleDefault() {
+ assertTrue(new MarkerViewOptions().position(new LatLng()).getMarker().isVisible());
+ }
+
+ @Test
+ public void testBuilder() {
+ MarkerView marker = new MarkerViewOptions().title("title").snippet("snippet").position(
+ new LatLng(10, 12)).getMarker();
+ assertEquals(marker.getSnippet(), "snippet");
+ assertEquals(marker.getPosition(), new LatLng(10, 12));
+ }
+
+ @Test
+ public void testHashCode() {
+ MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker();
+ assertEquals("hash code should match", marker.hashCode(), 0);
+ }
+
+ @Test
+ public void testHashCodeBuilder() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(10, 12));
+ assertEquals("hash code should match", markerOptions.hashCode(), 0);
+ }
+
+ @Test
+ public void testEquals() {
+ MarkerView markerOne = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker();
+ MarkerView markerTwo = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker();
+ assertEquals(markerOne, markerTwo);
+ }
+
+ @Test
+ public void testEqualsItself() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(0, 0));
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals("MarkerView should match", marker, marker);
+ assertEquals("MarkerViewOptions should match", markerOptions, markerOptions);
+ }
+
+ @Test
+ public void testNotEquals() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(0, 0));
+ MarkerView marker = markerOptions.getMarker();
+ assertNotEquals("MarkerViewOptions should match", markerOptions, new Object());
+ assertNotEquals("MarkerView should match", marker, new Object());
+ }
+
+ @Test
+ public void testEqualityBuilder() {
+ MarkerViewOptions markerOne = new MarkerViewOptions().position(new LatLng(0, 0));
+ MarkerViewOptions markerTwo = new MarkerViewOptions().position(new LatLng(0, 0));
+ assertEquals(markerOne, markerTwo);
+ }
+
+ @Test
+ public void testToString() {
+ MarkerView marker = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker();
+ assertEquals(marker.toString(), "MarkerView [position["
+ + "LatLng [latitude=0.0, longitude=0.0, altitude=0.0]" + "]]");
+ }
+
+ @Test
+ public void testParcelable() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).title("t").snippet("s");
+ Parcelable parcelable = MockParcel.obtain(markerOptions);
+ assertEquals("Parcel should match original object", parcelable, markerOptions);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java
index 744bf55c07..3933c68887 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java
@@ -1,9 +1,5 @@
package com.mapbox.mapboxsdk.annotations;
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.PolygonOptions;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
@@ -16,64 +12,64 @@ import static org.junit.Assert.assertNotNull;
public class PolygonTest {
- @Test
- public void testSanity() {
- PolygonOptions polygonOptions = new PolygonOptions();
- assertNotNull("polygonOptions should not be null", polygonOptions);
- }
+ @Test
+ public void testSanity() {
+ PolygonOptions polygonOptions = new PolygonOptions();
+ assertNotNull("polygonOptions should not be null", polygonOptions);
+ }
- @Test
- public void testPolygon() {
- Polygon polygon = new PolygonOptions().getPolygon();
- assertNotNull("polyline should not be null", polygon);
- }
+ @Test
+ public void testPolygon() {
+ Polygon polygon = new PolygonOptions().getPolygon();
+ assertNotNull("polyline should not be null", polygon);
+ }
- @Test
- public void testAlpha() {
- Polygon polygon = new PolygonOptions().alpha(0.5f).getPolygon();
- assertEquals(0.5f, polygon.getAlpha(), 0.0f);
- }
+ @Test
+ public void testAlpha() {
+ Polygon polygon = new PolygonOptions().alpha(0.5f).getPolygon();
+ assertEquals(0.5f, polygon.getAlpha(), 0.0f);
+ }
- @Test
- public void testStrokeColor() {
- Polygon polygon = new PolygonOptions().strokeColor(1).getPolygon();
- assertEquals(1, polygon.getStrokeColor());
- }
+ @Test
+ public void testStrokeColor() {
+ Polygon polygon = new PolygonOptions().strokeColor(1).getPolygon();
+ assertEquals(1, polygon.getStrokeColor());
+ }
- @Test
- public void testFillColor() {
- Polygon polygon = new PolygonOptions().fillColor(1).getPolygon();
- assertEquals(1, polygon.getFillColor());
- }
+ @Test
+ public void testFillColor() {
+ Polygon polygon = new PolygonOptions().fillColor(1).getPolygon();
+ assertEquals(1, polygon.getFillColor());
+ }
- @Test
- public void testLatLng() {
- Polygon polygon = new PolygonOptions().add(new LatLng(0, 0)).getPolygon();
- assertNotNull("points should not be null", polygon.getPoints());
- assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
- }
+ @Test
+ public void testLatLng() {
+ Polygon polygon = new PolygonOptions().add(new LatLng(0, 0)).getPolygon();
+ assertNotNull("points should not be null", polygon.getPoints());
+ assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
+ }
- @Test
- public void testAddAllLatLng() {
- List<LatLng> coordinates = new ArrayList<>();
- coordinates.add(new LatLng(0, 0));
- Polygon polygon = new PolygonOptions().addAll(coordinates).getPolygon();
- assertNotNull(polygon.getPoints());
- assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
- }
+ @Test
+ public void testAddAllLatLng() {
+ List<LatLng> coordinates = new ArrayList<>();
+ coordinates.add(new LatLng(0, 0));
+ Polygon polygon = new PolygonOptions().addAll(coordinates).getPolygon();
+ assertNotNull(polygon.getPoints());
+ assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
+ }
- @Test
- public void testBuilder() {
- PolylineOptions polylineOptions = new PolylineOptions();
- polylineOptions.width(1.0f);
- polylineOptions.color(2);
- polylineOptions.add(new LatLng(0, 0));
+ @Test
+ public void testBuilder() {
+ PolylineOptions polylineOptions = new PolylineOptions();
+ polylineOptions.width(1.0f);
+ polylineOptions.color(2);
+ polylineOptions.add(new LatLng(0, 0));
- Polyline polyline = polylineOptions.getPolyline();
- assertEquals(1.0f, polyline.getWidth(), 0);
- assertEquals(2, polyline.getColor());
- assertNotNull("Points should not be null", polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
+ Polyline polyline = polylineOptions.getPolyline();
+ assertEquals(1.0f, polyline.getWidth(), 0);
+ assertEquals(2, polyline.getColor());
+ assertNotNull("Points should not be null", polyline.getPoints());
+ assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java
index b95c9dba2a..54bb0e8cf4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java
@@ -1,7 +1,5 @@
package com.mapbox.mapboxsdk.annotations;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
@@ -14,64 +12,64 @@ import static org.junit.Assert.assertNotNull;
public class PolylineTest {
- @Test
- public void testSanity() {
- PolylineOptions polylineOptions = new PolylineOptions();
- assertNotNull("polylineOptions should not be null", polylineOptions);
- }
+ @Test
+ public void testSanity() {
+ PolylineOptions polylineOptions = new PolylineOptions();
+ assertNotNull("polylineOptions should not be null", polylineOptions);
+ }
- @Test
- public void testPolyline() {
- Polyline polyline = new PolylineOptions().getPolyline();
- assertNotNull("polyline should not be null", polyline);
- }
+ @Test
+ public void testPolyline() {
+ Polyline polyline = new PolylineOptions().getPolyline();
+ assertNotNull("polyline should not be null", polyline);
+ }
- @Test
- public void testAlpha() {
- Polyline polyline = new PolylineOptions().alpha(0.2f).getPolyline();
- assertEquals(0.2f, polyline.getAlpha(), 0.0f);
- }
+ @Test
+ public void testAlpha() {
+ Polyline polyline = new PolylineOptions().alpha(0.2f).getPolyline();
+ assertEquals(0.2f, polyline.getAlpha(), 0.0f);
+ }
- @Test
- public void testWidth() {
- Polyline polyline = new PolylineOptions().width(1).getPolyline();
- assertEquals(1.0f, polyline.getWidth(), 0);
- }
+ @Test
+ public void testWidth() {
+ Polyline polyline = new PolylineOptions().width(1).getPolyline();
+ assertEquals(1.0f, polyline.getWidth(), 0);
+ }
- @Test
- public void testColor() {
- Polyline polyline = new PolylineOptions().color(1).getPolyline();
- assertEquals(1, polyline.getColor());
- }
+ @Test
+ public void testColor() {
+ Polyline polyline = new PolylineOptions().color(1).getPolyline();
+ assertEquals(1, polyline.getColor());
+ }
- @Test
- public void testAddLatLng() {
- Polyline polyline = new PolylineOptions().add(new LatLng(0, 0)).getPolyline();
- assertNotNull("Points should not be null", polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
+ @Test
+ public void testAddLatLng() {
+ Polyline polyline = new PolylineOptions().add(new LatLng(0, 0)).getPolyline();
+ assertNotNull("Points should not be null", polyline.getPoints());
+ assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
+ }
- @Test
- public void testAddAllLatLng() {
- List<LatLng> coordinates = new ArrayList<>();
- coordinates.add(new LatLng(0, 0));
- Polyline polyline = new PolylineOptions().addAll(coordinates).getPolyline();
- assertNotNull(polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
+ @Test
+ public void testAddAllLatLng() {
+ List<LatLng> coordinates = new ArrayList<>();
+ coordinates.add(new LatLng(0, 0));
+ Polyline polyline = new PolylineOptions().addAll(coordinates).getPolyline();
+ assertNotNull(polyline.getPoints());
+ assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
+ }
- @Test
- public void testBuilder() {
- PolylineOptions polylineOptions = new PolylineOptions();
- polylineOptions.width(1.0f);
- polylineOptions.color(2);
- polylineOptions.add(new LatLng(0, 0));
+ @Test
+ public void testBuilder() {
+ PolylineOptions polylineOptions = new PolylineOptions();
+ polylineOptions.width(1.0f);
+ polylineOptions.color(2);
+ polylineOptions.add(new LatLng(0, 0));
- Polyline polyline = polylineOptions.getPolyline();
- assertEquals(1.0f, polyline.getWidth(), 0);
- assertEquals(2, polyline.getColor());
- assertNotNull("Points should not be null", polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
+ Polyline polyline = polylineOptions.getPolyline();
+ assertEquals(1.0f, polyline.getWidth(), 0);
+ assertEquals(2, polyline.getColor());
+ assertNotNull("Points should not be null", polyline.getPoints());
+ assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java
index 71931c1467..a8aad8d639 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java
@@ -18,108 +18,109 @@ import static org.mockito.Mockito.when;
public class CameraPositionTest {
- private static final double DELTA = 1e-15;
-
- @Test
- public void testSanity() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
- assertNotNull("cameraPosition should not be null", cameraPosition);
- }
-
- @Test
- public void testDefaultTypedArrayBuilder() {
- TypedArray typedArray = null;
- CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
- assertEquals("bearing should match", -1, cameraPosition.bearing, DELTA);
- assertEquals("latlng should match", null, cameraPosition.target);
- assertEquals("tilt should match", -1, cameraPosition.tilt, DELTA);
- assertEquals("zoom should match", -1, cameraPosition.zoom, DELTA);
- }
-
- @Test
- public void testTypedArrayBuilder() {
- float bearing = 180;
- float zoom = 12;
- float latitude = 10;
- float longitude = 11;
- float tilt = 44;
-
- TypedArray typedArray = mock(TypedArray.class);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraBearing, 0.0f)).thenReturn(bearing);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTargetLat, 0.0f)).thenReturn(latitude);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTargetLng, 0.0f)).thenReturn(longitude);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraZoom, 0.0f)).thenReturn(zoom);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTilt, 0.0f)).thenReturn(tilt);
- doNothing().when(typedArray).recycle();
-
- CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
- assertEquals("bearing should match", bearing, cameraPosition.bearing, DELTA);
- assertEquals("latlng should match", new LatLng(latitude, longitude), cameraPosition.target);
- assertEquals("tilt should match", tilt, cameraPosition.tilt, DELTA);
- assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA);
- }
-
- @Test
- public void testJniBuilder() {
- double bearing = 180;
- double zoom = 12;
- double latitude = 10;
- double longitude = 11;
- double tilt = 44;
-
- double[] cameraVars = new double[]{latitude, longitude, bearing, tilt, zoom};
- CameraPosition cameraPosition = new CameraPosition.Builder(cameraVars).build();
- assertEquals("bearing should match", bearing, cameraPosition.bearing, DELTA);
- assertEquals("latlng should match", new LatLng(latitude, longitude), cameraPosition.target);
- assertEquals("tilt should match", tilt, cameraPosition.tilt, DELTA);
- assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA);
- }
-
- @Test
- public void testToString() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
- assertEquals("toString should match", "Target: LatLng [latitude=1.0, longitude=2.0, altitude=0.0], Zoom:3.0, Bearing:5.0, Tilt:4.0", cameraPosition.toString());
- }
-
- @Test
- public void testHashcode() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
- assertEquals("hashCode should match", -1007681505, cameraPosition.hashCode());
- }
-
- @Test
- public void testZoomUpdateBuilder() {
- float zoomLevel = 5;
- CameraPosition.Builder builder = new CameraPosition.Builder(
- (CameraUpdateFactory.ZoomUpdate) CameraUpdateFactory.zoomTo(zoomLevel));
- assertEquals("zoom should match", zoomLevel, builder.build().zoom, 0);
- }
-
- @Test
- public void testEquals() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
- CameraPosition cameraPositionBearing = new CameraPosition(latLng, 3, 4, 9);
- CameraPosition cameraPositionTilt = new CameraPosition(latLng, 3, 9, 5);
- CameraPosition cameraPositionZoom = new CameraPosition(latLng, 9, 4, 5);
- CameraPosition cameraPositionTarget = new CameraPosition(new LatLng(), 3, 4, 5);
-
- assertEquals("cameraPosition should match itself", cameraPosition, cameraPosition);
- assertNotEquals("cameraPosition should not match null", null, cameraPosition);
- assertNotEquals("cameraPosition should not match object", new Object(), cameraPosition);
- assertNotEquals("cameraPosition should not match for bearing", cameraPositionBearing, cameraPosition);
- assertNotEquals("cameraPosition should not match for tilt", cameraPositionTilt, cameraPosition);
- assertNotEquals("cameraPosition should not match for zoom", cameraPositionZoom, cameraPosition);
- assertNotEquals("cameraPosition should not match for target", cameraPositionTarget, cameraPosition);
- }
-
- @Test
- public void testParcelable() {
- CameraPosition object = new CameraPosition(new LatLng(1, 2), 3, 4, 5);
- Parcelable parcelable = MockParcel.obtain(object);
- assertEquals("Parcel should match original object", parcelable, object);
- }
-}
+ private static final double DELTA = 1e-15;
+
+ @Test
+ public void testSanity() {
+ LatLng latLng = new LatLng(1, 2);
+ CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
+ assertNotNull("cameraPosition should not be null", cameraPosition);
+ }
+
+ @Test
+ public void testDefaultTypedArrayBuilder() {
+ TypedArray typedArray = null;
+ CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
+ assertEquals("bearing should match", -1, cameraPosition.bearing, DELTA);
+ assertEquals("latlng should match", null, cameraPosition.target);
+ assertEquals("tilt should match", -1, cameraPosition.tilt, DELTA);
+ assertEquals("zoom should match", -1, cameraPosition.zoom, DELTA);
+ }
+
+ @Test
+ public void testTypedArrayBuilder() {
+ float bearing = 180;
+ float zoom = 12;
+ float latitude = 10;
+ float longitude = 11;
+ float tilt = 44;
+
+ TypedArray typedArray = mock(TypedArray.class);
+ when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraBearing, 0.0f)).thenReturn(bearing);
+ when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTargetLat, 0.0f)).thenReturn(latitude);
+ when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTargetLng, 0.0f)).thenReturn(longitude);
+ when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraZoom, 0.0f)).thenReturn(zoom);
+ when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTilt, 0.0f)).thenReturn(tilt);
+ doNothing().when(typedArray).recycle();
+
+ CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
+ assertEquals("bearing should match", bearing, cameraPosition.bearing, DELTA);
+ assertEquals("latlng should match", new LatLng(latitude, longitude), cameraPosition.target);
+ assertEquals("tilt should match", tilt, cameraPosition.tilt, DELTA);
+ assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA);
+ }
+
+ @Test
+ public void testJniBuilder() {
+ double bearing = 180;
+ double zoom = 12;
+ double latitude = 10;
+ double longitude = 11;
+ double tilt = 44;
+
+ double[] cameraVars = new double[]{latitude, longitude, bearing, tilt, zoom};
+ CameraPosition cameraPosition = new CameraPosition.Builder(cameraVars).build();
+ assertEquals("bearing should match", bearing, cameraPosition.bearing, DELTA);
+ assertEquals("latlng should match", new LatLng(latitude, longitude), cameraPosition.target);
+ assertEquals("tilt should match", tilt, cameraPosition.tilt, DELTA);
+ assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA);
+ }
+
+ @Test
+ public void testToString() {
+ LatLng latLng = new LatLng(1, 2);
+ CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
+ assertEquals("toString should match", "Target: LatLng [latitude=1.0, longitude=2.0, altitude=0.0], Zoom:3.0, "
+ + "Bearing:5.0, Tilt:4.0", cameraPosition.toString());
+ }
+
+ @Test
+ public void testHashcode() {
+ LatLng latLng = new LatLng(1, 2);
+ CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
+ assertEquals("hashCode should match", -1007681505, cameraPosition.hashCode());
+ }
+
+ @Test
+ public void testZoomUpdateBuilder() {
+ float zoomLevel = 5;
+ CameraPosition.Builder builder = new CameraPosition.Builder(
+ (CameraUpdateFactory.ZoomUpdate) CameraUpdateFactory.zoomTo(zoomLevel));
+ assertEquals("zoom should match", zoomLevel, builder.build().zoom, 0);
+ }
+
+ @Test
+ public void testEquals() {
+ LatLng latLng = new LatLng(1, 2);
+ CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5);
+ CameraPosition cameraPositionBearing = new CameraPosition(latLng, 3, 4, 9);
+ CameraPosition cameraPositionTilt = new CameraPosition(latLng, 3, 9, 5);
+ CameraPosition cameraPositionZoom = new CameraPosition(latLng, 9, 4, 5);
+ CameraPosition cameraPositionTarget = new CameraPosition(new LatLng(), 3, 4, 5);
+
+ assertEquals("cameraPosition should match itself", cameraPosition, cameraPosition);
+ assertNotEquals("cameraPosition should not match null", null, cameraPosition);
+ assertNotEquals("cameraPosition should not match object", new Object(), cameraPosition);
+ assertNotEquals("cameraPosition should not match for bearing", cameraPositionBearing, cameraPosition);
+ assertNotEquals("cameraPosition should not match for tilt", cameraPositionTilt, cameraPosition);
+ assertNotEquals("cameraPosition should not match for zoom", cameraPositionZoom, cameraPosition);
+ assertNotEquals("cameraPosition should not match for target", cameraPositionTarget, cameraPosition);
+ }
+
+ @Test
+ public void testParcelable() {
+ CameraPosition object = new CameraPosition(new LatLng(1, 2), 3, 4, 5);
+ Parcelable parcelable = MockParcel.obtain(object);
+ assertEquals("Parcel should match original object", parcelable, object);
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java
index 3d9b2a9364..5623afeb58 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java
@@ -9,13 +9,13 @@ import static junit.framework.Assert.assertEquals;
public class StyleVersionTest {
- private static final double DELTA = 1e-15;
+ private static final double DELTA = 1e-15;
- @Test
- public void testSanity() {
- assertEquals("Style version should match, when upgrading, verify that integers.xml is updated",
- AppConstant.STYLE_VERSION,
- 9,
- DELTA);
- }
+ @Test
+ public void testSanity() {
+ assertEquals("Style version should match, when upgrading, verify that integers.xml is updated",
+ AppConstant.STYLE_VERSION,
+ 9,
+ DELTA);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
index b2cc1e9046..a42ca96cf5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
@@ -20,185 +20,186 @@ import static org.junit.Assert.assertTrue;
public class LatLngBoundsTest {
- private static final double DELTA = 1e-15;
-
- private LatLngBounds mLatLngBounds;
- private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
- private static final LatLng LAT_LNG_NOT_NULL_ISLAND = new LatLng(2, 2);
-
- @Before
- public void beforeTest() {
- mLatLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
- }
-
- @Test
- public void testSanity() {
- LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder();
- latLngBoundsBuilder.include(LAT_LNG_NULL_ISLAND).include(LAT_LNG_NOT_NULL_ISLAND);
- assertNotNull("latLng should not be null", latLngBoundsBuilder.build());
- }
-
- @Test(expected = InvalidLatLngBoundsException.class)
- public void testNoLatLngs() {
- new LatLngBounds.Builder().build();
- }
-
- @Test(expected = InvalidLatLngBoundsException.class)
- public void testOneLatLngs() {
- new LatLngBounds.Builder().include(LAT_LNG_NULL_ISLAND).build();
- }
-
- @Test
- public void testLatitiudeSpan() {
- assertEquals("Span should be the same", 2, mLatLngBounds.getLatitudeSpan(), DELTA);
- }
-
- @Test
- public void testLongitudeSpan() {
- assertEquals("Span should be the same", 2, mLatLngBounds.getLongitudeSpan(), DELTA);
- }
-
- @Test
- public void testCoordinateSpan() {
- LatLngSpan latLngSpan = mLatLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same", new LatLngSpan(2, 2), latLngSpan);
- }
-
- @Test
- public void testCenter() {
- LatLng center = mLatLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(1, 1), center);
- }
-
- @Test
- public void testEmptySpan() {
- mLatLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
- assertTrue("Should be empty", mLatLngBounds.isEmptySpan());
- }
-
- @Test
- public void testNotEmptySpan() {
- mLatLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertFalse("Should not be empty", mLatLngBounds.isEmptySpan());
- }
-
- @Test
- public void testToLatLngs() {
- mLatLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
-
- assertArrayEquals("LatLngs should match",
- new LatLng[]{LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND},
- mLatLngBounds.toLatLngs());
- }
-
- @Test
- public void testIncluding() {
- assertTrue("LatLng should be included", mLatLngBounds.contains(new LatLng(1, 1)));
- }
-
- @Test
- public void testIncludes() {
- List<LatLng> points = new ArrayList<>();
- points.add(LAT_LNG_NULL_ISLAND);
- points.add(LAT_LNG_NOT_NULL_ISLAND);
-
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .includes(points)
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
-
- assertEquals("LatLngBounds should match", latLngBounds1, latLngBounds2);
- }
-
- @Test
- public void testNoIncluding() {
- assertFalse("LatLng should not be included", mLatLngBounds.contains(new LatLng(3, 1)));
- }
-
- @Test
- public void testHashCode() {
- assertEquals(2147483647, mLatLngBounds.hashCode(), -1946419200);
- }
-
- @Test
- public void testEquality() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
- assertEquals("equality should match", mLatLngBounds, latLngBounds);
- assertEquals("not equal to a different object type", mLatLngBounds.equals(LAT_LNG_NOT_NULL_ISLAND), false);
- }
-
- @Test
- public void testToString() {
- assertEquals(mLatLngBounds.toString(), "N:2.0; E:2.0; S:0.0; W:0.0");
- }
-
- @Test
- public void testIntersect() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(1, 1))
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertEquals("intersect should match", latLngBounds, latLngBounds.intersect(mLatLngBounds.getLatNorth(), mLatLngBounds.getLonEast(), mLatLngBounds.getLatSouth(), mLatLngBounds.getLonWest()));
- }
-
- @Test
- public void testNoIntersect() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
- assertNull(latLngBounds.intersect(mLatLngBounds));
- }
-
- @Test
- public void testInnerUnion() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(1, 1))
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertEquals("union should match", latLngBounds, latLngBounds.intersect(mLatLngBounds));
- }
-
- @Test
- public void testOuterUnion() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
- assertEquals("outer union should match",
- latLngBounds.union(mLatLngBounds),
- new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(LAT_LNG_NULL_ISLAND)
- .build());
- }
-
- @Test
- public void testParcelable() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
- Parcelable parcel = MockParcel.obtain(latLngBounds);
- assertEquals("Parcel should match original object", parcel, latLngBounds);
- }
+ private static final double DELTA = 1e-15;
+
+ private LatLngBounds latLngBounds;
+ private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
+ private static final LatLng LAT_LNG_NOT_NULL_ISLAND = new LatLng(2, 2);
+
+ @Before
+ public void beforeTest() {
+ latLngBounds = new LatLngBounds.Builder()
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
+ }
+
+ @Test
+ public void testSanity() {
+ LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder();
+ latLngBoundsBuilder.include(LAT_LNG_NULL_ISLAND).include(LAT_LNG_NOT_NULL_ISLAND);
+ assertNotNull("latLng should not be null", latLngBoundsBuilder.build());
+ }
+
+ @Test(expected = InvalidLatLngBoundsException.class)
+ public void testNoLatLngs() {
+ new LatLngBounds.Builder().build();
+ }
+
+ @Test(expected = InvalidLatLngBoundsException.class)
+ public void testOneLatLngs() {
+ new LatLngBounds.Builder().include(LAT_LNG_NULL_ISLAND).build();
+ }
+
+ @Test
+ public void testLatitiudeSpan() {
+ assertEquals("Span should be the same", 2, latLngBounds.getLatitudeSpan(), DELTA);
+ }
+
+ @Test
+ public void testLongitudeSpan() {
+ assertEquals("Span should be the same", 2, latLngBounds.getLongitudeSpan(), DELTA);
+ }
+
+ @Test
+ public void testCoordinateSpan() {
+ LatLngSpan latLngSpan = latLngBounds.getSpan();
+ assertEquals("LatLngSpan should be the same", new LatLngSpan(2, 2), latLngSpan);
+ }
+
+ @Test
+ public void testCenter() {
+ LatLng center = latLngBounds.getCenter();
+ assertEquals("Center should match", new LatLng(1, 1), center);
+ }
+
+ @Test
+ public void testEmptySpan() {
+ latLngBounds = new LatLngBounds.Builder()
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
+ assertTrue("Should be empty", latLngBounds.isEmptySpan());
+ }
+
+ @Test
+ public void testNotEmptySpan() {
+ latLngBounds = new LatLngBounds.Builder()
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
+ assertFalse("Should not be empty", latLngBounds.isEmptySpan());
+ }
+
+ @Test
+ public void testToLatLngs() {
+ latLngBounds = new LatLngBounds.Builder()
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
+
+ assertArrayEquals("LatLngs should match",
+ new LatLng[] {LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND},
+ latLngBounds.toLatLngs());
+ }
+
+ @Test
+ public void testIncluding() {
+ assertTrue("LatLng should be included", latLngBounds.contains(new LatLng(1, 1)));
+ }
+
+ @Test
+ public void testIncludes() {
+ List<LatLng> points = new ArrayList<>();
+ points.add(LAT_LNG_NULL_ISLAND);
+ points.add(LAT_LNG_NOT_NULL_ISLAND);
+
+ LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
+ .includes(points)
+ .build();
+
+ LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
+
+ assertEquals("LatLngBounds should match", latLngBounds1, latLngBounds2);
+ }
+
+ @Test
+ public void testNoIncluding() {
+ assertFalse("LatLng should not be included", latLngBounds.contains(new LatLng(3, 1)));
+ }
+
+ @Test
+ public void testHashCode() {
+ assertEquals(2147483647, latLngBounds.hashCode(), -1946419200);
+ }
+
+ @Test
+ public void testEquality() {
+ LatLngBounds latLngBounds = new LatLngBounds.Builder()
+ .include(LAT_LNG_NULL_ISLAND)
+ .include(LAT_LNG_NOT_NULL_ISLAND)
+ .build();
+ assertEquals("equality should match", this.latLngBounds, latLngBounds);
+ assertEquals("not equal to a different object type", this.latLngBounds.equals(LAT_LNG_NOT_NULL_ISLAND), false);
+ }
+
+ @Test
+ public void testToString() {
+ assertEquals(latLngBounds.toString(), "N:2.0; E:2.0; S:0.0; W:0.0");
+ }
+
+ @Test
+ public void testIntersect() {
+ LatLngBounds latLngBounds = new LatLngBounds.Builder()
+ .include(new LatLng(1, 1))
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
+ assertEquals("intersect should match", latLngBounds, latLngBounds.intersect(this.latLngBounds.getLatNorth(),
+ this.latLngBounds.getLonEast(), this.latLngBounds.getLatSouth(), this.latLngBounds.getLonWest()));
+ }
+
+ @Test
+ public void testNoIntersect() {
+ LatLngBounds latLngBounds = new LatLngBounds.Builder()
+ .include(new LatLng(10, 10))
+ .include(new LatLng(9, 8))
+ .build();
+ assertNull(latLngBounds.intersect(this.latLngBounds));
+ }
+
+ @Test
+ public void testInnerUnion() {
+ LatLngBounds latLngBounds = new LatLngBounds.Builder()
+ .include(new LatLng(1, 1))
+ .include(LAT_LNG_NULL_ISLAND)
+ .build();
+ assertEquals("union should match", latLngBounds, latLngBounds.intersect(this.latLngBounds));
+ }
+
+ @Test
+ public void testOuterUnion() {
+ LatLngBounds latLngBounds = new LatLngBounds.Builder()
+ .include(new LatLng(10, 10))
+ .include(new LatLng(9, 8))
+ .build();
+ assertEquals("outer union should match",
+ latLngBounds.union(this.latLngBounds),
+ new LatLngBounds.Builder()
+ .include(new LatLng(10, 10))
+ .include(LAT_LNG_NULL_ISLAND)
+ .build());
+ }
+
+ @Test
+ public void testParcelable() {
+ LatLngBounds latLngBounds = new LatLngBounds.Builder()
+ .include(new LatLng(10, 10))
+ .include(new LatLng(9, 8))
+ .build();
+ Parcelable parcel = MockParcel.obtain(latLngBounds);
+ assertEquals("Parcel should match original object", parcel, latLngBounds);
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java
index e184097a43..12297247cf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java
@@ -11,55 +11,55 @@ import static org.junit.Assert.assertNotNull;
public class LatLngSpanTest {
- private static final double DELTA = 1e-15;
- private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
+ private static final double DELTA = 1e-15;
+ private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
- @Test
- public void testSanity() {
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- assertNotNull("latLngSpan should not be null", latLngSpan);
- }
+ @Test
+ public void testSanity() {
+ LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
+ assertNotNull("latLngSpan should not be null", latLngSpan);
+ }
- @Test
- public void testEquality() {
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- assertEquals("latLngSpan is not equal to a LatLng", latLngSpan.equals(LAT_LNG_NULL_ISLAND), false);
- }
+ @Test
+ public void testEquality() {
+ LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
+ assertEquals("latLngSpan is not equal to a LatLng", latLngSpan.equals(LAT_LNG_NULL_ISLAND), false);
+ }
- @Test
- public void testLatitudeConstructor() {
- double latitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(latitude, 0.0);
- assertEquals("latitude in constructor", latLngSpan.getLatitudeSpan(), latitude, DELTA);
- }
+ @Test
+ public void testLatitudeConstructor() {
+ double latitude = 1.23;
+ LatLngSpan latLngSpan = new LatLngSpan(latitude, 0.0);
+ assertEquals("latitude in constructor", latLngSpan.getLatitudeSpan(), latitude, DELTA);
+ }
- @Test
- public void testLongitudeConstructor() {
- double longitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(0.0, longitude);
- assertEquals("latitude in constructor", latLngSpan.getLongitudeSpan(), longitude, DELTA);
- }
+ @Test
+ public void testLongitudeConstructor() {
+ double longitude = 1.23;
+ LatLngSpan latLngSpan = new LatLngSpan(0.0, longitude);
+ assertEquals("latitude in constructor", latLngSpan.getLongitudeSpan(), longitude, DELTA);
+ }
- @Test
- public void testLatitudeMethod() {
- double latitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- latLngSpan.setLatitudeSpan(latitude);
- assertEquals("latitude in constructor", latLngSpan.getLatitudeSpan(), latitude, DELTA);
- }
+ @Test
+ public void testLatitudeMethod() {
+ double latitude = 1.23;
+ LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
+ latLngSpan.setLatitudeSpan(latitude);
+ assertEquals("latitude in constructor", latLngSpan.getLatitudeSpan(), latitude, DELTA);
+ }
- @Test
- public void testLongitudeMethod() {
- double longitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- latLngSpan.setLongitudeSpan(longitude);
- assertEquals("latitude in constructor", latLngSpan.getLongitudeSpan(), longitude, DELTA);
- }
+ @Test
+ public void testLongitudeMethod() {
+ double longitude = 1.23;
+ LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
+ latLngSpan.setLongitudeSpan(longitude);
+ assertEquals("latitude in constructor", latLngSpan.getLongitudeSpan(), longitude, DELTA);
+ }
- @Test
- public void testParcelable() {
- LatLngSpan object = new LatLngSpan(1, 2);
- Parcelable parcel = MockParcel.obtain(object);
- assertEquals("parcel should match initial object", object, parcel);
- }
+ @Test
+ public void testParcelable() {
+ LatLngSpan object = new LatLngSpan(1, 2);
+ Parcelable parcel = MockParcel.obtain(object);
+ assertEquals("parcel should match initial object", object, parcel);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java
index de5dbc5e09..5cbf1fa63c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java
@@ -16,182 +16,182 @@ import static org.mockito.Mockito.when;
public class LatLngTest {
- private static final double DELTA = 1e-15;
-
- @Test
- public void testSanity() {
- LatLng latLng = new LatLng(0.0, 0.0);
- assertNotNull("latLng should not be null", latLng);
- }
-
- @Test
- public void testLatitudeEmptyConstructor() {
- LatLng latLng = new LatLng();
- assertEquals("latitude default value", latLng.getLatitude(), 0, DELTA);
- }
-
- @Test
- public void testLongitudeEmptyConstructor() {
- LatLng latLng = new LatLng();
- assertEquals("longitude default value", latLng.getLongitude(), 0, DELTA);
- }
-
- @Test
- public void testAltitudeEmptyConstructor() {
- LatLng latLng1 = new LatLng();
- assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
- }
-
- @Test
- public void testLatitudeConstructor() {
- double latitude = 1.2;
- LatLng latLng = new LatLng(latitude, 3.4);
- assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
- }
-
- @Test
- public void testLongitudeConstructor() {
- double longitude = 3.4;
- LatLng latLng = new LatLng(1.2, longitude);
- assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
- }
-
- @Test
- public void testAltitudeConstructor() {
- LatLng latLng1 = new LatLng(1.2, 3.4);
- assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
-
- double altitude = 5.6;
- LatLng latLng2 = new LatLng(1.2, 3.4, altitude);
- assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA);
- }
-
- @Test
- public void testLatitudeSetter() {
- LatLng latLng = new LatLng(1.2, 3.4);
- latLng.setLatitude(3);
- assertEquals("latitude should match", 3, latLng.getLatitude(), DELTA);
- }
-
- @Test
- public void testLongitudeSetter() {
- LatLng latLng = new LatLng(1.2, 3.4);
- latLng.setLongitude(3);
- assertEquals("longitude should match", 3, latLng.getLongitude(), DELTA);
- }
-
- @Test
- public void testAltitudeSetter() {
- LatLng latLng = new LatLng(1.2, 3.4);
- latLng.setAltitude(3);
- assertEquals("altitude should match", 3, latLng.getAltitude(), DELTA);
- }
-
- @Test
- public void testLatLngConstructor() {
- LatLng latLng1 = new LatLng(1.2, 3.4);
- LatLng latLng2 = new LatLng(latLng1);
- assertEquals("latLng should match", latLng1, latLng2);
- }
-
- @Test
- public void testDistanceTo() {
- LatLng latLng1 = new LatLng(0.0, 0.0);
- LatLng latLng2 = new LatLng(1.0, 1.0);
- assertEquals("distances should match",
- latLng1.distanceTo(latLng2),
- 157425.53710839353, DELTA);
- }
-
- @Test
- public void testDistanceToSamePoint() {
- LatLng latLng1 = new LatLng(40.71199035644531, -74.0081);
- LatLng latLng2 = new LatLng(40.71199035644531, -74.0081);
- double distance = latLng1.distanceTo(latLng2);
- assertEquals("distance should match", 0.0, distance, DELTA);
- }
-
- @Test
- public void testLocationProvider() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
-
- // Mock the location class
- Location locationMocked = mock(Location.class);
- when(locationMocked.getLatitude()).thenReturn(latitude);
- when(locationMocked.getLongitude()).thenReturn(longitude);
- when(locationMocked.getAltitude()).thenReturn(altitude);
-
- // Test the constructor
- LatLng latLng = new LatLng(locationMocked);
- assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
- assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
- assertEquals("altitude should match", latLng.getAltitude(), altitude, DELTA);
- }
-
- @Test
- public void testHashCode() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
- LatLng latLng = new LatLng(latitude, longitude, altitude);
- assertEquals("hash code should match", latLng.hashCode(), -151519232);
- }
-
- @Test
- public void testToString() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
- LatLng latLng = new LatLng(latitude, longitude, altitude);
- assertEquals("string should match",
- latLng.toString(),
- "LatLng [latitude=1.2, longitude=3.4, altitude=5.6]");
- }
-
- @Test
- public void testEqualsOther() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
- LatLng latLng1 = new LatLng(latitude, longitude, altitude);
- LatLng latLng2 = new LatLng(latitude, longitude, altitude);
- assertEquals("LatLng should match", latLng1, latLng2);
- }
-
- @Test
- public void testEqualsItself() {
- LatLng latLng = new LatLng(1, 2, 3);
- assertEquals("LatLng should match", latLng, latLng);
- }
-
- @Test
- public void testNotEquals() {
- LatLng latLng = new LatLng(1, 2);
- assertNotEquals("LatLng should match", latLng, new Object());
- }
-
- @Test
- public void testParcelable() {
- LatLng latLng = new LatLng(45.0, -185.0);
- Parcelable parcel = MockParcel.obtain(latLng);
- assertEquals("parcel should match initial object", latLng, parcel);
- }
-
- @Test
- public void testWrapped() {
- LatLng latLng = new LatLng(45.0, -185.0);
- LatLng wrapped = latLng.wrap();
- assertNotSame(latLng, wrapped);
- assertEquals("longitude wrapped value", wrapped.getLongitude(), 175.0, DELTA);
- }
-
- @Test
- public void testUnnecessaryWrapped() {
- LatLng latLng = new LatLng(45.0, 50.0);
- LatLng wrapped = latLng.wrap();
- assertNotSame(latLng, wrapped);
- assertEquals("longitude wrapped value", wrapped.getLongitude(), 50.0, DELTA);
- }
+ private static final double DELTA = 1e-15;
+
+ @Test
+ public void testSanity() {
+ LatLng latLng = new LatLng(0.0, 0.0);
+ assertNotNull("latLng should not be null", latLng);
+ }
+
+ @Test
+ public void testLatitudeEmptyConstructor() {
+ LatLng latLng = new LatLng();
+ assertEquals("latitude default value", latLng.getLatitude(), 0, DELTA);
+ }
+
+ @Test
+ public void testLongitudeEmptyConstructor() {
+ LatLng latLng = new LatLng();
+ assertEquals("longitude default value", latLng.getLongitude(), 0, DELTA);
+ }
+
+ @Test
+ public void testAltitudeEmptyConstructor() {
+ LatLng latLng1 = new LatLng();
+ assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
+ }
+
+ @Test
+ public void testLatitudeConstructor() {
+ double latitude = 1.2;
+ LatLng latLng = new LatLng(latitude, 3.4);
+ assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
+ }
+
+ @Test
+ public void testLongitudeConstructor() {
+ double longitude = 3.4;
+ LatLng latLng = new LatLng(1.2, longitude);
+ assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
+ }
+
+ @Test
+ public void testAltitudeConstructor() {
+ LatLng latLng1 = new LatLng(1.2, 3.4);
+ assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
+
+ double altitude = 5.6;
+ LatLng latLng2 = new LatLng(1.2, 3.4, altitude);
+ assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA);
+ }
+
+ @Test
+ public void testLatitudeSetter() {
+ LatLng latLng = new LatLng(1.2, 3.4);
+ latLng.setLatitude(3);
+ assertEquals("latitude should match", 3, latLng.getLatitude(), DELTA);
+ }
+
+ @Test
+ public void testLongitudeSetter() {
+ LatLng latLng = new LatLng(1.2, 3.4);
+ latLng.setLongitude(3);
+ assertEquals("longitude should match", 3, latLng.getLongitude(), DELTA);
+ }
+
+ @Test
+ public void testAltitudeSetter() {
+ LatLng latLng = new LatLng(1.2, 3.4);
+ latLng.setAltitude(3);
+ assertEquals("altitude should match", 3, latLng.getAltitude(), DELTA);
+ }
+
+ @Test
+ public void testLatLngConstructor() {
+ LatLng latLng1 = new LatLng(1.2, 3.4);
+ LatLng latLng2 = new LatLng(latLng1);
+ assertEquals("latLng should match", latLng1, latLng2);
+ }
+
+ @Test
+ public void testDistanceTo() {
+ LatLng latLng1 = new LatLng(0.0, 0.0);
+ LatLng latLng2 = new LatLng(1.0, 1.0);
+ assertEquals("distances should match",
+ latLng1.distanceTo(latLng2),
+ 157425.53710839353, DELTA);
+ }
+
+ @Test
+ public void testDistanceToSamePoint() {
+ LatLng latLng1 = new LatLng(40.71199035644531, -74.0081);
+ LatLng latLng2 = new LatLng(40.71199035644531, -74.0081);
+ double distance = latLng1.distanceTo(latLng2);
+ assertEquals("distance should match", 0.0, distance, DELTA);
+ }
+
+ @Test
+ public void testLocationProvider() {
+ double latitude = 1.2;
+ double longitude = 3.4;
+ double altitude = 5.6;
+
+ // Mock the location class
+ Location locationMocked = mock(Location.class);
+ when(locationMocked.getLatitude()).thenReturn(latitude);
+ when(locationMocked.getLongitude()).thenReturn(longitude);
+ when(locationMocked.getAltitude()).thenReturn(altitude);
+
+ // Test the constructor
+ LatLng latLng = new LatLng(locationMocked);
+ assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
+ assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
+ assertEquals("altitude should match", latLng.getAltitude(), altitude, DELTA);
+ }
+
+ @Test
+ public void testHashCode() {
+ double latitude = 1.2;
+ double longitude = 3.4;
+ double altitude = 5.6;
+ LatLng latLng = new LatLng(latitude, longitude, altitude);
+ assertEquals("hash code should match", latLng.hashCode(), -151519232);
+ }
+
+ @Test
+ public void testToString() {
+ double latitude = 1.2;
+ double longitude = 3.4;
+ double altitude = 5.6;
+ LatLng latLng = new LatLng(latitude, longitude, altitude);
+ assertEquals("string should match",
+ latLng.toString(),
+ "LatLng [latitude=1.2, longitude=3.4, altitude=5.6]");
+ }
+
+ @Test
+ public void testEqualsOther() {
+ double latitude = 1.2;
+ double longitude = 3.4;
+ double altitude = 5.6;
+ LatLng latLng1 = new LatLng(latitude, longitude, altitude);
+ LatLng latLng2 = new LatLng(latitude, longitude, altitude);
+ assertEquals("LatLng should match", latLng1, latLng2);
+ }
+
+ @Test
+ public void testEqualsItself() {
+ LatLng latLng = new LatLng(1, 2, 3);
+ assertEquals("LatLng should match", latLng, latLng);
+ }
+
+ @Test
+ public void testNotEquals() {
+ LatLng latLng = new LatLng(1, 2);
+ assertNotEquals("LatLng should match", latLng, new Object());
+ }
+
+ @Test
+ public void testParcelable() {
+ LatLng latLng = new LatLng(45.0, -185.0);
+ Parcelable parcel = MockParcel.obtain(latLng);
+ assertEquals("parcel should match initial object", latLng, parcel);
+ }
+
+ @Test
+ public void testWrapped() {
+ LatLng latLng = new LatLng(45.0, -185.0);
+ LatLng wrapped = latLng.wrap();
+ assertNotSame(latLng, wrapped);
+ assertEquals("longitude wrapped value", wrapped.getLongitude(), 175.0, DELTA);
+ }
+
+ @Test
+ public void testUnnecessaryWrapped() {
+ LatLng latLng = new LatLng(45.0, 50.0);
+ LatLng wrapped = latLng.wrap();
+ assertNotSame(latLng, wrapped);
+ assertEquals("longitude wrapped value", wrapped.getLongitude(), 50.0, DELTA);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java
index 5525684601..00fd125a1a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java
@@ -11,56 +11,56 @@ import static org.junit.Assert.assertNotNull;
public class ProjectedMetersTest {
- private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
+ private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
- @Test
- public void testSanity() {
- ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
- assertNotNull("projectedMeters should not be null", projectedMeters);
- }
+ @Test
+ public void testSanity() {
+ ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
+ assertNotNull("projectedMeters should not be null", projectedMeters);
+ }
- @Test
- public void testEquality() {
- ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
- assertEquals("projectedMeters is not equal to a LatLng", projectedMeters.equals(LAT_LNG_NULL_ISLAND), false);
- assertEquals("projectedMeters is equal to itself", projectedMeters.equals(projectedMeters), true);
- }
+ @Test
+ public void testEquality() {
+ ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
+ assertEquals("projectedMeters is not equal to a LatLng", projectedMeters.equals(LAT_LNG_NULL_ISLAND), false);
+ assertEquals("projectedMeters is equal to itself", projectedMeters.equals(projectedMeters), true);
+ }
- @Test
- public void testNorthing() {
- ProjectedMeters projectedMeters = new ProjectedMeters(1.0, 0.0);
- assertEquals("northing should be 1", 1, projectedMeters.getNorthing(), 0);
- }
+ @Test
+ public void testNorthing() {
+ ProjectedMeters projectedMeters = new ProjectedMeters(1.0, 0.0);
+ assertEquals("northing should be 1", 1, projectedMeters.getNorthing(), 0);
+ }
- @Test
- public void testEasting() {
- ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 1.0);
- assertEquals("easting should be 1", 1, projectedMeters.getEasting(), 0);
- }
+ @Test
+ public void testEasting() {
+ ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 1.0);
+ assertEquals("easting should be 1", 1, projectedMeters.getEasting(), 0);
+ }
- @Test
- public void testConstructor() {
- ProjectedMeters projectedMeters1 = new ProjectedMeters(1, 2);
- ProjectedMeters projectedMeters2 = new ProjectedMeters(projectedMeters1);
- assertEquals("projectedmeters should match", projectedMeters1, projectedMeters2);
- }
+ @Test
+ public void testConstructor() {
+ ProjectedMeters projectedMeters1 = new ProjectedMeters(1, 2);
+ ProjectedMeters projectedMeters2 = new ProjectedMeters(projectedMeters1);
+ assertEquals("projectedmeters should match", projectedMeters1, projectedMeters2);
+ }
- @Test
- public void testHashcode() {
- ProjectedMeters meters = new ProjectedMeters(1, 2);
- assertEquals("hashcode should match", -1048576, meters.hashCode());
- }
+ @Test
+ public void testHashcode() {
+ ProjectedMeters meters = new ProjectedMeters(1, 2);
+ assertEquals("hashcode should match", -1048576, meters.hashCode());
+ }
- @Test
- public void testToString() {
- ProjectedMeters meters = new ProjectedMeters(1, 1);
- assertEquals("toString should match", "ProjectedMeters [northing=1.0, easting=1.0]", meters.toString());
- }
+ @Test
+ public void testToString() {
+ ProjectedMeters meters = new ProjectedMeters(1, 1);
+ assertEquals("toString should match", "ProjectedMeters [northing=1.0, easting=1.0]", meters.toString());
+ }
- @Test
- public void testParcelable() {
- ProjectedMeters meters = new ProjectedMeters(1, 1);
- Parcelable parcel = MockParcel.obtain(meters);
- assertEquals("parcel should match initial object", meters, parcel);
- }
+ @Test
+ public void testParcelable() {
+ ProjectedMeters meters = new ProjectedMeters(1, 1);
+ Parcelable parcel = MockParcel.obtain(meters);
+ assertEquals("parcel should match initial object", meters, parcel);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java
index cad268c2ba..12b779de5d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java
@@ -11,84 +11,85 @@ import static org.junit.Assert.assertNotNull;
public class VisibleRegionTest {
- private static final LatLng FAR_LEFT = new LatLng(52, -12);
- private static final LatLng NEAR_LEFT = new LatLng(34, -12);
- private static final LatLng FAR_RIGHT = new LatLng(52, 26);
- private static final LatLng NEAR_RIGHT = new LatLng(34, 26);
- private static final LatLngBounds BOUNDS = new LatLngBounds.Builder().include(FAR_LEFT).include(FAR_RIGHT).include(NEAR_LEFT).include(NEAR_RIGHT).build();
-
- @Test
- public void testSanity() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertNotNull("region should not be null", region);
- }
-
- @Test
- public void testEquality() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("visibleRegion is not equal to a LatLng", region.equals(FAR_LEFT), false);
- assertEquals("visibleRegion is equal to itself", region.equals(region), true);
- }
-
- @Test
- public void testFarLeftConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.farLeft, FAR_LEFT);
- }
-
- @Test
- public void testNearLeftConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.nearLeft, NEAR_LEFT);
- }
-
- @Test
- public void testFarRightConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.farRight, FAR_RIGHT);
- }
-
- @Test
- public void testNearRightConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.nearRight, NEAR_RIGHT);
- }
-
- @Test
- public void testLatLngBoundsConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLngBounds should match", region.latLngBounds, BOUNDS);
- }
-
- @Test
- public void testEquals() {
- VisibleRegion regionLeft = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- VisibleRegion regionRight = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("VisibleRegions should match", regionLeft, regionRight);
- }
-
- @Test
- public void testHashcode() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("hashcode should match", -923534102, region.hashCode());
- }
-
- @Test
- public void testToString() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("string should match",
- "[farLeft [LatLng [latitude=52.0, longitude=-12.0, altitude=0.0]], " +
- "farRight [LatLng [latitude=52.0, longitude=26.0, altitude=0.0]], " +
- "nearLeft [LatLng [latitude=34.0, longitude=-12.0, altitude=0.0]], " +
- "nearRight [LatLng [latitude=34.0, longitude=26.0, altitude=0.0]], " +
- "latLngBounds [N:52.0; E:26.0; S:34.0; W:-12.0]]"
- , region.toString());
- }
-
- @Test
- public void testParcelable() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- Parcelable parcel = MockParcel.obtain(region);
- assertEquals("parcel should match initial object", region, parcel);
- }
+ private static final LatLng FAR_LEFT = new LatLng(52, -12);
+ private static final LatLng NEAR_LEFT = new LatLng(34, -12);
+ private static final LatLng FAR_RIGHT = new LatLng(52, 26);
+ private static final LatLng NEAR_RIGHT = new LatLng(34, 26);
+ private static final LatLngBounds BOUNDS =
+ new LatLngBounds.Builder().include(FAR_LEFT).include(FAR_RIGHT).include(NEAR_LEFT).include(NEAR_RIGHT).build();
+
+ @Test
+ public void testSanity() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertNotNull("region should not be null", region);
+ }
+
+ @Test
+ public void testEquality() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("visibleRegion is not equal to a LatLng", region.equals(FAR_LEFT), false);
+ assertEquals("visibleRegion is equal to itself", region.equals(region), true);
+ }
+
+ @Test
+ public void testFarLeftConstructor() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("LatLng should match", region.farLeft, FAR_LEFT);
+ }
+
+ @Test
+ public void testNearLeftConstructor() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("LatLng should match", region.nearLeft, NEAR_LEFT);
+ }
+
+ @Test
+ public void testFarRightConstructor() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("LatLng should match", region.farRight, FAR_RIGHT);
+ }
+
+ @Test
+ public void testNearRightConstructor() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("LatLng should match", region.nearRight, NEAR_RIGHT);
+ }
+
+ @Test
+ public void testLatLngBoundsConstructor() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("LatLngBounds should match", region.latLngBounds, BOUNDS);
+ }
+
+ @Test
+ public void testEquals() {
+ VisibleRegion regionLeft = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ VisibleRegion regionRight = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("VisibleRegions should match", regionLeft, regionRight);
+ }
+
+ @Test
+ public void testHashcode() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("hashcode should match", -923534102, region.hashCode());
+ }
+
+ @Test
+ public void testToString() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ assertEquals("string should match",
+ "[farLeft [LatLng [latitude=52.0, longitude=-12.0, altitude=0.0]], "
+ + "farRight [LatLng [latitude=52.0, longitude=26.0, altitude=0.0]], "
+ + "nearLeft [LatLng [latitude=34.0, longitude=-12.0, altitude=0.0]], "
+ + "nearRight [LatLng [latitude=34.0, longitude=26.0, altitude=0.0]], "
+ + "latLngBounds [N:52.0; E:26.0; S:34.0; W:-12.0]]",
+ region.toString());
+ }
+
+ @Test
+ public void testParcelable() {
+ VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
+ Parcelable parcel = MockParcel.obtain(region);
+ assertEquals("parcel should match initial object", region, parcel);
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
index 05d1f2beb1..e0415182de 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
@@ -21,169 +21,177 @@ import static org.junit.Assert.assertTrue;
public class MapboxMapOptionsTest {
- private static final double DELTA = 1e-15;
-
- @Test
- public void testSanity() {
- assertNotNull("should not be null", new MapboxMapOptions());
- }
-
- @Test
- public void testDebugEnabled() {
- assertFalse(new MapboxMapOptions().getDebugActive());
- assertTrue(new MapboxMapOptions().debugActive(true).getDebugActive());
- assertFalse(new MapboxMapOptions().debugActive(false).getDebugActive());
- }
-
- @Test
- public void testCompassEnabled() {
- assertTrue(new MapboxMapOptions().compassEnabled(true).getCompassEnabled());
- assertFalse(new MapboxMapOptions().compassEnabled(false).getCompassEnabled());
- }
-
- @Test
- public void testCompassGravity() {
- assertEquals(Gravity.TOP | Gravity.END, new MapboxMapOptions().getCompassGravity());
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity());
- assertNotEquals(Gravity.START, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity());
- }
-
- @Test
- public void testCompassMargins() {
- assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().compassMargins(new int[]{0, 1, 2, 3}).getCompassMargins()));
- assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().compassMargins(new int[]{0, 0, 0, 0}).getCompassMargins()));
- }
-
- @Test
- public void testLogoEnabled() {
- assertTrue(new MapboxMapOptions().logoEnabled(true).getLogoEnabled());
- assertFalse(new MapboxMapOptions().logoEnabled(false).getLogoEnabled());
- }
-
- @Test
- public void testLogoGravity() {
- assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getLogoGravity());
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
- assertNotEquals(Gravity.START, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
- }
-
- @Test
- public void testLogoMargins() {
- assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().logoMargins(new int[]{0, 1, 2, 3}).getLogoMargins()));
- assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().logoMargins(new int[]{0, 0, 0, 0}).getLogoMargins()));
- }
-
- @Test
- public void testAttributionTintColor() {
- assertEquals(-1, new MapboxMapOptions().getAttributionTintColor());
- assertEquals(Color.RED, new MapboxMapOptions().attributionTintColor(Color.RED).getAttributionTintColor());
- }
-
- @Test
- public void testAttributionEnabled() {
- assertTrue(new MapboxMapOptions().attributionEnabled(true).getAttributionEnabled());
- assertFalse(new MapboxMapOptions().attributionEnabled(false).getAttributionEnabled());
- }
-
- @Test
- public void testAttributionGravity() {
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity());
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
- assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
- }
-
- @Test
- public void testAttributionMargins() {
- assertTrue(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(new int[]{0, 1, 2, 3}).getAttributionMargins()));
- assertFalse(Arrays.equals(new int[]{0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(new int[]{0, 0, 0, 0}).getAttributionMargins()));
- }
-
- @Test
- public void testMinZoom() {
- assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoomPreference(), DELTA);
- assertEquals(5.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA);
- assertNotEquals(2.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA);
- }
-
- @Test
- public void testMaxZoom() {
- assertEquals(MapboxConstants.MAXIMUM_ZOOM, new MapboxMapOptions().getMaxZoomPreference(), DELTA);
- assertEquals(5.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA);
- assertNotEquals(2.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA);
- }
-
- @Test
- public void testLocationEnabled() {
- assertFalse(new MapboxMapOptions().getLocationEnabled());
- assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled());
- assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled());
- }
-
- @Test
- public void testTiltGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getTiltGesturesEnabled());
- assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled());
- assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTiltGesturesEnabled());
- }
-
- @Test
- public void testScrollGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getScrollGesturesEnabled());
- assertTrue(new MapboxMapOptions().scrollGesturesEnabled(true).getScrollGesturesEnabled());
- assertFalse(new MapboxMapOptions().scrollGesturesEnabled(false).getScrollGesturesEnabled());
- }
-
- @Test
- public void testZoomGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getZoomGesturesEnabled());
- assertTrue(new MapboxMapOptions().zoomGesturesEnabled(true).getZoomGesturesEnabled());
- assertFalse(new MapboxMapOptions().zoomGesturesEnabled(false).getZoomGesturesEnabled());
- }
-
- @Test
- public void testRotateGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getRotateGesturesEnabled());
- assertTrue(new MapboxMapOptions().rotateGesturesEnabled(true).getRotateGesturesEnabled());
- assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled());
- }
-
- @Test
- public void testZoomControlsEnabled() {
- assertFalse(new MapboxMapOptions().getZoomControlsEnabled());
- assertTrue(new MapboxMapOptions().zoomControlsEnabled(true).getZoomControlsEnabled());
- assertFalse(new MapboxMapOptions().zoomControlsEnabled(false).getZoomControlsEnabled());
- }
-
- @Test
- public void testStyleUrl() {
- assertEquals(Style.DARK, new MapboxMapOptions().styleUrl(Style.DARK).getStyle());
- assertNotEquals(Style.LIGHT, new MapboxMapOptions().styleUrl(Style.DARK).getStyle());
- assertNull(new MapboxMapOptions().getStyle());
- }
-
- @Test
- public void testCamera() {
- CameraPosition position = new CameraPosition.Builder().build();
- assertEquals(new CameraPosition.Builder(position).build(), new MapboxMapOptions().camera(position).getCamera());
- assertNotEquals(new CameraPosition.Builder().target(new LatLng(1, 1)), new MapboxMapOptions().camera(position));
- assertNull(new MapboxMapOptions().getCamera());
- }
-
- @Test
- public void testMyLocationForegroundTint() {
- assertEquals(Color.BLUE, new MapboxMapOptions().myLocationForegroundTintColor(Color.BLUE).getMyLocationForegroundTintColor());
- }
-
- @Test
- public void testMyLocationBackgroundTint() {
- assertEquals(Color.BLUE, new MapboxMapOptions().myLocationBackgroundTintColor(Color.BLUE).getMyLocationBackgroundTintColor());
- }
-
- @Test
- public void testAccessToken() {
- assertNull(new MapboxMapOptions().getAccessToken());
- assertEquals("test", new MapboxMapOptions().accessToken("test").getAccessToken());
- assertNotEquals("nottest", new MapboxMapOptions().accessToken("test").getStyle());
- }
+ private static final double DELTA = 1e-15;
+
+ @Test
+ public void testSanity() {
+ assertNotNull("should not be null", new MapboxMapOptions());
+ }
+
+ @Test
+ public void testDebugEnabled() {
+ assertFalse(new MapboxMapOptions().getDebugActive());
+ assertTrue(new MapboxMapOptions().debugActive(true).getDebugActive());
+ assertFalse(new MapboxMapOptions().debugActive(false).getDebugActive());
+ }
+
+ @Test
+ public void testCompassEnabled() {
+ assertTrue(new MapboxMapOptions().compassEnabled(true).getCompassEnabled());
+ assertFalse(new MapboxMapOptions().compassEnabled(false).getCompassEnabled());
+ }
+
+ @Test
+ public void testCompassGravity() {
+ assertEquals(Gravity.TOP | Gravity.END, new MapboxMapOptions().getCompassGravity());
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity());
+ assertNotEquals(Gravity.START, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity());
+ }
+
+ @Test
+ public void testCompassMargins() {
+ assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().compassMargins(
+ new int[] {0, 1, 2, 3}).getCompassMargins()));
+ assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().compassMargins(
+ new int[] {0, 0, 0, 0}).getCompassMargins()));
+ }
+
+ @Test
+ public void testLogoEnabled() {
+ assertTrue(new MapboxMapOptions().logoEnabled(true).getLogoEnabled());
+ assertFalse(new MapboxMapOptions().logoEnabled(false).getLogoEnabled());
+ }
+
+ @Test
+ public void testLogoGravity() {
+ assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getLogoGravity());
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
+ assertNotEquals(Gravity.START, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
+ }
+
+ @Test
+ public void testLogoMargins() {
+ assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().logoMargins(
+ new int[] {0, 1, 2, 3}).getLogoMargins()));
+ assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().logoMargins(
+ new int[] {0, 0, 0, 0}).getLogoMargins()));
+ }
+
+ @Test
+ public void testAttributionTintColor() {
+ assertEquals(-1, new MapboxMapOptions().getAttributionTintColor());
+ assertEquals(Color.RED, new MapboxMapOptions().attributionTintColor(Color.RED).getAttributionTintColor());
+ }
+
+ @Test
+ public void testAttributionEnabled() {
+ assertTrue(new MapboxMapOptions().attributionEnabled(true).getAttributionEnabled());
+ assertFalse(new MapboxMapOptions().attributionEnabled(false).getAttributionEnabled());
+ }
+
+ @Test
+ public void testAttributionGravity() {
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity());
+ assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
+ assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
+ }
+
+ @Test
+ public void testAttributionMargins() {
+ assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(
+ new int[] {0, 1, 2, 3}).getAttributionMargins()));
+ assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(
+ new int[] {0, 0, 0, 0}).getAttributionMargins()));
+ }
+
+ @Test
+ public void testMinZoom() {
+ assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoomPreference(), DELTA);
+ assertEquals(5.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA);
+ assertNotEquals(2.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA);
+ }
+
+ @Test
+ public void testMaxZoom() {
+ assertEquals(MapboxConstants.MAXIMUM_ZOOM, new MapboxMapOptions().getMaxZoomPreference(), DELTA);
+ assertEquals(5.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA);
+ assertNotEquals(2.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA);
+ }
+
+ @Test
+ public void testLocationEnabled() {
+ assertFalse(new MapboxMapOptions().getLocationEnabled());
+ assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled());
+ assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled());
+ }
+
+ @Test
+ public void testTiltGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getTiltGesturesEnabled());
+ assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled());
+ assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTiltGesturesEnabled());
+ }
+
+ @Test
+ public void testScrollGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getScrollGesturesEnabled());
+ assertTrue(new MapboxMapOptions().scrollGesturesEnabled(true).getScrollGesturesEnabled());
+ assertFalse(new MapboxMapOptions().scrollGesturesEnabled(false).getScrollGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getZoomGesturesEnabled());
+ assertTrue(new MapboxMapOptions().zoomGesturesEnabled(true).getZoomGesturesEnabled());
+ assertFalse(new MapboxMapOptions().zoomGesturesEnabled(false).getZoomGesturesEnabled());
+ }
+
+ @Test
+ public void testRotateGesturesEnabled() {
+ assertTrue(new MapboxMapOptions().getRotateGesturesEnabled());
+ assertTrue(new MapboxMapOptions().rotateGesturesEnabled(true).getRotateGesturesEnabled());
+ assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomControlsEnabled() {
+ assertFalse(new MapboxMapOptions().getZoomControlsEnabled());
+ assertTrue(new MapboxMapOptions().zoomControlsEnabled(true).getZoomControlsEnabled());
+ assertFalse(new MapboxMapOptions().zoomControlsEnabled(false).getZoomControlsEnabled());
+ }
+
+ @Test
+ public void testStyleUrl() {
+ assertEquals(Style.DARK, new MapboxMapOptions().styleUrl(Style.DARK).getStyle());
+ assertNotEquals(Style.LIGHT, new MapboxMapOptions().styleUrl(Style.DARK).getStyle());
+ assertNull(new MapboxMapOptions().getStyle());
+ }
+
+ @Test
+ public void testCamera() {
+ CameraPosition position = new CameraPosition.Builder().build();
+ assertEquals(new CameraPosition.Builder(position).build(), new MapboxMapOptions().camera(position).getCamera());
+ assertNotEquals(new CameraPosition.Builder().target(new LatLng(1, 1)), new MapboxMapOptions().camera(position));
+ assertNull(new MapboxMapOptions().getCamera());
+ }
+
+ @Test
+ public void testMyLocationForegroundTint() {
+ assertEquals(Color.BLUE,
+ new MapboxMapOptions().myLocationForegroundTintColor(Color.BLUE).getMyLocationForegroundTintColor());
+ }
+
+ @Test
+ public void testMyLocationBackgroundTint() {
+ assertEquals(Color.BLUE,
+ new MapboxMapOptions().myLocationBackgroundTintColor(Color.BLUE).getMyLocationBackgroundTintColor());
+ }
+
+ @Test
+ public void testAccessToken() {
+ assertNull(new MapboxMapOptions().getAccessToken());
+ assertEquals("test", new MapboxMapOptions().accessToken("test").getAccessToken());
+ assertNotEquals("nottest", new MapboxMapOptions().accessToken("test").getStyle());
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java
index 96c2c57084..57f3b942af 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java
@@ -4,7 +4,6 @@ import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
-import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
@@ -12,7 +11,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -23,49 +21,50 @@ import static org.mockito.Mockito.when;
public class TrackingSettingsTest {
- @InjectMocks
- MyLocationView myLocationView = mock(MyLocationView.class);
+ @InjectMocks
+ MyLocationView myLocationView = mock(MyLocationView.class);
- @InjectMocks
- UiSettings uiSettings = mock(UiSettings.class);
+ @InjectMocks
+ UiSettings uiSettings = mock(UiSettings.class);
- @InjectMocks
- FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
+ @InjectMocks
+ FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
- private TrackingSettings trackingSettings;
+ private TrackingSettings trackingSettings;
- @Before
- public void beforeTest() {
- trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener);
- }
+ @Before
+ public void beforeTest() {
+ trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener);
+ }
- @Test
- public void testSanity() {
- assertNotNull("trackingsettings should not be null", trackingSettings);
- }
-
- @Test
- public void testDismissTrackingModesOnGesture() {
- trackingSettings.setDismissTrackingOnGesture(false);
- assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture());
- }
+ @Test
+ public void testSanity() {
+ assertNotNull("trackingsettings should not be null", trackingSettings);
+ }
- @Test
- public void testValidateGesturesForTrackingModes() {
- trackingSettings.setDismissTrackingOnGesture(false);
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture());
- }
+ @Test
+ public void testDismissTrackingModesOnGesture() {
+ trackingSettings.setDismissTrackingOnGesture(false);
+ assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture());
+ }
- @Test
- public void testMyLocationEnabled() {
- // setup mock context to provide accepted location permission
- Context context = mock(Context.class);
- when(myLocationView.getContext()).thenReturn(context);
- when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
+ @Test
+ public void testValidateGesturesForTrackingModes() {
+ trackingSettings.setDismissTrackingOnGesture(false);
+ trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+ assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture());
+ }
- assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled());
- trackingSettings.setMyLocationEnabled(true);
- assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled());
- }
+ @Test
+ public void testMyLocationEnabled() {
+ // setup mock context to provide accepted location permission
+ Context context = mock(Context.class);
+ when(myLocationView.getContext()).thenReturn(context);
+ when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(),
+ anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
+
+ assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled());
+ trackingSettings.setMyLocationEnabled(true);
+ assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled());
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
index 741929b814..1f532255d7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
@@ -20,321 +20,321 @@ import static org.mockito.Mockito.when;
public class UiSettingsTest {
- @InjectMocks
- Projection projection = mock(Projection.class);
-
- @InjectMocks
- FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
-
- @InjectMocks
- CompassView compassView = mock(CompassView.class);
-
- @InjectMocks
- ImageView imageView = mock(ImageView.class);
-
- @InjectMocks
- ImageView logoView = mock(ImageView.class);
-
- @InjectMocks
- FrameLayout.LayoutParams layoutParams = mock(FrameLayout.LayoutParams.class);
-
- private UiSettings uiSettings;
-
- @Before
- public void beforeTest() {
- uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView);
- }
-
- @Test
- public void testSanity() {
- assertNotNull("uiSettings should not be null", uiSettings);
- }
-
- @Test
- public void testCompassEnabled() {
- when(compassView.isEnabled()).thenReturn(true);
- uiSettings.setCompassEnabled(true);
- assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled());
- }
-
- @Test
- public void testCompassDisabled() {
- uiSettings.setCompassEnabled(false);
- assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled());
- }
-
- @Test
- public void testCompassGravity() {
- when(compassView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.gravity = Gravity.START;
- uiSettings.setCompassGravity(Gravity.START);
- assertEquals("Compass gravity should be same", Gravity.START, uiSettings.getCompassGravity());
- }
-
- @Test
- public void testCompassMargins() {
- when(projection.getContentPadding()).thenReturn(new int[]{0, 0, 0, 0});
- when(compassView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.leftMargin = 1;
- layoutParams.topMargin = 2;
- layoutParams.rightMargin = 3;
- layoutParams.bottomMargin = 4;
- uiSettings.setCompassMargins(1, 2, 3, 4);
- assertTrue("Compass margin left should be same", uiSettings.getCompassMarginLeft() == 1);
- assertTrue("Compass margin top should be same", uiSettings.getCompassMarginTop() == 2);
- assertTrue("Compass margin right should be same", uiSettings.getCompassMarginRight() == 3);
- assertTrue("Compass margin bottom should be same", uiSettings.getCompassMarginBottom() == 4);
- }
-
- @Test
- public void testCompassFadeWhenFacingNorth() {
- when(compassView.isFadeCompassViewFacingNorth()).thenReturn(true);
- assertTrue("Compass should fade when facing north by default.", uiSettings.isCompassFadeWhenFacingNorth());
- uiSettings.setCompassFadeFacingNorth(false);
- when(compassView.isFadeCompassViewFacingNorth()).thenReturn(false);
- assertFalse("Compass fading should be disabled", uiSettings.isCompassFadeWhenFacingNorth());
- }
-
- @Test
- public void testLogoEnabled() {
- uiSettings.setLogoEnabled(true);
- assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled());
- }
-
- @Test
- public void testLogoDisabled() {
- when(logoView.getVisibility()).thenReturn(View.GONE);
- uiSettings.setLogoEnabled(false);
- assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled());
- }
-
- @Test
- public void testLogoGravity() {
- layoutParams.gravity = Gravity.END;
- when(logoView.getLayoutParams()).thenReturn(layoutParams);
- uiSettings.setLogoGravity(Gravity.END);
- assertEquals("Logo gravity should be same", Gravity.END, uiSettings.getLogoGravity());
- }
-
- @Test
- public void testLogoMargins() {
- when(projection.getContentPadding()).thenReturn(new int[]{0, 0, 0, 0});
- when(logoView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.leftMargin = 1;
- layoutParams.topMargin = 2;
- layoutParams.rightMargin = 3;
- layoutParams.bottomMargin = 4;
- uiSettings.setLogoMargins(1, 2, 3, 4);
- assertTrue("Compass margin left should be same", uiSettings.getLogoMarginLeft() == 1);
- assertTrue("Compass margin top should be same", uiSettings.getLogoMarginTop() == 2);
- assertTrue("Compass margin right should be same", uiSettings.getLogoMarginRight() == 3);
- assertTrue("Compass margin bottom should be same", uiSettings.getLogoMarginBottom() == 4);
- }
-
- @Test
- public void testAttributionEnabled() {
- when(imageView.getVisibility()).thenReturn(View.VISIBLE);
- uiSettings.setAttributionEnabled(true);
- assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled());
- }
-
- @Test
- public void testAttributionDisabled() {
- when(imageView.getVisibility()).thenReturn(View.GONE);
- uiSettings.setAttributionEnabled(false);
- assertEquals("Attribution should be disabled", false, uiSettings.isAttributionEnabled());
- }
-
- @Test
- public void testAttributionGravity() {
- when(imageView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.gravity = Gravity.END;
- uiSettings.setAttributionGravity(Gravity.END);
- assertEquals("Attribution gravity should be same", Gravity.END, uiSettings.getAttributionGravity());
- }
-
- @Test
- public void testAttributionMargins() {
- when(imageView.getLayoutParams()).thenReturn(layoutParams);
- when(projection.getContentPadding()).thenReturn(new int[]{0, 0, 0, 0});
- layoutParams.leftMargin = 1;
- layoutParams.topMargin = 2;
- layoutParams.rightMargin = 3;
- layoutParams.bottomMargin = 4;
- uiSettings.setAttributionMargins(1, 2, 3, 4);
- assertTrue("Attribution margin left should be same", uiSettings.getAttributionMarginLeft() == 1);
- assertTrue("Attribution margin top should be same", uiSettings.getAttributionMarginTop() == 2);
- assertTrue("Attribution margin right should be same", uiSettings.getAttributionMarginRight() == 3);
- assertTrue("Attribution margin bottom should be same", uiSettings.getAttributionMarginBottom() == 4);
- }
-
- @Test
- public void testRotateGesturesEnabled() {
- uiSettings.setRotateGesturesEnabled(true);
- assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testRotateGesturesDisabled() {
- uiSettings.setRotateGesturesEnabled(false);
- assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testRotateGestureChange() {
- assertEquals("Default state should be true", true, uiSettings.isRotateGestureChangeAllowed());
- uiSettings.setRotateGestureChangeAllowed(false);
- assertEquals("State should have been changed", false, uiSettings.isRotateGestureChangeAllowed());
- }
-
- @Test
- public void testRotateGestureChangeAllowed() {
- uiSettings.setRotateGesturesEnabled(false);
- assertEquals("Rotate gesture should be false", false, uiSettings.isRotateGesturesEnabled());
- uiSettings.setRotateGesturesEnabled(true);
- assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testRotateGestureChangeDisallowed() {
- assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled());
- uiSettings.setRotateGestureChangeAllowed(false);
- uiSettings.setRotateGesturesEnabled(false);
- assertEquals("Rotate gesture change should be ignored", true, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testTiltGesturesEnabled() {
- uiSettings.setTiltGesturesEnabled(true);
- assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testTiltGesturesDisabled() {
- uiSettings.setTiltGesturesEnabled(false);
- assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testTiltGestureChange() {
- assertEquals("Default state should be true", true, uiSettings.isTiltGestureChangeAllowed());
- uiSettings.setTiltGestureChangeAllowed(false);
- assertEquals("State should have been changed", false, uiSettings.isTiltGestureChangeAllowed());
- }
-
- @Test
- public void testTiltGestureChangeAllowed() {
- uiSettings.setTiltGesturesEnabled(false);
- assertEquals("Tilt gesture should be false", false, uiSettings.isTiltGesturesEnabled());
- uiSettings.setTiltGesturesEnabled(true);
- assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testTiltGestureChangeDisallowed() {
- assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled());
- uiSettings.setTiltGestureChangeAllowed(false);
- uiSettings.setTiltGesturesEnabled(false);
- assertEquals("Tilt gesture change should be ignored", true, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testZoomGesturesEnabled() {
- uiSettings.setZoomGesturesEnabled(true);
- assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testZoomGesturesDisabled() {
- uiSettings.setZoomGesturesEnabled(false);
- assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testZoomGestureChange() {
- assertEquals("Default state should be true", true, uiSettings.isZoomGestureChangeAllowed());
- uiSettings.setZoomGestureChangeAllowed(false);
- assertEquals("State should have been changed", false, uiSettings.isZoomGestureChangeAllowed());
- }
-
- @Test
- public void testZoomGestureChangeAllowed() {
- uiSettings.setZoomGesturesEnabled(false);
- assertEquals("Zoom gesture should be false", false, uiSettings.isZoomGesturesEnabled());
- uiSettings.setZoomGesturesEnabled(true);
- assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testZoomGestureChangeDisallowed() {
- assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled());
- uiSettings.setZoomGestureChangeAllowed(false);
- uiSettings.setZoomGesturesEnabled(false);
- assertEquals("Zooom gesture change should be ignored", true, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testZoomControlsEnabled() {
- uiSettings.setZoomControlsEnabled(true);
- assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled());
- }
-
- @Test
- public void testZoomControlsDisabled() {
- uiSettings.setZoomControlsEnabled(false);
- assertEquals("Zoom controls should be disabled", false, uiSettings.isZoomControlsEnabled());
- }
-
- @Test
- public void testScrollGesturesEnabled() {
- uiSettings.setScrollGesturesEnabled(true);
- assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testScrollGesturesDisabled() {
- uiSettings.setScrollGesturesEnabled(false);
- assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testScrollGestureChange() {
- assertEquals("Default state should be true", true, uiSettings.isScrollGestureChangeAllowed());
- uiSettings.setScrollGestureChangeAllowed(false);
- assertEquals("State should have been changed", false, uiSettings.isScrollGestureChangeAllowed());
- }
-
- @Test
- public void testScrollGestureChangeAllowed() {
- uiSettings.setScrollGesturesEnabled(false);
- assertEquals("Scroll gesture should be false", false, uiSettings.isScrollGesturesEnabled());
- uiSettings.setScrollGesturesEnabled(true);
- assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testScrollGestureChangeDisallowed() {
- assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled());
- uiSettings.setScrollGestureChangeAllowed(false);
- uiSettings.setScrollGesturesEnabled(false);
- assertEquals("Scroll gesture change should be ignored", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testAllGesturesEnabled() {
- uiSettings.setAllGesturesEnabled(true);
- assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
- assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
- assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
- assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testAllGesturesDisabled() {
- uiSettings.setAllGesturesEnabled(false);
- assertEquals("Rotate gesture should be enabled", false, uiSettings.isRotateGesturesEnabled());
- assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
- assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
- assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
- }
+ @InjectMocks
+ Projection projection = mock(Projection.class);
+
+ @InjectMocks
+ FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
+
+ @InjectMocks
+ CompassView compassView = mock(CompassView.class);
+
+ @InjectMocks
+ ImageView imageView = mock(ImageView.class);
+
+ @InjectMocks
+ ImageView logoView = mock(ImageView.class);
+
+ @InjectMocks
+ FrameLayout.LayoutParams layoutParams = mock(FrameLayout.LayoutParams.class);
+
+ private UiSettings uiSettings;
+
+ @Before
+ public void beforeTest() {
+ uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView);
+ }
+
+ @Test
+ public void testSanity() {
+ assertNotNull("uiSettings should not be null", uiSettings);
+ }
+
+ @Test
+ public void testCompassEnabled() {
+ when(compassView.isEnabled()).thenReturn(true);
+ uiSettings.setCompassEnabled(true);
+ assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled());
+ }
+
+ @Test
+ public void testCompassDisabled() {
+ uiSettings.setCompassEnabled(false);
+ assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled());
+ }
+
+ @Test
+ public void testCompassGravity() {
+ when(compassView.getLayoutParams()).thenReturn(layoutParams);
+ layoutParams.gravity = Gravity.START;
+ uiSettings.setCompassGravity(Gravity.START);
+ assertEquals("Compass gravity should be same", Gravity.START, uiSettings.getCompassGravity());
+ }
+
+ @Test
+ public void testCompassMargins() {
+ when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0});
+ when(compassView.getLayoutParams()).thenReturn(layoutParams);
+ layoutParams.leftMargin = 1;
+ layoutParams.topMargin = 2;
+ layoutParams.rightMargin = 3;
+ layoutParams.bottomMargin = 4;
+ uiSettings.setCompassMargins(1, 2, 3, 4);
+ assertTrue("Compass margin left should be same", uiSettings.getCompassMarginLeft() == 1);
+ assertTrue("Compass margin top should be same", uiSettings.getCompassMarginTop() == 2);
+ assertTrue("Compass margin right should be same", uiSettings.getCompassMarginRight() == 3);
+ assertTrue("Compass margin bottom should be same", uiSettings.getCompassMarginBottom() == 4);
+ }
+
+ @Test
+ public void testCompassFadeWhenFacingNorth() {
+ when(compassView.isFadeCompassViewFacingNorth()).thenReturn(true);
+ assertTrue("Compass should fade when facing north by default.", uiSettings.isCompassFadeWhenFacingNorth());
+ uiSettings.setCompassFadeFacingNorth(false);
+ when(compassView.isFadeCompassViewFacingNorth()).thenReturn(false);
+ assertFalse("Compass fading should be disabled", uiSettings.isCompassFadeWhenFacingNorth());
+ }
+
+ @Test
+ public void testLogoEnabled() {
+ uiSettings.setLogoEnabled(true);
+ assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled());
+ }
+
+ @Test
+ public void testLogoDisabled() {
+ when(logoView.getVisibility()).thenReturn(View.GONE);
+ uiSettings.setLogoEnabled(false);
+ assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled());
+ }
+
+ @Test
+ public void testLogoGravity() {
+ layoutParams.gravity = Gravity.END;
+ when(logoView.getLayoutParams()).thenReturn(layoutParams);
+ uiSettings.setLogoGravity(Gravity.END);
+ assertEquals("Logo gravity should be same", Gravity.END, uiSettings.getLogoGravity());
+ }
+
+ @Test
+ public void testLogoMargins() {
+ when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0});
+ when(logoView.getLayoutParams()).thenReturn(layoutParams);
+ layoutParams.leftMargin = 1;
+ layoutParams.topMargin = 2;
+ layoutParams.rightMargin = 3;
+ layoutParams.bottomMargin = 4;
+ uiSettings.setLogoMargins(1, 2, 3, 4);
+ assertTrue("Compass margin left should be same", uiSettings.getLogoMarginLeft() == 1);
+ assertTrue("Compass margin top should be same", uiSettings.getLogoMarginTop() == 2);
+ assertTrue("Compass margin right should be same", uiSettings.getLogoMarginRight() == 3);
+ assertTrue("Compass margin bottom should be same", uiSettings.getLogoMarginBottom() == 4);
+ }
+
+ @Test
+ public void testAttributionEnabled() {
+ when(imageView.getVisibility()).thenReturn(View.VISIBLE);
+ uiSettings.setAttributionEnabled(true);
+ assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled());
+ }
+
+ @Test
+ public void testAttributionDisabled() {
+ when(imageView.getVisibility()).thenReturn(View.GONE);
+ uiSettings.setAttributionEnabled(false);
+ assertEquals("Attribution should be disabled", false, uiSettings.isAttributionEnabled());
+ }
+
+ @Test
+ public void testAttributionGravity() {
+ when(imageView.getLayoutParams()).thenReturn(layoutParams);
+ layoutParams.gravity = Gravity.END;
+ uiSettings.setAttributionGravity(Gravity.END);
+ assertEquals("Attribution gravity should be same", Gravity.END, uiSettings.getAttributionGravity());
+ }
+
+ @Test
+ public void testAttributionMargins() {
+ when(imageView.getLayoutParams()).thenReturn(layoutParams);
+ when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0});
+ layoutParams.leftMargin = 1;
+ layoutParams.topMargin = 2;
+ layoutParams.rightMargin = 3;
+ layoutParams.bottomMargin = 4;
+ uiSettings.setAttributionMargins(1, 2, 3, 4);
+ assertTrue("Attribution margin left should be same", uiSettings.getAttributionMarginLeft() == 1);
+ assertTrue("Attribution margin top should be same", uiSettings.getAttributionMarginTop() == 2);
+ assertTrue("Attribution margin right should be same", uiSettings.getAttributionMarginRight() == 3);
+ assertTrue("Attribution margin bottom should be same", uiSettings.getAttributionMarginBottom() == 4);
+ }
+
+ @Test
+ public void testRotateGesturesEnabled() {
+ uiSettings.setRotateGesturesEnabled(true);
+ assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
+ }
+
+ @Test
+ public void testRotateGesturesDisabled() {
+ uiSettings.setRotateGesturesEnabled(false);
+ assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled());
+ }
+
+ @Test
+ public void testRotateGestureChange() {
+ assertEquals("Default state should be true", true, uiSettings.isRotateGestureChangeAllowed());
+ uiSettings.setRotateGestureChangeAllowed(false);
+ assertEquals("State should have been changed", false, uiSettings.isRotateGestureChangeAllowed());
+ }
+
+ @Test
+ public void testRotateGestureChangeAllowed() {
+ uiSettings.setRotateGesturesEnabled(false);
+ assertEquals("Rotate gesture should be false", false, uiSettings.isRotateGesturesEnabled());
+ uiSettings.setRotateGesturesEnabled(true);
+ assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled());
+ }
+
+ @Test
+ public void testRotateGestureChangeDisallowed() {
+ assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled());
+ uiSettings.setRotateGestureChangeAllowed(false);
+ uiSettings.setRotateGesturesEnabled(false);
+ assertEquals("Rotate gesture change should be ignored", true, uiSettings.isRotateGesturesEnabled());
+ }
+
+ @Test
+ public void testTiltGesturesEnabled() {
+ uiSettings.setTiltGesturesEnabled(true);
+ assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
+ }
+
+ @Test
+ public void testTiltGesturesDisabled() {
+ uiSettings.setTiltGesturesEnabled(false);
+ assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
+ }
+
+ @Test
+ public void testTiltGestureChange() {
+ assertEquals("Default state should be true", true, uiSettings.isTiltGestureChangeAllowed());
+ uiSettings.setTiltGestureChangeAllowed(false);
+ assertEquals("State should have been changed", false, uiSettings.isTiltGestureChangeAllowed());
+ }
+
+ @Test
+ public void testTiltGestureChangeAllowed() {
+ uiSettings.setTiltGesturesEnabled(false);
+ assertEquals("Tilt gesture should be false", false, uiSettings.isTiltGesturesEnabled());
+ uiSettings.setTiltGesturesEnabled(true);
+ assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled());
+ }
+
+ @Test
+ public void testTiltGestureChangeDisallowed() {
+ assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled());
+ uiSettings.setTiltGestureChangeAllowed(false);
+ uiSettings.setTiltGesturesEnabled(false);
+ assertEquals("Tilt gesture change should be ignored", true, uiSettings.isTiltGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomGesturesEnabled() {
+ uiSettings.setZoomGesturesEnabled(true);
+ assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomGesturesDisabled() {
+ uiSettings.setZoomGesturesEnabled(false);
+ assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomGestureChange() {
+ assertEquals("Default state should be true", true, uiSettings.isZoomGestureChangeAllowed());
+ uiSettings.setZoomGestureChangeAllowed(false);
+ assertEquals("State should have been changed", false, uiSettings.isZoomGestureChangeAllowed());
+ }
+
+ @Test
+ public void testZoomGestureChangeAllowed() {
+ uiSettings.setZoomGesturesEnabled(false);
+ assertEquals("Zoom gesture should be false", false, uiSettings.isZoomGesturesEnabled());
+ uiSettings.setZoomGesturesEnabled(true);
+ assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomGestureChangeDisallowed() {
+ assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled());
+ uiSettings.setZoomGestureChangeAllowed(false);
+ uiSettings.setZoomGesturesEnabled(false);
+ assertEquals("Zooom gesture change should be ignored", true, uiSettings.isZoomGesturesEnabled());
+ }
+
+ @Test
+ public void testZoomControlsEnabled() {
+ uiSettings.setZoomControlsEnabled(true);
+ assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled());
+ }
+
+ @Test
+ public void testZoomControlsDisabled() {
+ uiSettings.setZoomControlsEnabled(false);
+ assertEquals("Zoom controls should be disabled", false, uiSettings.isZoomControlsEnabled());
+ }
+
+ @Test
+ public void testScrollGesturesEnabled() {
+ uiSettings.setScrollGesturesEnabled(true);
+ assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
+ }
+
+ @Test
+ public void testScrollGesturesDisabled() {
+ uiSettings.setScrollGesturesEnabled(false);
+ assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
+ }
+
+ @Test
+ public void testScrollGestureChange() {
+ assertEquals("Default state should be true", true, uiSettings.isScrollGestureChangeAllowed());
+ uiSettings.setScrollGestureChangeAllowed(false);
+ assertEquals("State should have been changed", false, uiSettings.isScrollGestureChangeAllowed());
+ }
+
+ @Test
+ public void testScrollGestureChangeAllowed() {
+ uiSettings.setScrollGesturesEnabled(false);
+ assertEquals("Scroll gesture should be false", false, uiSettings.isScrollGesturesEnabled());
+ uiSettings.setScrollGesturesEnabled(true);
+ assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled());
+ }
+
+ @Test
+ public void testScrollGestureChangeDisallowed() {
+ assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled());
+ uiSettings.setScrollGestureChangeAllowed(false);
+ uiSettings.setScrollGesturesEnabled(false);
+ assertEquals("Scroll gesture change should be ignored", true, uiSettings.isScrollGesturesEnabled());
+ }
+
+ @Test
+ public void testAllGesturesEnabled() {
+ uiSettings.setAllGesturesEnabled(true);
+ assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
+ assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
+ assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
+ assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
+ }
+
+ @Test
+ public void testAllGesturesDisabled() {
+ uiSettings.setAllGesturesEnabled(false);
+ assertEquals("Rotate gesture should be enabled", false, uiSettings.isRotateGesturesEnabled());
+ assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
+ assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
+ assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
index 24f28567ba..c9ce19dc85 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
@@ -22,84 +22,85 @@ import static org.mockito.Mockito.when;
public class MyLocationViewSettingsTest {
- @InjectMocks
- Projection projection = mock(Projection.class);
-
- @InjectMocks
- MyLocationView myLocationView = mock(MyLocationView.class);
-
- @InjectMocks
- TrackingSettings trackingSettings = mock(TrackingSettings.class);
-
- @InjectMocks
- FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
-
- private MyLocationViewSettings locationViewSettings;
-
- @Before
- public void beforeTest() {
- locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener);
- }
-
- @Test
- public void testSanity() {
- assertNotNull("should not be null", locationViewSettings);
- }
-
- @Test
- public void testForegroundDrawables() {
- Drawable foregroundDrawable = mock(Drawable.class);
- Drawable foregroundBearingDrawable = mock(Drawable.class);
- Drawable.ConstantState constantState = mock(Drawable.ConstantState.class);
- when(foregroundDrawable.getConstantState()).thenReturn(constantState);
- when(constantState.newDrawable()).thenReturn(foregroundDrawable);
- locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable);
- assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable());
- assertEquals("foreground bearing should match", foregroundBearingDrawable, locationViewSettings.getForegroundBearingDrawable());
- }
-
- @Test
- public void testBackgroundDrawable() {
- Drawable backgroundDrawable = mock(Drawable.class);
- int[] offset = new int[]{1, 2, 3, 4};
- locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset);
- assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable());
- assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset()));
- }
-
- @Test
- public void testForegroundTint() {
- int color = Color.RED;
- locationViewSettings.setForegroundTintColor(Color.RED);
- assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
- }
-
- @Test
- public void testForegroundTransparentTint() {
- int color = Color.TRANSPARENT;
- locationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
- assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
- }
-
- @Test
- public void testBackgroundTint() {
- int color = Color.RED;
- locationViewSettings.setBackgroundTintColor(Color.RED);
- assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
- }
-
- @Test
- public void testBackgroundTransparentTint() {
- int color = Color.TRANSPARENT;
- locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
- assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
- }
-
- @Test
- public void testEnabled() {
- assertFalse("initial state should be false", locationViewSettings.isEnabled());
- locationViewSettings.setEnabled(true);
- assertTrue("state should be true", locationViewSettings.isEnabled());
- }
+ @InjectMocks
+ Projection projection = mock(Projection.class);
+
+ @InjectMocks
+ MyLocationView myLocationView = mock(MyLocationView.class);
+
+ @InjectMocks
+ TrackingSettings trackingSettings = mock(TrackingSettings.class);
+
+ @InjectMocks
+ FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
+
+ private MyLocationViewSettings locationViewSettings;
+
+ @Before
+ public void beforeTest() {
+ locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener);
+ }
+
+ @Test
+ public void testSanity() {
+ assertNotNull("should not be null", locationViewSettings);
+ }
+
+ @Test
+ public void testForegroundDrawables() {
+ Drawable foregroundDrawable = mock(Drawable.class);
+ Drawable foregroundBearingDrawable = mock(Drawable.class);
+ Drawable.ConstantState constantState = mock(Drawable.ConstantState.class);
+ when(foregroundDrawable.getConstantState()).thenReturn(constantState);
+ when(constantState.newDrawable()).thenReturn(foregroundDrawable);
+ locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable);
+ assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable());
+ assertEquals("foreground bearing should match", foregroundBearingDrawable,
+ locationViewSettings.getForegroundBearingDrawable());
+ }
+
+ @Test
+ public void testBackgroundDrawable() {
+ Drawable backgroundDrawable = mock(Drawable.class);
+ int[] offset = new int[] {1, 2, 3, 4};
+ locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset);
+ assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable());
+ assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset()));
+ }
+
+ @Test
+ public void testForegroundTint() {
+ int color = Color.RED;
+ locationViewSettings.setForegroundTintColor(Color.RED);
+ assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
+ }
+
+ @Test
+ public void testForegroundTransparentTint() {
+ int color = Color.TRANSPARENT;
+ locationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
+ assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
+ }
+
+ @Test
+ public void testBackgroundTint() {
+ int color = Color.RED;
+ locationViewSettings.setBackgroundTintColor(Color.RED);
+ assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
+ }
+
+ @Test
+ public void testBackgroundTransparentTint() {
+ int color = Color.TRANSPARENT;
+ locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
+ assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
+ }
+
+ @Test
+ public void testEnabled() {
+ assertFalse("initial state should be false", locationViewSettings.isEnabled());
+ locationViewSettings.setEnabled(true);
+ assertTrue("state should be true", locationViewSettings.isEnabled());
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FilterTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FilterTest.java
index 3e312d3b0a..933bf05b39 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FilterTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FilterTest.java
@@ -2,89 +2,101 @@ package com.mapbox.mapboxsdk.style.layers;
import org.junit.Test;
-import static org.junit.Assert.*;
-import static com.mapbox.mapboxsdk.style.layers.Filter.*;
+import static com.mapbox.mapboxsdk.style.layers.Filter.all;
+import static com.mapbox.mapboxsdk.style.layers.Filter.any;
+import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
+import static com.mapbox.mapboxsdk.style.layers.Filter.gt;
+import static com.mapbox.mapboxsdk.style.layers.Filter.gte;
+import static com.mapbox.mapboxsdk.style.layers.Filter.has;
+import static com.mapbox.mapboxsdk.style.layers.Filter.in;
+import static com.mapbox.mapboxsdk.style.layers.Filter.lt;
+import static com.mapbox.mapboxsdk.style.layers.Filter.lte;
+import static com.mapbox.mapboxsdk.style.layers.Filter.neq;
+import static com.mapbox.mapboxsdk.style.layers.Filter.none;
+import static com.mapbox.mapboxsdk.style.layers.Filter.notHas;
+import static com.mapbox.mapboxsdk.style.layers.Filter.notIn;
+import static org.junit.Assert.assertArrayEquals;
/**
* Tests for Filter
*/
public class FilterTest {
- @Test
- public void testAll() {
- assertArrayEquals(all().toArray(), new Object[]{"all"});
- assertArrayEquals(
- all(eq("key", 2), neq("key", 3)).toArray(),
- new Object[]{"all", new Object[]{"==", "key", 2}, new Object[]{"!=", "key", 3}}
- );
- }
-
- @Test
- public void testAny() {
- assertArrayEquals(any().toArray(), new Object[]{"any"});
- assertArrayEquals(
- any(eq("key", 2), neq("key", 3)).toArray(),
- new Object[]{"any", new Object[]{"==", "key", 2}, new Object[]{"!=", "key", 3}}
- );
- }
-
- @Test
- public void testNone() {
- assertArrayEquals(none().toArray(), new Object[]{"none"});
- assertArrayEquals(
- none(eq("key", 2), neq("key", 3)).toArray(),
- new Object[]{"none", new Object[]{"==", "key", 2}, new Object[]{"!=", "key", 3}}
- );
- }
-
- @Test
- public void testHas() {
- assertArrayEquals(has("key").toArray(), new Object[]{"has", "key"});
- }
-
- @Test
- public void testHasNot() {
- assertArrayEquals(notHas("key").toArray(), new Object[]{"!has", "key"});
- }
-
- @Test
- public void testEq() {
- assertArrayEquals(eq("key", 1).toArray(), new Object[]{"==", "key", 1});
-
- }
-
- @Test
- public void testNeq() {
- assertArrayEquals(neq("key", 1).toArray(), new Object[]{"!=", "key", 1});
- }
-
- @Test
- public void testGt() {
- assertArrayEquals(gt("key", 1).toArray(), new Object[]{">", "key", 1});
- }
-
- @Test
- public void testGte() {
- assertArrayEquals(gte("key", 1).toArray(), new Object[]{">=", "key", 1});
- }
-
- @Test
- public void testLt() {
- assertArrayEquals(lt("key", 1).toArray(), new Object[]{"<", "key", 1});
- }
-
- @Test
- public void testLte() {
- assertArrayEquals(lte("key", 1).toArray(), new Object[]{"<=", "key", 1});
- }
-
- @Test
- public void testIn() {
- assertArrayEquals(in("key", 1, 2, "Aap").toArray(), new Object[]{"in", "key", 1, 2, "Aap"});
- }
-
- @Test
- public void testNotIn() {
- assertArrayEquals(notIn("key", 1, 2, "Noot").toArray(), new Object[]{"!in", "key", 1, 2, "Noot"});
- }
+ @Test
+ public void testAll() {
+ assertArrayEquals(all().toArray(), new Object[] {"all"});
+ assertArrayEquals(
+ all(eq("key", 2), neq("key", 3)).toArray(),
+ new Object[] {"all", new Object[] {"==", "key", 2}, new Object[] {"!=", "key", 3}}
+ );
+ }
+
+ @Test
+ public void testAny() {
+ assertArrayEquals(any().toArray(), new Object[] {"any"});
+ assertArrayEquals(
+ any(eq("key", 2), neq("key", 3)).toArray(),
+ new Object[] {"any", new Object[] {"==", "key", 2}, new Object[] {"!=", "key", 3}}
+ );
+ }
+
+ @Test
+ public void testNone() {
+ assertArrayEquals(none().toArray(), new Object[] {"none"});
+ assertArrayEquals(
+ none(eq("key", 2), neq("key", 3)).toArray(),
+ new Object[] {"none", new Object[] {"==", "key", 2}, new Object[] {"!=", "key", 3}}
+ );
+ }
+
+ @Test
+ public void testHas() {
+ assertArrayEquals(has("key").toArray(), new Object[] {"has", "key"});
+ }
+
+ @Test
+ public void testHasNot() {
+ assertArrayEquals(notHas("key").toArray(), new Object[] {"!has", "key"});
+ }
+
+ @Test
+ public void testEq() {
+ assertArrayEquals(eq("key", 1).toArray(), new Object[] {"==", "key", 1});
+
+ }
+
+ @Test
+ public void testNeq() {
+ assertArrayEquals(neq("key", 1).toArray(), new Object[] {"!=", "key", 1});
+ }
+
+ @Test
+ public void testGt() {
+ assertArrayEquals(gt("key", 1).toArray(), new Object[] {">", "key", 1});
+ }
+
+ @Test
+ public void testGte() {
+ assertArrayEquals(gte("key", 1).toArray(), new Object[] {">=", "key", 1});
+ }
+
+ @Test
+ public void testLt() {
+ assertArrayEquals(lt("key", 1).toArray(), new Object[] {"<", "key", 1});
+ }
+
+ @Test
+ public void testLte() {
+ assertArrayEquals(lte("key", 1).toArray(), new Object[] {"<=", "key", 1});
+ }
+
+ @Test
+ public void testIn() {
+ assertArrayEquals(in("key", 1, 2, "Aap").toArray(), new Object[] {"in", "key", 1, 2, "Aap"});
+ }
+
+ @Test
+ public void testNotIn() {
+ assertArrayEquals(notIn("key", 1, 2, "Noot").toArray(), new Object[] {"!in", "key", 1, 2, "Noot"});
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java
index 1106009ea8..4e82ca2318 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java
@@ -2,28 +2,29 @@ package com.mapbox.mapboxsdk.style.layers;
import org.junit.Test;
-import static com.mapbox.mapboxsdk.style.layers.Function.*;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
-
-import static org.junit.Assert.*;
+import static com.mapbox.mapboxsdk.style.layers.Function.stop;
+import static com.mapbox.mapboxsdk.style.layers.Function.zoom;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Tests Function
*/
public class FunctionTest {
- @Test
- public void testZoomFunction() {
- Function zoomF = zoom(
- stop(1f, lineBlur(1f)),
- stop(10f, lineBlur(20f))
- );
+ @Test
+ public void testZoomFunction() {
+ Function zoomF = zoom(
+ stop(1f, lineBlur(1f)),
+ stop(10f, lineBlur(20f))
+ );
- assertNotNull(zoomF.toValueObject());
- assertArrayEquals(
- new Object[]{new Object[]{1f, 1f}, new Object[]{10f, 20f}},
- (Object[]) zoomF.toValueObject().get("stops")
- );
- }
+ assertNotNull(zoomF.toValueObject());
+ assertArrayEquals(
+ new Object[] {new Object[] {1f, 1f}, new Object[] {10f, 20f}},
+ (Object[]) zoomF.toValueObject().get("stops")
+ );
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java
index 8be0d2c663..94a6dc2194 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java
@@ -1,17 +1,20 @@
package com.mapbox.mapboxsdk.telemetry;
import org.junit.Test;
+
import okhttp3.internal.Util;
+
import static junit.framework.Assert.assertEquals;
public class HttpTransportTest {
- @Test
- public void testNonAsciiUserAgent() {
+ @Test
+ public void testNonAsciiUserAgent() {
- final String swedishUserAgent = "Sveriges Fjäll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT";
- final String asciiVersion = "Sveriges Fj?ll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT";
+ final String swedishUserAgent = "Sveriges Fjäll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT";
+ final String asciiVersion = "Sveriges Fj?ll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT";
- assertEquals("asciiVersion and swedishUserAgent should match", asciiVersion, Util.toHumanReadableAscii(swedishUserAgent));
- }
+ assertEquals("asciiVersion and swedishUserAgent should match", asciiVersion,
+ Util.toHumanReadableAscii(swedishUserAgent));
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java
index aa0a4edd13..dd4c7b25ee 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java
@@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.List;
import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertArrayEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyByte;
@@ -29,227 +28,227 @@ import static org.mockito.Mockito.when;
public class MockParcel {
- public static Parcelable obtain(@NonNull Parcelable object) {
- return obtain(object, 0);
+ public static Parcelable obtain(@NonNull Parcelable object) {
+ return obtain(object, 0);
+ }
+
+ public static Parcelable obtain(@NonNull Parcelable object, int describeContentsValue) {
+ testDescribeContents(object, describeContentsValue);
+ testParcelableArray(object);
+ return testParcelable(object);
+ }
+
+ public static Parcelable testParcelable(@NonNull Parcelable object) {
+ Parcel parcel = ParcelMocker.obtain(object);
+ object.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+
+ try {
+ Field field = object.getClass().getDeclaredField("CREATOR");
+ field.setAccessible(true);
+ Class<?> creatorClass = field.getType();
+ Object fieldValue = field.get(object);
+ Method myMethod = creatorClass.getDeclaredMethod("createFromParcel", Parcel.class);
+ return (Parcelable) myMethod.invoke(fieldValue, parcel);
+ } catch (Exception exception) {
+ return null;
}
+ }
+
+ public static void testParcelableArray(@NonNull Parcelable object) {
+ Parcelable[] objects = new Parcelable[] {object};
+ Parcel parcel = ParcelMocker.obtain(objects);
+ parcel.writeParcelableArray(objects, 0);
+ parcel.setDataPosition(0);
+ Parcelable[] parcelableArray = parcel.readParcelableArray(object.getClass().getClassLoader());
+ assertArrayEquals("parcel should match initial object", objects, parcelableArray);
+ }
+
+ public static void testDescribeContents(@NonNull Parcelable object, int describeContentsValue) {
+ if (describeContentsValue == 0) {
+ assertEquals("\nExpecting a describeContents() value of 0 for a " + object.getClass().getSimpleName()
+ + " instance." + "\nYou can provide a different value for describeContentValue through the obtain method.",
+ 0,
+ object.describeContents());
+ } else {
+ assertEquals("Expecting a describeContents() value of " + describeContentsValue,
+ describeContentsValue,
+ object.describeContents());
+ }
+ }
+
+ private static class ParcelMocker {
- public static Parcelable obtain(@NonNull Parcelable object, int describeContentsValue) {
- testDescribeContents(object, describeContentsValue);
- testParcelableArray(object);
- return testParcelable(object);
+ public static Parcel obtain(@NonNull Parcelable target) {
+ Parcel parcel = new ParcelMocker(target).getMockedParcel();
+ target.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ return parcel;
}
- public static Parcelable testParcelable(@NonNull Parcelable object) {
- Parcel parcel = ParcelMocker.obtain(object);
- object.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- try {
- Field field = object.getClass().getDeclaredField("CREATOR");
- field.setAccessible(true);
- Class<?> creatorClass = field.getType();
- Object fieldValue = field.get(object);
- Method myMethod = creatorClass.getDeclaredMethod("createFromParcel", Parcel.class);
- return (Parcelable) myMethod.invoke(fieldValue, parcel);
- } catch (Exception e) {
- return null;
- }
+ public static Parcel obtain(@NonNull Parcelable[] targets) {
+ if (targets.length == 0) {
+ throw new IllegalArgumentException("The passed argument may not be empty");
+ }
+ Parcel parcel = new ParcelMocker(targets[0]).getMockedParcel();
+ parcel.writeParcelableArray(targets, 0);
+ parcel.setDataPosition(0);
+ return parcel;
}
- public static void testParcelableArray(@NonNull Parcelable object) {
- Parcelable[] objects = new Parcelable[]{object};
- Parcel parcel = ParcelMocker.obtain(objects);
- parcel.writeParcelableArray(objects, 0);
- parcel.setDataPosition(0);
- Parcelable[] parcelableArray = parcel.readParcelableArray(object.getClass().getClassLoader());
- assertArrayEquals("parcel should match initial object", objects, parcelableArray);
+ private List<Object> objects;
+ private Object object;
+ private Parcel mockedParcel;
+ private int position;
+
+ private ParcelMocker(Object o) {
+ this.object = o;
+ mockedParcel = mock(Parcel.class);
+ objects = new ArrayList<>();
+ setupMock();
}
- public static void testDescribeContents(@NonNull Parcelable object, int describeContentsValue) {
- if (describeContentsValue == 0) {
- assertEquals("\nExpecting a describeContents() value of 0 for a " + object.getClass().getSimpleName() + " instance." +
- "\nYou can provide a different value for describeContentValue through the obtain method.",
- 0,
- object.describeContents());
- } else {
- assertEquals("Expecting a describeContents() value of " + describeContentsValue,
- describeContentsValue,
- object.describeContents());
- }
+ private Parcel getMockedParcel() {
+ return mockedParcel;
}
- private static class ParcelMocker {
+ private void setupMock() {
+ setupWrites();
+ setupReads();
+ setupOthers();
+ }
- public static Parcel obtain(@NonNull Parcelable target) {
- Parcel parcel = new ParcelMocker(target).getMockedParcel();
- target.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- return parcel;
+ private void setupWrites() {
+ Answer<Void> writeValueAnswer = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ Object parameter = invocation.getArguments()[0];
+ objects.add(parameter);
+ return null;
}
-
- public static Parcel obtain(@NonNull Parcelable[] targets) {
- if (targets.length == 0) {
- throw new IllegalArgumentException("The passed argument may not be empty");
+ };
+ Answer<Void> writeArrayAnswer = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ Object[] parameters = (Object[]) invocation.getArguments()[0];
+ objects.add(parameters.length);
+ for (Object o : parameters) {
+ objects.add(o);
+ }
+ return null;
+ }
+ };
+ Answer<Void> writeIntArrayAnswer = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ int[] parameters = (int[]) invocation.getArguments()[0];
+ if (parameters != null) {
+ objects.add(parameters.length);
+ for (Object o : parameters) {
+ objects.add(o);
}
- Parcel parcel = new ParcelMocker(targets[0]).getMockedParcel();
- parcel.writeParcelableArray(targets, 0);
- parcel.setDataPosition(0);
- return parcel;
+ } else {
+ objects.add(-1);
+ }
+ return null;
}
+ };
+ doAnswer(writeValueAnswer).when(mockedParcel).writeByte(anyByte());
+ doAnswer(writeValueAnswer).when(mockedParcel).writeLong(anyLong());
+ doAnswer(writeValueAnswer).when(mockedParcel).writeString(anyString());
+ doAnswer(writeValueAnswer).when(mockedParcel).writeInt(anyInt());
+ doAnswer(writeIntArrayAnswer).when(mockedParcel).writeIntArray(any(int[].class));
+ doAnswer(writeValueAnswer).when(mockedParcel).writeDouble(anyDouble());
+ doAnswer(writeValueAnswer).when(mockedParcel).writeFloat(anyFloat());
+ doAnswer(writeValueAnswer).when(mockedParcel).writeParcelable(any(Parcelable.class), eq(0));
+ doAnswer(writeArrayAnswer).when(mockedParcel).writeParcelableArray(any(Parcelable[].class), eq(0));
+ }
- private List<Object> objects;
- private Object object;
- private Parcel mockedParcel;
- private int position;
-
- private ParcelMocker(Object o) {
- this.object = o;
- mockedParcel = mock(Parcel.class);
- objects = new ArrayList<>();
- setupMock();
+ private void setupReads() {
+ when(mockedParcel.readInt()).then(new Answer<Integer>() {
+ @Override
+ public Integer answer(InvocationOnMock invocation) throws Throwable {
+ return (Integer) objects.get(position++);
}
-
- private Parcel getMockedParcel() {
- return mockedParcel;
+ });
+ when(mockedParcel.readByte()).thenAnswer(new Answer<Byte>() {
+ @Override
+ public Byte answer(InvocationOnMock invocation) throws Throwable {
+ return (Byte) objects.get(position++);
}
-
- private void setupMock() {
- setupWrites();
- setupReads();
- setupOthers();
+ });
+ when(mockedParcel.readLong()).thenAnswer(new Answer<Long>() {
+ @Override
+ public Long answer(InvocationOnMock invocation) throws Throwable {
+ return (Long) objects.get(position++);
}
-
- private void setupWrites() {
- Answer<Void> writeValueAnswer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object parameter = invocation.getArguments()[0];
- objects.add(parameter);
- return null;
- }
- };
- Answer<Void> writeArrayAnswer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] parameters = (Object[]) invocation.getArguments()[0];
- objects.add(parameters.length);
- for (Object o : parameters) {
- objects.add(o);
- }
- return null;
- }
- };
- Answer<Void> writeIntArrayAnswer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- int[] parameters = (int[]) invocation.getArguments()[0];
- if (parameters != null) {
- objects.add(parameters.length);
- for (Object o : parameters) {
- objects.add(o);
- }
- } else {
- objects.add(-1);
- }
- return null;
- }
- };
- doAnswer(writeValueAnswer).when(mockedParcel).writeByte(anyByte());
- doAnswer(writeValueAnswer).when(mockedParcel).writeLong(anyLong());
- doAnswer(writeValueAnswer).when(mockedParcel).writeString(anyString());
- doAnswer(writeValueAnswer).when(mockedParcel).writeInt(anyInt());
- doAnswer(writeIntArrayAnswer).when(mockedParcel).writeIntArray(any(int[].class));
- doAnswer(writeValueAnswer).when(mockedParcel).writeDouble(anyDouble());
- doAnswer(writeValueAnswer).when(mockedParcel).writeFloat(anyFloat());
- doAnswer(writeValueAnswer).when(mockedParcel).writeParcelable(any(Parcelable.class), eq(0));
- doAnswer(writeArrayAnswer).when(mockedParcel).writeParcelableArray(any(Parcelable[].class), eq(0));
+ });
+ when(mockedParcel.readString()).thenAnswer(new Answer<String>() {
+ @Override
+ public String answer(InvocationOnMock invocation) throws Throwable {
+ return (String) objects.get(position++);
+ }
+ });
+ when(mockedParcel.readDouble()).thenAnswer(new Answer<Double>() {
+ @Override
+ public Double answer(InvocationOnMock invocation) throws Throwable {
+ return (Double) objects.get(position++);
+ }
+ });
+ when(mockedParcel.readFloat()).thenAnswer(new Answer<Float>() {
+ @Override
+ public Float answer(InvocationOnMock invocation) throws Throwable {
+ return (Float) objects.get(position++);
}
+ });
+ when(mockedParcel.readParcelable(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Parcelable>() {
+ @Override
+ public Parcelable answer(InvocationOnMock invocation) throws Throwable {
+ return (Parcelable) objects.get(position++);
+ }
+ });
+ when(mockedParcel.readParcelableArray(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Object[]>() {
+ @Override
+ public Object[] answer(InvocationOnMock invocation) throws Throwable {
+ int size = (Integer) objects.get(position++);
+ Field field = object.getClass().getDeclaredField("CREATOR");
+ field.setAccessible(true);
+ Class<?> creatorClass = field.getType();
+ Object fieldValue = field.get(object);
+ Method myMethod = creatorClass.getDeclaredMethod("newArray", int.class);
+ Object[] array = (Object[]) myMethod.invoke(fieldValue, size);
+ for (int i = 0; i < size; i++) {
+ array[i] = objects.get(position++);
+ }
+ return array;
+ }
+ });
+ when(mockedParcel.createIntArray()).then(new Answer<int[]>() {
+ @Override
+ public int[] answer(InvocationOnMock invocation) throws Throwable {
+ int size = (Integer) objects.get(position++);
+ if (size == -1) {
+ return null;
+ }
- private void setupReads() {
- when(mockedParcel.readInt()).then(new Answer<Integer>() {
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- return (Integer) objects.get(position++);
- }
- });
- when(mockedParcel.readByte()).thenAnswer(new Answer<Byte>() {
- @Override
- public Byte answer(InvocationOnMock invocation) throws Throwable {
- return (Byte) objects.get(position++);
- }
- });
- when(mockedParcel.readLong()).thenAnswer(new Answer<Long>() {
- @Override
- public Long answer(InvocationOnMock invocation) throws Throwable {
- return (Long) objects.get(position++);
- }
- });
- when(mockedParcel.readString()).thenAnswer(new Answer<String>() {
- @Override
- public String answer(InvocationOnMock invocation) throws Throwable {
- return (String) objects.get(position++);
- }
- });
- when(mockedParcel.readDouble()).thenAnswer(new Answer<Double>() {
- @Override
- public Double answer(InvocationOnMock invocation) throws Throwable {
- return (Double) objects.get(position++);
- }
- });
- when(mockedParcel.readFloat()).thenAnswer(new Answer<Float>() {
- @Override
- public Float answer(InvocationOnMock invocation) throws Throwable {
- return (Float) objects.get(position++);
- }
- });
- when(mockedParcel.readParcelable(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Parcelable>() {
- @Override
- public Parcelable answer(InvocationOnMock invocation) throws Throwable {
- return (Parcelable) objects.get(position++);
- }
- });
- when(mockedParcel.readParcelableArray(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Object[]>() {
- @Override
- public Object[] answer(InvocationOnMock invocation) throws Throwable {
- int size = (Integer) objects.get(position++);
- Field field = object.getClass().getDeclaredField("CREATOR");
- field.setAccessible(true);
- Class<?> creatorClass = field.getType();
- Object fieldValue = field.get(object);
- Method myMethod = creatorClass.getDeclaredMethod("newArray", int.class);
- Object[] array = (Object[]) myMethod.invoke(fieldValue, size);
- for (int i = 0; i < size; i++) {
- array[i] = objects.get(position++);
- }
- return array;
- }
- });
- when(mockedParcel.createIntArray()).then(new Answer<int[]>() {
- @Override
- public int[] answer(InvocationOnMock invocation) throws Throwable {
- int size = (Integer) objects.get(position++);
- if (size == -1) {
- return null;
- }
-
- int[] array = new int[size];
- for (int i = 0; i < size; i++) {
- array[i] = (Integer) objects.get(position++);
- }
-
- return array;
- }
- });
+ int[] array = new int[size];
+ for (int i = 0; i < size; i++) {
+ array[i] = (Integer) objects.get(position++);
+ }
+
+ return array;
}
+ });
+ }
- private void setupOthers() {
- doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- position = ((Integer) invocation.getArguments()[0]);
- return null;
- }
- }).when(mockedParcel).setDataPosition(anyInt());
+ private void setupOthers() {
+ doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ position = ((Integer) invocation.getArguments()[0]);
+ return null;
}
+ }).when(mockedParcel).setDataPosition(anyInt());
}
+ }
}