ICONLOADER - fix monochrome icon crash for ClockDrawableWrapper

This commit is contained in:
Alex Sim committed 2026-09-27 13:09:20 +02:00
1 parent 43cb328886
commit c6bc1d733f
1 file changed
+5
@@ -255,6 +255,11 @@ public class ClockDrawableWrapper extends CustomAdaptiveIconDrawable implements
result.hourLayerIndex = hourLayerIndex;
result.minuteLayerIndex = minuteLayerIndex;
result.secondLayerIndex = secondLayerIndex;
// The monochrome layer can have fewer layers than the colored one (e.g. no second hand)
int layerCount = ((LayerDrawable) ((AdaptiveIconDrawable) icon).getForeground()).getNumberOfLayers();
if (result.hourLayerIndex >= layerCount) result.hourLayerIndex = INVALID_VALUE;
if (result.minuteLayerIndex >= layerCount) result.minuteLayerIndex = INVALID_VALUE;
if (result.secondLayerIndex >= layerCount) result.secondLayerIndex = INVALID_VALUE;
return result;
}