[android] Refactor annotations API

Remove unimplemented properties.
Correct defintions of equals() and hasCode().
Add setOnInfoWindowClickListener and remove old method from Marker.
Refactor showInfoWindow() to remove need for exposing internal method.
Make select/deselectMarker public. Add getSelectedMarker.
Fix bug where you couldn't reselect a closed info window.
Add empty constructor to LatLng and LatLngZoom.
Fixes #2546
Fixes #2631
Fixes #2448
This commit is contained in:
Leith Bade
2015-10-08 13:22:28 +11:00
parent 8b79a8d6e6
commit 927b4c6dbe
20 changed files with 299 additions and 729 deletions

View File

@@ -137,11 +137,20 @@ public class MainActivity extends AppCompatActivity {
mMapView.setOnMarkerClickListener(new MapView.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
Snackbar.make(mCoordinatorLayout, "Custom Marker Click Listener", Snackbar.LENGTH_SHORT).show();
Snackbar.make(mCoordinatorLayout, "Marker Click Listener for " + marker.getTitle(), Snackbar.LENGTH_SHORT).show();
return false;
}
});
mMapView.setOnInfoWindowClickListener(new MapView.OnInfoWindowClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
Snackbar.make(mCoordinatorLayout, "InfoWindow Click Listener for " + marker.getTitle(), Snackbar.LENGTH_SHORT).show();
marker.hideInfoWindow();
return true;
}
});
mMapView.setOnMyLocationChangeListener(new MapView.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(@Nullable Location location) {
@@ -430,18 +439,7 @@ public class MainActivity extends AppCompatActivity {
final MarkerOptions cheeseRoom = generateMarker("Cheese Room", "The only air conditioned room on the property", dogIcon, 38.531577, -122.010646);
markerOptionsList.add(cheeseRoom);
List<Marker> markers = mMapView.addMarkers(markerOptionsList);
// need to call this after adding markers to map, click event hook into InfoWindow needs refactoring
final Marker backLotMarker = markers.get(0);
backLotMarker.setInfoWindowOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Toast.makeText(getApplicationContext(), "Custom Info Touch Listener!!", Toast.LENGTH_SHORT).show();
backLotMarker.hideInfoWindow();
return true;
}
});
List<Marker> markers = mMapView.addMarkers(markerOptionsList);
}
private MarkerOptions generateMarker(String title, String snippet, Sprite icon, double lat, double lng){