fix issue on attribute format encoding

This commit is contained in:
REAndroid 2023-05-02 17:27:45 +02:00
parent 0ec2b3fe1c
commit 1037986e95
3 changed files with 10 additions and 11 deletions

View File

@ -63,8 +63,7 @@ class XMLValuesEncoderAttr extends XMLValuesEncoderBag{
AttributeValueType[] valueTypes = AttributeValueType
.valuesOf(parentElement.getAttributeValue("formats"));
formatItem.setDataLow((short) (0xffff &
AttributeValueType.getByte(valueTypes)));
formatItem.setDataLow((short) (0xff & AttributeValueType.sumValues(valueTypes)));
bagIndex++;

View File

@ -89,7 +89,7 @@ public class AttributeBagItem {
if(valueType == null || getItemType()!=AttributeItemType.FORMAT){
return false;
}
int value = 0xff & valueType.getByte();
int value = 0xff & valueType.sumValues();
int dataLow = 0xffff & getBagItem().getData();
return (dataLow & value) == value;
}
@ -97,7 +97,7 @@ public class AttributeBagItem {
if(valueType == null || getItemType()!=AttributeItemType.FORMAT){
return false;
}
int value = 0xff & valueType.getByte();
int value = 0xff & valueType.sumValues();
int dataLow = 0xffff & getBagItem().getData();
return (dataLow == value);
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2022 github.com/REAndroid
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -34,7 +34,7 @@ import java.util.*;
AttributeValueType(byte b) {
this.mByte=b;
}
public byte getByte(){
public byte sumValues(){
return mByte;
}
@Override
@ -65,18 +65,18 @@ import java.util.*;
}
return builder.toString();
}
public static byte getByte(AttributeValueType[] valueTypes){
public static int sumValues(AttributeValueType[] valueTypes){
if(valueTypes==null){
return 0;
}
int i=0;
int result = 0;
for(AttributeValueType vt:valueTypes){
if(vt==null){
if(vt == null){
continue;
}
i=i|(0xff & vt.mByte);
result = result | (0xff & vt.mByte);
}
return (byte) (0xff & i);
return result;
}
public static AttributeValueType valueOf(byte b){
AttributeValueType[] all=values();