You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
LayerDrawable: handle null Drawables
This fixes a NullPointerException with the SponsorBlock UI of the Tubular NewPipe fork
This commit is contained in:
@@ -78,13 +78,17 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
|
|||||||
int length = layers.length;
|
int length = layers.length;
|
||||||
ChildDrawable[] r = new ChildDrawable[length];
|
ChildDrawable[] r = new ChildDrawable[length];
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
r[i] = new ChildDrawable();
|
if (layers[i] == null)
|
||||||
r[i].mDrawable = layers[i];
|
continue;
|
||||||
|
r[j] = new ChildDrawable();
|
||||||
|
r[j].mDrawable = layers[i];
|
||||||
layers[i].setCallback(this);
|
layers[i].setCallback(this);
|
||||||
mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations();
|
mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations();
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
mLayerState.mNum = length;
|
mLayerState.mNum = j;
|
||||||
mLayerState.mChildren = r;
|
mLayerState.mChildren = r;
|
||||||
|
|
||||||
ensurePadding();
|
ensurePadding();
|
||||||
|
|||||||
Reference in New Issue
Block a user