package com.github.pengrad.testtest;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;

import com.androidmapsextensions.ClusterOptions;
import com.androidmapsextensions.ClusterOptionsProvider;
import com.androidmapsextensions.Marker;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;

import java.util.List;

/**
 * stas
 * 8/28/15
 */
public class ClusterIconProvider implements ClusterOptionsProvider {

    Resources resources;
    Paint paint;

    public ClusterIconProvider(Resources resources) {
        this.resources = resources;

        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.WHITE);
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setTextSize(15);
    }

    @Override
    public ClusterOptions getClusterOptions(List<Marker> list) {
        Rect bounds = new Rect();
        Bitmap base = BitmapFactory.decodeResource(resources, R.drawable.m1);
        Bitmap bitmap = base.copy(Bitmap.Config.ARGB_8888, true);

        String text = String.valueOf(list.size());
        paint.getTextBounds(text, 0, text.length(), bounds);
        float x = bitmap.getWidth() / 2.0f;
        float y = (bitmap.getHeight() - bounds.height()) / 2.0f - bounds.top;

        Canvas canvas = new Canvas(bitmap);
        canvas.drawText(text, x, y, paint);
        BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bitmap);

        return new ClusterOptions().anchor(0.5f, 0.5f).icon(icon);
    }
}

@@ -700,16 +700,33 @@
 t paint;
+%0A    Bitmap base;
 %0A%0A    pu
@@ -975,16 +975,88 @@
 ize(15);
+%0A%0A        base = BitmapFactory.decodeResource(resources, R.drawable.m1);
 %0A    %7D%0A%0A
@@ -1138,120 +1138,8 @@
 ) %7B%0A
-        Rect bounds = new Rect();%0A        Bitmap base = BitmapFactory.decodeResource(resources, R.drawable.m1);%0A
     
@@ -1197,24 +1197,58 @@
 88, true);%0A%0A
+        Rect bounds = new Rect();%0A
         Stri

Clean ClusterIconProvider