I have an app that use android-maps-utils and glide for marker icons.
I got an error report using Firebase crash reporting which I can\'t track in source code because
I have the same environment (maps-utils + custom renderer + Glide) and the same error IllegalArgumentException: Unmanaged descriptor
.
I solved the error by checking if the marker is "valid" before setting the icon, using the methods DefaultClusterRenderer.getCluster(Marker)
and DefaultClusterRenderer.getClusterItem(Marker)
. If both return null
, I don't do anything on the onResourceReady(...)
method.
In your case I would try the following change to CustomSimpleTarget
:
private class CustomSimpleTarget extends SimpleTarget {
Sucursal sucursal;
Marker markerToChange = null;
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation super GlideDrawable> glideAnimation) {
if (getCluster(markerToChange) != null || getClusterItem(markerToChange) != null) {
mImageView.setImageDrawable(resource);
//currentSelectedItem is the current element selected in the map (Sucursal type)
//mIconGenerator is a: CustomIconGenerator extends IconGenerator
if (currentSelectedItem != null && sucursal.idalmacen.contentEquals(currentSelectedItem.idalmacen))
mIconGenerator.customIconBackground.useSelectionColor(true, ContextCompat.getColor(mContext, R.color.colorAccent));
else
mIconGenerator.customIconBackground.useSelectionColor(false, 0);
Bitmap icon = mIconGenerator.makeIcon();
//GlideShortcutDrawable is a WeakReference<>(drawable)
sucursal.setGlideShortCutDrawable(resource);
markerToChange.setIcon(BitmapDescriptorFactory.fromBitmap(icon));
}
}
}
PS.: I can reproduce the problem easily on a slow device and clearing the app cache before testing (to force Glide to load from network). Then I open the map and perform some zoom in/out before any markers load.