LayerDrawable: handle null Drawables

This fixes a NullPointerException with the SponsorBlock UI of the
Tubular NewPipe fork
This commit is contained in:
Julian Winkler 2025-04-09 12:38:12 +02:00
parent 0b5ab83933
commit 0c0af3d1be

View file

@ -78,13 +78,17 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
int length = layers.length;
ChildDrawable[] r = new ChildDrawable[length];
int j = 0;
for (int i = 0; i < length; i++) {
r[i] = new ChildDrawable();
r[i].mDrawable = layers[i];
if (layers[i] == null)
continue;
r[j] = new ChildDrawable();
r[j].mDrawable = layers[i];
layers[i].setCallback(this);
mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations();
j++;
}
mLayerState.mNum = length;
mLayerState.mNum = j;
mLayerState.mChildren = r;
ensurePadding();