All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.reandroid.arsc.array.ResXmlAttributeArray Maven / Gradle / Ivy

There is a newer version: 1.3.5
Show newest version
/*
  *  Copyright (C) 2022 github.com/REAndroid
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
package com.reandroid.arsc.array;

import com.reandroid.arsc.base.Block;
import com.reandroid.arsc.base.BlockArray;
import com.reandroid.arsc.header.HeaderBlock;
import com.reandroid.arsc.io.BlockReader;
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
import com.reandroid.arsc.item.ShortItem;
import com.reandroid.json.JSONConvert;
import com.reandroid.json.JSONArray;
import com.reandroid.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class ResXmlAttributeArray extends BlockArray
        implements Comparator, JSONConvert {
    private final HeaderBlock mHeaderBlock;
    private final ShortItem mAttributeStart;
    private final ShortItem mAttributeCount;
    private final ShortItem mAttributesUnitSize;
    public ResXmlAttributeArray(HeaderBlock headerBlock,
                                ShortItem attributeStart,
                                ShortItem attributeCount,
                                ShortItem attributesUnitSize){
        this.mHeaderBlock=headerBlock;
        this.mAttributeStart=attributeStart;
        this.mAttributeCount=attributeCount;
        this.mAttributesUnitSize=attributesUnitSize;
    }

    public int removeUndefinedAttributes(){
        List undefinedAttributes = listUndefined();
        super.remove(undefinedAttributes);
        return undefinedAttributes.size();
    }
    public List listUndefined(){
        List results = new ArrayList<>();
        ResXmlAttribute[] attributes = getChildes();
        for(int i = 0; i < attributes.length; i++){
            ResXmlAttribute attribute = attributes[i];
            if(attribute != null && attribute.isUndefined()){
                results.add(attribute);
            }
        }
        return results;
    }
    public void setAttributesUnitSize(int size){
        ResXmlAttribute[] attributes=getChildes();
        for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy