@@ -926,27 +926,34 @@ private void parsePublicTag(XMLElement element) throws XmlEncodeException {
926926 }
927927 int resourceId = encodeResult .value ;
928928 int packageId = (resourceId >> 24 ) & 0xff ;
929+ PackageBlock packageBlock = this .packageBlock ;
929930 int i = packageBlock .getId ();
930- if (i == 0 ){
931+ if (i == 0 ) {
931932 packageBlock .setId (packageId );
932- }else if (i != packageId ){
933+ } else if (i != packageId ) {
933934 return ;
934935 }
935936 int typeId = (resourceId >> 16 ) & 0xff ;
936- if (typeId == 0 ){
937+ if (typeId == 0 ) {
937938 throw new XmlEncodeException ("Type id is zero: '" + id + "', "
938939 + element .getDebugText ());
939940 }
940941 TypeString typeString = packageBlock .getOrCreateTypeString (typeId , type );
941942 typeId = typeString .getId ();
942- TypeBlock typeBlock = packageBlock .getOrCreateTypeBlock ((byte ) typeId , "" );
943- Entry entry = typeBlock .getOrCreateEntry (resourceId & 0xffff );
944- entry .setName (name , true );
945- if (isInitializeIds () && typeBlock .isTypeId ()){
946- entry .setValueAsBoolean (false );
947- ValueHeader header = entry .getHeader ();
948- header .setPublic (true );
949- header .setWeak (true );
943+ int entryId = resourceId & 0xffff ;
944+ ResourceEntry resourceEntry = packageBlock .getResource (typeId , entryId );
945+ if (resourceEntry != null && !resourceEntry .isEmpty ()) {
946+ resourceEntry .setName (name );
947+ } else {
948+ TypeBlock typeBlock = packageBlock .getOrCreateTypeBlock ((byte ) typeId , "" );
949+ Entry entry = typeBlock .getOrCreateEntry (entryId );
950+ entry .setName (name , true );
951+ if (isInitializeIds () && typeBlock .isTypeId ()) {
952+ entry .setValueAsBoolean (false );
953+ ValueHeader header = entry .getHeader ();
954+ header .setPublic (true );
955+ header .setWeak (true );
956+ }
950957 }
951958 }
952959 private void parseResourcesAttributes (XmlPullParser parser ) throws IOException , XmlPullParserException {
0 commit comments