ClusterManager repaint markers of Google maps v2 utils

Seems that I found a workaround.

ClusterManager uses a renderer, in this case it inherits from DefaultClusterRenderer which uses a internal cache, a cache of markers that are added to map. You can access directly to the added markers on the map, I don't use the info window, so i add marker options.title() an ID for later find this marker, so:

@Override
protected void onBeforeClusterItemRendered(TweetClusterItem item, MarkerOptions markerOptions) {

     .... Blabla code....          
            markerOptions.title(Long.toString(tweet.getId()));
     .... Blabla code....


}

and when I want to reload the clusterItem I call this method:

/**
  * Workarround to repaint markers
  * @param item item to repaint
 */
  public void reloadMarker(TweetClusterItem item) {

        MarkerManager.Collection markerCollection = clusterManager.getMarkerCollection();
        Collection<Marker> markers = markerCollection.getMarkers();
        String strId = Long.toString(item.getTweet().getId());
        for (Marker m : markers) {
            if (strId.equals(m.getTitle())) {
                m.setIcon( ICON TO SET);
                break;
            }
        }

    }

Maybe is a little hacky but it works and I din't found any other way to do this. If you found another better way, please share :)


mClusterManager.cluster();

force re-clustering items when you after added new item.