mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
ExploreMapFragment.java: modify Overlay onItemSingleTapUp code to place Overlay above other Overlays
Before these changes, when a user tapped on an icon in the Explore Map, the icon and label would often appear underneath other icons, making it difficult or impossible to read the text on the label. These changes add two methods that search for and move the icon/label Overlays above all other icons and overlays. These two methods are called when the user taps on an icon.
This commit is contained in:
parent
230604f5ef
commit
649bd199e7
1 changed files with 49 additions and 0 deletions
|
|
@ -782,6 +782,9 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
clickedMarker = nearbyBaseMarker;
|
||||
passInfoToSheet(place);
|
||||
|
||||
//Move the overlay to the top so it can be fully seen.
|
||||
moveOverlayToTop(getOverlay(item));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -801,6 +804,52 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the specified Overlay above all other Overlays. This prevents other Overlays from
|
||||
* obstructing it. Upon failure, this method returns early.
|
||||
* @param overlay The Overlay to move.
|
||||
*/
|
||||
private void moveOverlayToTop (Overlay overlay) {
|
||||
if (overlay == null || binding == null || binding.mapView.getOverlays() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean successfulRemoval = binding.mapView.getOverlays().remove(overlay);
|
||||
if (!successfulRemoval) {
|
||||
return;
|
||||
}
|
||||
|
||||
binding.mapView.getOverlays().add(overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a linear search for the first Overlay which contains the specified OverlayItem.
|
||||
*
|
||||
* @param item The OverlayItem contained within the first target Overlay.
|
||||
* @return The first Overlay which contains the specified OverlayItem or null if the Overlay
|
||||
* could not be found.
|
||||
*/
|
||||
private Overlay getOverlay (OverlayItem item) {
|
||||
if (item == null || binding == null || binding.mapView.getOverlays() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < binding.mapView.getOverlays().size(); i++) {
|
||||
if (binding.mapView.getOverlays().get(i) instanceof ItemizedOverlayWithFocus) {
|
||||
ItemizedOverlayWithFocus overlay =
|
||||
(ItemizedOverlayWithFocus)binding.mapView.getOverlays().get(i);
|
||||
|
||||
for (int j = 0; j < overlay.size(); j++) {
|
||||
if (overlay.getItem(j) == item) {
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the specific Media object from the mediaList field.
|
||||
* @param url The specific Media's image URL.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue