Last active
April 19, 2020 17:17
-
-
Save CallumCarmicheal/6810e48b837020adfb7f32b27df212e6 to your computer and use it in GitHub Desktop.
Fix for fragment null string comparison inside DefaultClusterRenderer Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GmapClusterRendererFixedNullRef extends DefaultClusterRenderer<GmapClusterItem> | |
{ | |
// .... | |
@Override | |
protected void onClusterItemUpdated(GmapClusterItem item, Marker marker) | |
{ | |
//super.onClusterItemUpdated(item, marker); | |
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
// | |
// // Source / Credits: https://gist.github.com/CallumCarmicheal/6810e48b837020adfb7f32b27df212e6 | |
// | |
// Replaced logic with a fix due to a bug where the marker .getTitle is null! | |
// This is the code from inside the com.google.maps.android.clustering.view.DefaultClusterRenderer class licensed under apache | |
// | |
// I REPEAT THIS IS NOT MY ORIGINAL WORK, THE COPYRIGHT HOLDER FOR THE FOLLOWING CODE IS GOOGLE 2013 LICENSED UNDER APACHE !!!! | |
// | |
// ==== TERMS OF APACHE LICENSE ==== | |
// | |
// Permissions: | |
// - Commercial use | |
// - Distribution | |
// - Modification | |
// - Patent use | |
// - Private use | |
// | |
// Conditions: | |
// - License and copyright notice | |
// - State changes | |
// | |
// Limitations: | |
// - Liability | |
// - Trademark use | |
// - Warranty | |
// | |
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
boolean changed = false; | |
// Update marker text if the item text changed - same logic as adding marker in CreateMarkerTask.perform() | |
if (item.getTitle() != null || item.getSnippet() != null) | |
{ | |
// FIX: FIX for issue where marker.getTitle is null | |
if (marker.getTitle() == null || !marker.getTitle().equals(item.getTitle())) | |
{ | |
marker.setTitle(item.getTitle()); | |
changed = true; | |
} | |
// FIX: FIX for issue where marker.getSnippet is null | |
if (marker.getSnippet() == null || !marker.getSnippet().equals(item.getSnippet())) | |
{ | |
marker.setSnippet(item.getSnippet()); | |
changed = true; | |
} | |
} | |
else if (item.getSnippet() != null && !item.getSnippet().equals(marker.getTitle())) | |
{ | |
marker.setTitle(item.getSnippet()); | |
changed = true; | |
} | |
else if (item.getTitle() != null && !item.getTitle().equals(marker.getTitle())) | |
{ | |
marker.setTitle(item.getTitle()); | |
changed = true; | |
} | |
// Update marker position if the item changed position | |
if (!marker.getPosition().equals(item.getPosition())) | |
{ | |
marker.setPosition(item.getPosition()); | |
changed = true; | |
} | |
if (changed && marker.isInfoWindowShown()) | |
{ | |
// Force a refresh of marker info window contents | |
marker.showInfoWindow(); | |
} | |
} | |
// .... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment