微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.content.res.XmlResourceParser的实例源码

项目:NanoIconPackLite    文件LiteIconActivityV1.java   
private Set<String> getIcons() {
//        Set<String> iconSet = new TreeSet<>(); // 字母顺序
        Set<String> iconSet = new LinkedHashSet<>(); // 录入顺序
        XmlResourceParser parser = getResources().getXml(R.xml.drawable);
        try {
            int event = parser.getEventType();
            while (event != XmlPullParser.END_DOCUMENT) {
                if (event == XmlPullParser.START_TAG) {
                    if (!"item".equals(parser.getName())) {
                        event = parser.next();
                        continue;
                    }
                    iconSet.add(parser.getAttributeValue(null,"drawable"));
                }
                event = parser.next();
            }
        } catch (Exception e) {
            e.printstacktrace();
        }
        return iconSet;
    }
项目:GxIconAndroid    文件AppfilterReader.java   
private boolean init(@NonNull Resources resources) {
    try {
        XmlResourceParser parser = resources.getXml(R.xml.appfilter);
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                if (!"item".equals(parser.getName())) {
                    event = parser.next();
                    continue;
                }
                String drawable = parser.getAttributeValue(null,"drawable");
                if (TextUtils.isEmpty(drawable)) {
                    event = parser.next();
                    continue;
                }
                String component = parser.getAttributeValue(null,"component");
                if (TextUtils.isEmpty(component)) {
                    event = parser.next();
                    continue;
                }
                Matcher matcher = componentPattern.matcher(component);
                if (!matcher.matches()) {
                    event = parser.next();
                    continue;
                }
                dataList.add(new Bean(matcher.group(1),matcher.group(2),drawable));
            }
            event = parser.next();
        }
        return true;
    } catch (Exception e) {
        e.printstacktrace();
    }
    return false;
}
项目:QiangHongBao    文件TabParser.java   
private void parse() {
    try {
        parser.next();
        int eventType = parser.getEventType();

        while (eventType != XmlResourceParser.END_DOCUMENT) {
            if(eventType == XmlResourceParser.START_TAG) {
                parseNewTab(parser);
            } else if(eventType == XmlResourceParser.END_TAG) {
                if (parser.getName().equals("tab")) {
                    if (workingTab != null) {
                        tabs.add(workingTab);
                        workingTab = null;
                    }
                }
            }

            eventType = parser.next();
        }
    } catch (IOException | XmlPullParserException e) {
        e.printstacktrace();
        throw new TabParserException();
    }
}
项目:q-mail    文件AccountSetupBasics.java   
private Provider findProviderForDomain(String domain) {
    try {
        XmlResourceParser xml = getResources().getXml(R.xml.providers);
        int xmlEventType;
        Provider provider = null;
        while ((xmlEventType = xml.next()) != XmlResourceParser.END_DOCUMENT) {
            if (xmlEventType == XmlResourceParser.START_TAG
                    && "provider".equals(xml.getName())
                    && domain.equalsIgnoreCase(getXmlAttribute(xml,"domain"))) {
                provider = new Provider();
                provider.id = getXmlAttribute(xml,"id");
                provider.label = getXmlAttribute(xml,"label");
                provider.domain = getXmlAttribute(xml,"domain");
                provider.note = getXmlAttribute(xml,"note");
            } else if (xmlEventType == XmlResourceParser.START_TAG
                       && "incoming".equals(xml.getName())
                       && provider != null) {
                provider.incomingUriTemplate = new URI(getXmlAttribute(xml,"uri"));
                provider.incomingUsernameTemplate = getXmlAttribute(xml,"username");
            } else if (xmlEventType == XmlResourceParser.START_TAG
                       && "outgoing".equals(xml.getName())
                       && provider != null) {
                provider.outgoingUriTemplate = new URI(getXmlAttribute(xml,"uri"));
                provider.outgoingUsernameTemplate = getXmlAttribute(xml,"username");
            } else if (xmlEventType == XmlResourceParser.END_TAG
                       && "provider".equals(xml.getName())
                       && provider != null) {
                return provider;
            }
        }
    } catch (Exception e) {
        Timber.e(e,"Error while trying to load provider settings.");
    }
    return null;
}
项目:LaunchEnr    文件DefaultLayoutParser.java   
@Override
public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException,IOException {
    final int groupDepth = parser.getDepth();
    int type;
    long addedId = -1;
    while ((type = parser.next()) != XmlPullParser.END_TAG ||
            parser.getDepth() > groupDepth) {
        if (type != XmlPullParser.START_TAG || addedId > -1) {
            continue;
        }
        final String fallback_item_name = parser.getName();
        if (TAG_FAVORITE.equals(fallback_item_name)) {
            addedId = mChildParser.parseAndAdd(parser);
        }
    }
    return addedId;
}
项目:LaunchEnr    文件IconThemer.java   
private Drawable getRoundIcon(Context context,String packageName,int iconDpi) {

        mPackageManager = context.getPackageManager();

        try {
            Resources resourcesForApplication = mPackageManager.getResourcesForApplication(packageName);
            AssetManager assets = resourcesForApplication.getAssets();
            XmlResourceParser parseXml = assets.openXmlResourceParser("AndroidManifest.xml");
            int eventType;
            while ((eventType = parseXml.nextToken()) != XmlPullParser.END_DOCUMENT)
                if (eventType == XmlPullParser.START_TAG && parseXml.getName().equals("application"))
                    for (int i = 0; i < parseXml.getAttributeCount(); i++)
                        if (parseXml.getAttributeName(i).equals("roundIcon"))
                            return resourcesForApplication.getDrawableForDensity(Integer.parseInt(parseXml.getAttributeValue(i).substring(1)),iconDpi,context.getTheme());
            parseXml.close();
        }
        catch (Exception ex) {
            ex.printstacktrace();
        }
        return null;
    }
项目:Hitalk    文件FloatingSearchView.java   
public void inflateMenu(@MenuRes int menuRes) {
    if(menuRes == 0) return;
    if (isInEditMode()) return;
    getActivity().getMenuInflater().inflate(menuRes,mActionMenu.getMenu());

    XmlResourceParser parser = null;
    try {
        //noinspection ResourceType
        parser = getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser,attrs);
    } catch (XmlPullParserException | IOException e) {
        // should not happens
        throw new InflateException("Error parsing menu XML",e);
    } finally {
        if (parser != null) parser.close();
    }
}
项目:simple-keyboard    文件KeyboardLayoutSet.java   
private void parseKeyboardLayoutSet(final Resources res,final int resId)
        throws XmlPullParserException,IOException {
    final XmlResourceParser parser = res.getXml(resId);
    try {
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            final int event = parser.next();
            if (event == XmlPullParser.START_TAG) {
                final String tag = parser.getName();
                if (TAG_KEYBOARD_SET.equals(tag)) {
                    parseKeyboardLayoutSetContent(parser);
                } else {
                    throw new XmlParseUtils.IllegalStartTag(parser,tag,TAG_KEYBOARD_SET);
                }
            }
        }
    } finally {
        parser.close();
    }
}
项目:AndroidDvbDriver    文件DeviceFilterXmlEquivalenceTester.java   
private static Set<DeviceFilter> getDeviceData(Resources resources,int xmlResourceId) {
    Set<DeviceFilter> ans = new HashSet<>();
    try {
        XmlResourceParser xml = resources.getXml(xmlResourceId);

        xml.next();
        int eventType;
        while ((eventType = xml.getEventType()) != XmlPullParser.END_DOCUMENT) {

            switch (eventType) {
                case XmlPullParser.START_TAG:
                    if (xml.getName().equals("usb-device")) {
                        AttributeSet as = Xml.asAttributeSet(xml);
                        Integer vendorId = parseInt( as.getAttributeValue(null,"vendor-id"));
                        Integer productId = parseInt( as.getAttributeValue(null,"product-id"));
                        ans.add(new DeviceFilter(vendorId,productId,null));
                    }
                    break;
            }
            xml.next();
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ans;
}
项目:UnityNativeShare    文件UnitySSContentProvider.java   
/**
 * Parse and return {@link PathStrategy} for given authority as defined in
 * {@link #Meta_DATA_FILE_PROVIDER_PATHS} {@code &lt;Meta-data>}.
 *
 * @see #getPathStrategy(Context,String)
 */
private static PathStrategy parsePathStrategy(Context context,String authority)
        throws IOException,XmlPullParserException {
    final SimplePathStrategy strat = new SimplePathStrategy(authority);
    final ProviderInfo info = context.getPackageManager()
            .resolveContentProvider(authority,PackageManager.GET_Meta_DATA);
    final XmlResourceParser in = info.loadXmlMetaData(
            context.getPackageManager(),Meta_DATA_FILE_PROVIDER_PATHS);
    //if (in == null) {
    //    throw new IllegalArgumentException(
    //            "Missing " + Meta_DATA_FILE_PROVIDER_PATHS + " Meta-data");
    //}

    File target = null;
    target = buildpath(DEVICE_ROOT,".");
    if (target != null) {
        strat.addRoot("devroot",target);
    }

    return strat;
}
项目:QiangHongBao    文件TabParser.java   
private Integer getColorValue(int attrIndex,XmlResourceParser parser) {
    // Modify the >>>
    String valueResource = parser.getAttributeValue(attrIndex);
    if(!TextUtils.isEmpty(valueResource) && valueResource.startsWith("?")){ // 引用主题属性
        valueResource = valueResource.replace("?","@"); // 替换?
        int attr = context.getResources().getIdentifier(valueResource,"attr",context.getPackageName()); // 找出属性Id
        if(attr != 0){
            TypedArray array = context.obtainStyledAttributes(new int[]{attr}); //解析属性值
            return array.getColor(0,0);
        }
    }
    // <<<

    int colorResource = parser.getAttributeResourceValue(attrIndex,0);

    if (colorResource != 0) {
        return ContextCompat.getColor(context,colorResource);
    }

    try {
        return Color.parseColor(parser.getAttributeValue(attrIndex));
    } catch (Exception ignored) {
        return null;
    }
}
项目:VirtualHook    文件VAccountManagerService.java   
private void generateServicesMap(List<ResolveInfo> services,Map<String,AuthenticatorInfo> map,IAccountParser accountParser) {
    for (ResolveInfo info : services) {
        XmlResourceParser parser = accountParser.getParser(mContext,info.serviceInfo,AccountManager.AUTHENTICATOR_Meta_DATA_NAME);
        if (parser != null) {
            try {
                AttributeSet attributeSet = Xml.asAttributeSet(parser);
                int type;
                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
                    // nothing to do
                }
                if (AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME.equals(parser.getName())) {
                    AuthenticatorDescription desc = parseAuthenticatorDescription(
                            accountParser.getResources(mContext,info.serviceInfo.applicationInfo),info.serviceInfo.packageName,attributeSet);
                    if (desc != null) {
                        map.put(desc.type,new AuthenticatorInfo(desc,info.serviceInfo));
                    }
                }
            } catch (Exception e) {
                e.printstacktrace();
            }
        }
    }
}
项目:SimpleUILauncher    文件DefaultLayoutParser.java   
@Override
public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException,IOException {
    final int groupDepth = parser.getDepth();
    int type;
    long addedId = -1;
    while ((type = parser.next()) != XmlPullParser.END_TAG ||
            parser.getDepth() > groupDepth) {
        if (type != XmlPullParser.START_TAG || addedId > -1) {
            continue;
        }
        final String fallback_item_name = parser.getName();
        if (TAG_FAVORITE.equals(fallback_item_name)) {
            addedId = mChildParser.parseAndAdd(parser);
        } else {
            Log.e(TAG,"Fallback groups can contain only favorites,found "
                    + fallback_item_name);
        }
    }
    return addedId;
}
项目:boohee_v5.6    文件SupportMenuInflater.java   
public void inflate(int menuRes,Menu menu) {
    if (menu instanceof SupportMenu) {
        XmlResourceParser parser = null;
        try {
            parser = this.mContext.getResources().getLayout(menuRes);
            parseMenu(parser,Xml.asAttributeSet(parser),menu);
            if (parser != null) {
                parser.close();
            }
        } catch (XmlPullParserException e) {
            throw new InflateException("Error inflating menu XML",e);
        } catch (IOException e2) {
            throw new InflateException("Error inflating menu XML",e2);
        } catch (Throwable th) {
            if (parser != null) {
                parser.close();
            }
        }
    } else {
        super.inflate(menuRes,menu);
    }
}
项目:FlickLauncher    文件DefaultLayoutParser.java   
@Override
public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException,found "
                    + fallback_item_name);
        }
    }
    return addedId;
}
项目:AOSP-Kayboard-7.1.2    文件KeyboardLayoutSet.java   
static int readScriptId(final Resources resources,final InputMethodSubtype subtype) {
    final String layoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX
            + SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    final int xmlId = getXmlId(resources,layoutSetName);
    final XmlResourceParser parser = resources.getXml(xmlId);
    try {
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            // Bovinate through the XML stupidly searching for TAG_FEATURE,and read
            // the script Id from it.
            parser.next();
            final String tag = parser.getName();
            if (TAG_FEATURE.equals(tag)) {
                return readScriptIdFromTagFeature(resources,parser);
            }
        }
    } catch (final IOException | XmlPullParserException e) {
        throw new RuntimeException(e.getMessage() + " in " + layoutSetName,e);
    } finally {
        parser.close();
    }
    // If the tag is not found,then the default script is Latin.
    return ScriptUtils.SCRIPT_LATIN;
}
项目:android-apkBox    文件ApkManifestParser.java   
/**
 * parseActivity
 *
 * @param activityName  activityName
 * @param intentFilters intentFilters
 * @param parser        parser
 * @throws Exception e
 */
private static void parseActivity(String activityName,IntentFilter> intentFilters,XmlResourceParser parser) throws Exception {
    int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }
        String tagName = parser.getName();
        if (tagName == null) {
            continue;
        }

        if (tagName.equals("intent-filter")) {
            IntentFilter mFilter = new IntentFilter();
            intentFilters.put(activityName,mFilter);
            parseIntentFilter(mFilter,parser);
        }
    }
}
项目:q-mail    文件AccountSetupBasics.java   
/**
 * Attempts to get the given attribute as a String resource first,and if it fails
 * returns the attribute as a simple String value.
 * @param xml
 * @param name
 * @return
 */
private String getXmlAttribute(XmlResourceParser xml,String name) {
    int resId = xml.getAttributeResourceValue(null,name,0);
    if (resId == 0) {
        return xml.getAttributeValue(null,name);
    } else {
        return getString(resId);
    }
}
项目:GitHub    文件PrefUtil.java   
static void setLayoutResource(@NonNull Context context,@NonNull Preference preference,@Nullable AttributeSet attrs) {
    boolean foundLayout = false;
    if (attrs != null) {
        for (int i = 0; i < attrs.getAttributeCount(); i++) {
            final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
            if (namespace.equals("http://schemas.android.com/apk/res/android") &&
                    attrs.getAttributeName(i).equals("layout")) {
                foundLayout = true;
                break;
            }
        }
    }

    boolean useStockLayout = false;
    if (attrs != null) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs,R.styleable.Preference,0);
        try {
            useStockLayout = a.getBoolean(R.styleable.Preference_useStockLayout,false);
        } finally {
            a.recycle();
        }
    }

    if (!foundLayout && !useStockLayout)
        preference.setLayoutResource(R.layout.md_preference_custom);
}
项目:MBEStyle    文件IconShowPresenter.java   
public disposable getAllIcons() {
    return Observable.create(new ObservableOnSubscribe<IconBean>() {
        @Override
        public void subscribe(@NonNull ObservableEmitter<IconBean> e) throws Exception {
            XmlResourceParser xml = mView.getResources().getXml(R.xml.drawable);

            while (xml.getEventType() != XmlResourceParser.END_DOCUMENT) {
                if (xml.getEventType() == XmlPullParser.START_TAG) {
                    if (xml.getName().startsWith("item")) {
                        IconBean bean = new IconBean();

                        String iconName = xml.getAttributeValue(null,"drawable");
                        bean.id = mView.getResources().getIdentifier(
                                iconName,"drawable",BuildConfig.APPLICATION_ID);
                        bean.name = iconName;

                        e.onNext(bean);
                    }
                }
                xml.next();
            }
            e.onComplete();
        }
    }).toList().subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<List<IconBean>>() {
                @Override
                public void accept(List<IconBean> list) throws Exception {
                    mView.onLoadData(list);
                }
            });
}
项目:LaunchEnr    文件DefaultLayoutParser.java   
@Override
protected void parseContainerAndScreen(XmlResourceParser parser,long[] out) {
    out[0] = LauncherSettings.Favorites.CONTAINER_DESKTOP;
    String strContainer = getAttributeValue(parser,ATTR_CONTAINER);
    if (strContainer != null) {
        out[0] = Long.valueOf(strContainer);
    }
    out[1] = Long.parseLong(getAttributeValue(parser,ATTR_SCREEN));
}
项目:LaunchEnr    文件DefaultLayoutParser.java   
@Override
public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException,IOException {
    // Folder contents come from an external XML resource
    final Partner partner = Partner.get(mPackageManager);
    if (partner != null) {
        final Resources partnerRes = partner.getResources();
        final int resId = partnerRes.getIdentifier(Partner.RES_FOLDER,"xml",partner.getPackageName());
        if (resId != 0) {
            final XmlResourceParser partnerParser = partnerRes.getXml(resId);
            beginDocument(partnerParser,TAG_FOLDER);

            FolderParser folderParser = new FolderParser(getFolderElementsMap(partnerRes));
            return folderParser.parseAndAdd(partnerParser);
        }
    }
    return -1;
}
项目:LaunchEnr    文件AutoInstallsLayout.java   
/**
 * Parses the layout and returns the number of elements added on the homescreen.
 */
private int parseLayout(int layoutId,ArrayList<Long> screenIds)
        throws XmlPullParserException,IOException {
    XmlResourceParser parser = mSourceRes.getXml(layoutId);
    beginDocument(parser,mRoottag);
    final int depth = parser.getDepth();
    int type;
    HashMap<String,TagParser> tagParserMap = getLayoutElementsMap();
    int count = 0;

    while (((type = parser.next()) != XmlPullParser.END_TAG ||
            parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }
        count += parseAndAddNode(parser,tagParserMap,screenIds);
    }
    return count;
}
项目:LaunchEnr    文件AutoInstallsLayout.java   
/**
 * Return attribute value,attempting launcher-specific namespace first
 * before falling back to anonymous attribute.
 */
static String getAttributeValue(XmlResourceParser parser,String attribute) {
    String value = parser.getAttributeValue(
            "http://schemas.android.com/apk/res-auto/com.enrico.launcher3",attribute);
    if (value == null) {
        value = parser.getAttributeValue(null,attribute);
    }
    return value;
}
项目:LaunchEnr    文件AutoInstallsLayout.java   
/**
 * Return attribute resource value,attempting launcher-specific namespace
 * first before falling back to anonymous attribute.
 */
static int getAttributeResourceValue(XmlResourceParser parser,String attribute,int defaultValue) {
    int value = parser.getAttributeResourceValue(
            "http://schemas.android.com/apk/res-auto/com.enrico.launcher3",attribute,defaultValue);
    if (value == defaultValue) {
        value = parser.getAttributeResourceValue(null,defaultValue);
    }
    return value;
}
项目:mobile-store    文件App.java   
/**
 * {@link PackageManager} doesn't give us {@code minSdkVersion},{@code targetSdkVersion},* and {@code maxsdkVersion},so we have to parse it straight from {@code <uses-sdk>} in
 * {@code AndroidManifest.xml}.  If {@code targetSdkVersion} is not set,then it is
 * equal to {@code minSdkVersion}
 *
 * @see <a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a>
 */
private static int[] getMinTargetMaxsdkVersions(Context context,String packageName) {
    int minSdkVersion = Apk.SDK_VERSION_MIN_VALUE;
    int targetSdkVersion = Apk.SDK_VERSION_MIN_VALUE;
    int maxsdkVersion = Apk.SDK_VERSION_MAX_VALUE;
    try {
        AssetManager am = context.createPackageContext(packageName,0).getAssets();
        XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG && "uses-sdk".equals(xml.getName())) {
                for (int j = 0; j < xml.getAttributeCount(); j++) {
                    if (xml.getAttributeName(j).equals("minSdkVersion")) {
                        minSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    } else if (xml.getAttributeName(j).equals("targetSdkVersion")) {
                        targetSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    } else if (xml.getAttributeName(j).equals("maxsdkVersion")) {
                        maxsdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    }
                }
                break;
            }
            eventType = xml.nextToken();
        }
    } catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) {
        Log.e(TAG,"Could not get min/max sdk version",e);
    }
    if (targetSdkVersion < minSdkVersion) {
        targetSdkVersion = minSdkVersion;
    }
    return new int[]{minSdkVersion,targetSdkVersion,maxsdkVersion};
}
项目:behe-keyboard    文件LatinKeyboard.java   
@Override
protected Key createKeyFromXml(Resources res,Row parent,int x,int y,XmlResourceParser parser) {
    Key key = new LatinKey(res,parent,x,y,parser);
    if (key.codes[0] == 10) {
        mEnterKey = key;
    } else if (key.codes[0] == ' ') {
        mSpaceKey = key;
    } else if (key.codes[0] == Keyboard.KEYCODE_MODE_CHANGE) {
        mModeChangeKey = key;
        mSavedModeChangeKey = new LatinKey(res,parser);
    } else if (key.codes[0] == LatinKeyboard.KEYCODE_LAYUOUT_SWITCH) {
        mLanguageSwitchKey = key;
        mSavedLanguageSwitchKey = new LatinKey(res,parser);
    }
    return key;
}
项目:NanoIconPackLite    文件LiteIconActivityV2.java   
private List<Cate> getIcons() {
    List<Cate> dataList = new ArrayList<>();
    Cate defCate = new Cate(null);
    XmlResourceParser parser = getResources().getXml(R.xml.drawable);
    try {
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                switch (parser.getName()) {
                    case "category":
                        dataList.add(new Cate(parser.getAttributeValue(null,"title")));
                        break;
                    case "item":
                        String iconName = parser.getAttributeValue(null,"drawable");
                        if (dataList.isEmpty()) {
                            defCate.pushIcon(iconName);
                        } else {
                            dataList.get(dataList.size() - 1).pushIcon(iconName);
                        }
                        break;
                }
            }
            event = parser.next();
        }
        if (!defCate.isEmpty()) {
            dataList.add(defCate);
        }
    } catch (Exception e) {
        e.printstacktrace();
    }
    return dataList;
}
项目:NanoIconPackLite    文件LiteIconActivity.java   
private List<Cate> getIcons() {
    List<Cate> dataList = new ArrayList<>();
    Cate defCate = new Cate(null);
    XmlResourceParser parser = getResources().getXml(R.xml.drawable);
    try {
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                switch (parser.getName()) {
                    case "category":
                        dataList.add(new Cate(parser.getAttributeValue(null,"drawable");
                        if (dataList.isEmpty()) {
                            defCate.pushIcon(iconName);
                        } else {
                            dataList.get(dataList.size() - 1).pushIcon(iconName);
                        }
                        break;
                }
            }
            event = parser.next();
        }
        if (!defCate.isEmpty()) {
            dataList.add(defCate);
        }
    } catch (Exception e) {
        e.printstacktrace();
    }
    return dataList;
}
项目:GxIconDIY    文件AppfilterReader.java   
private boolean init(@NonNull Resources resources) {
    try {
        XmlResourceParser parser = resources.getXml(R.xml.appfilter);
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                if (!"item".equals(parser.getName())) {
                    event = parser.next();
                    continue;
                }
                String drawable = parser.getAttributeValue(null,drawable));
            }
            event = parser.next();
        }
        return true;
    } catch (Exception e) {
        e.printstacktrace();
    }
    return false;
}
项目:letv    文件FileProvider.java   
private static PathStrategy parsePathStrategy(Context context,String authority) throws IOException,XmlPullParserException {
    SimplePathStrategy strat = new SimplePathStrategy(authority);
    XmlResourceParser in = context.getPackageManager().resolveContentProvider(authority,128).loadXmlMetaData(context.getPackageManager(),Meta_DATA_FILE_PROVIDER_PATHS);
    if (in == null) {
        throw new IllegalArgumentException("Missing android.support.FILE_PROVIDER_PATHS Meta-data");
    }
    while (true) {
        int type = in.next();
        if (type == 1) {
            return strat;
        }
        if (type == 2) {
            String tag = in.getName();
            String name = in.getAttributeValue(null,"name");
            String path = in.getAttributeValue(null,ATTR_PATH);
            File target = null;
            if (TAG_ROOT_PATH.equals(tag)) {
                target = buildpath(DEVICE_ROOT,path);
            } else if (TAG_FILES_PATH.equals(tag)) {
                target = buildpath(context.getFilesDir(),path);
            } else if (TAG_CACHE_PATH.equals(tag)) {
                target = buildpath(context.getCacheDir(),path);
            } else if (TAG_EXTERNAL.equals(tag)) {
                target = buildpath(Environment.getExternalStorageDirectory(),path);
            }
            if (target != null) {
                strat.addRoot(name,target);
            }
        }
    }
}
项目:UIKit-ViewBlock    文件UIKitHelper.java   
void generateViewBlock(UIKitComponent component,AttributeSet attrs) {
    String tagName = ((XmlResourceParser) attrs).getName();
    if (!AndroidAttrs.UIKIT_TAGS.contains(tagName)) {
        Pair<Integer,String> viewBlockAttrs = getViewBlockAttrs(attrs);

        int resourceId = viewBlockAttrs.first;
        String name = viewBlockAttrs.second;

        if (name != null) {
            if (resourceId == NO_ID) {
                Logcat.w().tag(TAG_UIKIT).msg("ViewBlock name ").msg(name).msg(" view no id ").out();
                resourceId = component.getViewDepth();
            }
            component.getViewBlockClassNamesArray().put(resourceId,name);
        }
    }

    if (!"include".equals(tagName)) {
        component.setViewDepth(component.getViewDepth() + 1);
    }
}
项目:javaide    文件LatinKeyboard.java   
@Override
protected Key createKeyFromXml(Resources res,parser);

    if (key.codes[0] == 13) {
        mEnterKey = key;
    } else if (key.codes[0] == TerminalKeyboard.CTRL_KEY) {
        mCtrlKey = key;
    } else if (key.codes[0] == TerminalKeyboard.ALT_KEY) {
        mALTKey = key;
    } else if (key.codes[0] == -1) {
        mShiftKeyLeft = key;
    } else if (key.codes[0] == -999) {
        mShiftKeyRight = key;
    } else if (key.codes[0] == -2) {
        mFNKey = key;
    }

    return key;
}
项目:gamecollection    文件Games.java   
private String[] getAttributes(XmlResourceParser xmlParser,String[] attributesList) {
    int length = attributesList.length;
    String[] attributes = new String[length];
    for (int i = 0; i < length; i++) {
        String attributeValue = xmlParser.getAttributeValue(null,attributesList[i]);
        attributes[i] = AndroidResources.getResourceString(attributeValue);
    }
    return attributes;
}
项目:NanoIconPack    文件AppfilterReader.java   
private boolean init(@NonNull Resources resources) {
    try {
        XmlResourceParser parser = resources.getXml(R.xml.appfilter);
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                if (!"item".equals(parser.getName())) {
                    event = parser.next();
                    continue;
                }
                String drawable = parser.getAttributeValue(null,drawable));
            }
            event = parser.next();
        }
        return true;
    } catch (Exception e) {
        e.printstacktrace();
    }
    return false;
}
项目:boohee_v5.6    文件FileProvider.java   
private static PathStrategy parsePathStrategy(Context context,target);
            }
        }
    }
}
项目:TPlayer    文件VContentService.java   
private void generateServicesMap(List<ResolveInfo> services,SyncAdapterInfo> map,RegisteredServicesParser accountParser) {
    for (ResolveInfo info : services) {
        XmlResourceParser parser = accountParser.getParser(mContext,"android.content.SyncAdapter");
        if (parser != null) {
            try {
                AttributeSet attributeSet = Xml.asAttributeSet(parser);
                int type;
                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
                    // nothing to do
                }
                if ("sync-adapter".equals(parser.getName())) {
                    SyncAdapterType adapterType = parseSyncAdapterType(
                            accountParser.getResources(mContext,attributeSet);
                    if (adapterType != null) {
                        String key = adapterType.accountType + "/" + adapterType.authority;
                        map.put(key,new SyncAdapterInfo(adapterType,info.serviceInfo));
                    }
                }
            } catch (Exception e) {
                e.printstacktrace();
            }
        }
    }
}
项目:SimpleUILauncher    文件DefaultLayoutParser.java   
@Override
protected Intent parseIntent(XmlResourceParser parser) {
    String uri = null;
    try {
        uri = getAttributeValue(parser,ATTR_URI);
        return Intent.parseUri(uri,0);
    } catch (URISyntaxException e) {
        Log.w(TAG,"Shortcut has malformed uri: " + uri);
        return null; // Oh well
    }
}
项目:FlickLauncher    文件DefaultLayoutParser.java   
@Override
public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException,TAG_FOLDER);

            FolderParser folderParser = new FolderParser(getFolderElementsMap(partnerRes));
            return folderParser.parseAndAdd(partnerParser);
        }
    }
    return -1;
}
项目:FlickLauncher    文件AutoInstallsLayout.java   
/**
 * Parses the layout and returns the number of elements added on the homescreen.
 */
protected int parseLayout(int layoutId,screenIds);
    }
    return count;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。