Skip to content

Commit 2c299d8

Browse files
committed
fix ANY condition
1 parent c160be0 commit 2c299d8

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/main/java/com/reandroid/arsc/value/AttributeDataFormat.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,24 @@ public static int sum(AttributeDataFormat[] typeValues){
158158
return result;
159159
}
160160

161-
public static AttributeDataFormat[] decodeValueTypes(int data){
161+
public static AttributeDataFormat[] decodeValueTypes(int data) {
162+
if ((data & 0xffff) == 0xffff) {
163+
return new AttributeDataFormat[]{ANY};
164+
}
162165
data &= 0xff;
163-
if(data == 0){
166+
if (data == 0) {
164167
return null;
165168
}
166-
if(data == 0xff){
167-
return new AttributeDataFormat[]{AttributeDataFormat.ANY};
168-
}
169-
final int length = Integer.bitCount(data);
170-
final AttributeDataFormat[] results = new AttributeDataFormat[length];
171-
for(int i = 0, j = 0; i < VALUE_TYPES.length - 1 && j < results.length; ++i){
172-
if(((data >> i) & 1) != 0){
173-
results[j++] = VALUE_TYPES[i];
169+
AttributeDataFormat[] results = new AttributeDataFormat[Integer.bitCount(data)];
170+
AttributeDataFormat[] valueTypes = VALUE_TYPES;
171+
int length = valueTypes.length - 1;
172+
int j = 0;
173+
for (int i = 0; i < length; i++) {
174+
if ((data & 1) != 0) {
175+
results[j] = valueTypes[i];
176+
j ++;
174177
}
178+
data = data >> 1;
175179
}
176180
return results;
177181
}

0 commit comments

Comments
 (0)