some fixes to make NewPipe not crash when layouting

This commit is contained in:
Julian Winkler
2023-08-23 09:16:45 +02:00
parent 1474d8d3e1
commit 28cd0006bc
13 changed files with 171 additions and 29 deletions

View File

@@ -323,9 +323,22 @@ public final class AssetManager {
break;
}
}
ident = 0;
if (valueItem != null && valueItem.getValueType() == ValueType.REFERENCE) {
while (valueItem.getValueType() == ValueType.REFERENCE) {
ident = valueItem.getData();
valueItem = null;
if (ident == 0)
break;
valueItem = tableBlockSearch(ident).pickOne().getResValue();
if (valueItem == null)
break;
}
}
if (valueItem == null)
return false;
outValue.resourceId = 0;
outValue.resourceId = ident;
outValue.type = valueItem.getType();
outValue.data = valueItem.getData();
outValue.assetCookie = -1;
@@ -925,31 +938,20 @@ public final class AssetManager {
if (valueItem.getValueType() == ValueType.REFERENCE) {
while (valueItem.getValueType() == ValueType.REFERENCE) {
resId = valueItem.getData();
valueItem = null;
if (resId == 0)
break;
valueItem = tableBlockSearch(resId).pickOne().getResValue();
if (valueItem == null)
entry = tableBlockSearch(resId).pickOne();
if (entry == null || entry.getResValue() == null)
break;
valueItem = entry.getResValue();
}
outValues[d + AssetManager.STYLE_RESOURCE_ID] = resId;
if (valueItem != null) {
outValues[d + AssetManager.STYLE_TYPE] = valueItem.getType();
outValues[d + AssetManager.STYLE_DATA] = valueItem.getData();
outValues[d + AssetManager.STYLE_ASSET_COOKIE] = getCookie(valueItem);
outIndices[++outIndices[0]] = i;
} else {
outValues[d + AssetManager.STYLE_TYPE] = -1;
outValues[d + AssetManager.STYLE_ASSET_COOKIE] = -1;
}
} else {
outValues[d+AssetManager.STYLE_RESOURCE_ID] = 0;
outValues[d+AssetManager.STYLE_TYPE] = valueItem.getType();
outValues[d+AssetManager.STYLE_DATA] = valueItem.getData();
outValues[d+AssetManager.STYLE_ASSET_COOKIE] = getCookie(valueItem);
outIndices[++outIndices[0]] = i;
}
outValues[d + AssetManager.STYLE_TYPE] = valueItem.getType();
outValues[d + AssetManager.STYLE_DATA] = valueItem.getData();
outValues[d + AssetManager.STYLE_ASSET_COOKIE] = getCookie(valueItem);
outIndices[++outIndices[0]] = i;
}
return true;
}

View File

@@ -314,7 +314,8 @@ public class TypedArray {
return defValue;
}
throw new UnsupportedOperationException("Can't convert to color: type=0x" + Integer.toHexString(type));
Log.e(Resources.TAG, "Can't convert to color: type=0x" + Integer.toHexString(type));
return defValue;
}
/**
@@ -331,6 +332,8 @@ public class TypedArray {
if (getValueAt(index * AssetManager.STYLE_NUM_ENTRIES, value)) {
if (value.type == -1)
return null;
if (value.type == TypedValue.TYPE_REFERENCE && value.data == 0)
return null;
return mResources.loadColorStateList(value, value.resourceId);
}
return null;