summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-08-17 08:53:33 +0200
committerGitHub <noreply@github.com>2016-08-17 08:53:33 +0200
commitfff0ebaa1754aabd9584c994624b7b948bec95af (patch)
tree745006b1a761856e6651738cd7d26e0e08c6cbbf /platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow
parent0062cf2f949fe1b0080e2de45aaf0b3d5e028bf3 (diff)
downloadqtlocation-mapboxgl-fff0ebaa1754aabd9584c994624b7b948bec95af.tar.gz
5859 generate sanity tests (#5870)
* [android] #5859 - generate espresso tests [android] #5859 - cleanup xml files, use all the same resource id for map view [android] #5859 - update scripts [android] #5859 - update Activity to match mapboxMap naming [android] #5859 - make SurfaceViewMediaControlActivity compatible [android] #5859 - make MarkerViewScaleActivity test generation compatible [android] #5859 - make PolygonActivity test generation compatible [android] #5859 - integration within make file [android] #5859 - made CameraPostion generation safe [android] #5859 - generate sanity test [android] #5859 - add generated test cases [android] #5859 - add documentation * [android] #5859 - remove generated files, introduce gen package, added gitignore to package * [android] #5859 - regenerated test code * [android] #5859 - added AWS gradle plugin + bitrise configuration * [android] #5859 - fixes running locally without having the properties configured * [android] #6010 - remove python from android sdk * [android] #5859 - update docs about aws gradle plugin
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java75
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java18
2 files changed, 49 insertions, 44 deletions
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 5b2cae5e04..cf522d7f39 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
@@ -29,8 +29,9 @@ import com.mapbox.mapboxsdk.testapp.R;
/**
* Shows how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter
*/
-public class DynamicInfoWindowAdapterActivity extends AppCompatActivity {
+public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implements OnMapReadyCallback {
+ private MapboxMap mapboxMap;
private MapView mapView;
private LatLng paris = new LatLng(48.864716, 2.349014);
@@ -44,45 +45,47 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity {
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);
- mapView.getMapAsync(new OnMapReadyCallback() {
+ //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 onMapReady(@NonNull final MapboxMap mapboxMap) {
- //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));
+ 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));
}
private MarkerView addMarker(MapboxMap mapboxMap) {
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 2c74702253..8066dbc60e 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
@@ -13,20 +13,21 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.annotations.Icon;
-import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.IconFactory;
+import com.mapbox.mapboxsdk.annotations.Marker;
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.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarker;
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarkerOptions;
-import com.mapbox.mapboxsdk.maps.MapView;
public class InfoWindowAdapterActivity extends AppCompatActivity {
private MapView mapView;
+ private MapboxMap mapboxMap;
private IconFactory iconFactory;
private Drawable iconDrawable;
@@ -51,14 +52,15 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- addMarkers(mapboxMap);
- addCustomInfoWindowAdapter(mapboxMap);
+ public void onMapReady(@NonNull MapboxMap map) {
+ mapboxMap = map;
+ addMarkers();
+ addCustomInfoWindowAdapter();
}
});
}
- private void addMarkers(MapboxMap mapboxMap){
+ 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"));
@@ -79,7 +81,7 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
return marker;
}
- private void addCustomInfoWindowAdapter(MapboxMap mapboxMap){
+ private void addCustomInfoWindowAdapter() {
mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
private int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);