当前位置: 首页>>代码示例>>Java>>正文


Java XmlResourceParser.getEventType方法代码示例

本文整理汇总了Java中android.content.res.XmlResourceParser.getEventType方法的典型用法代码示例。如果您正苦于以下问题:Java XmlResourceParser.getEventType方法的具体用法?Java XmlResourceParser.getEventType怎么用?Java XmlResourceParser.getEventType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.XmlResourceParser的用法示例。


在下文中一共展示了XmlResourceParser.getEventType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIcons

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
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;
    }
 
开发者ID:by-syk,项目名称:NanoIconPackLite,代码行数:22,代码来源:LiteIconActivityV1.java

示例2: parseKeyboardLayoutSet

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:20,代码来源:KeyboardLayoutSet.java

示例3: getDeviceData

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:martinmarinov,项目名称:AndroidDvbDriver,代码行数:27,代码来源:DeviceFilterXmlEquivalenceTester.java

示例4: init

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:36,代码来源:AppfilterReader.java

示例5: readScriptId

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:24,代码来源:KeyboardLayoutSet.java

示例6: getMinTargetMaxSdkVersions

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
/**
 * {@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};
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:40,代码来源:App.java

示例7: getIcons

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
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;
}
 
开发者ID:by-syk,项目名称:NanoIconPackLite,代码行数:33,代码来源:LiteIconActivityV2.java

示例8: readUuidData

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
private void readUuidData(XmlResourceParser xpp) throws XmlPullParserException, IOException {
  xpp.next();
  String tagName = null;
  String uuid = null;
  String descr = null;
  int eventType = xpp.getEventType();

  while (eventType != XmlPullParser.END_DOCUMENT) {
    if (eventType == XmlPullParser.START_DOCUMENT) {
      // do nothing
    } else if (eventType == XmlPullParser.START_TAG) {
      tagName = xpp.getName();
      uuid = xpp.getAttributeValue(null, "uuid");
      descr = xpp.getAttributeValue(null, "descr");
    } else if (eventType == XmlPullParser.END_TAG) {
      // do nothing
    } else if (eventType == XmlPullParser.TEXT) {
      if (tagName.equalsIgnoreCase("item")) {
        if (!uuid.isEmpty()) {
          uuid = uuid.replace("0x", "");
          mNameMap.put(uuid, xpp.getText());
          mDescrMap.put(uuid, descr);
        }
      }
    }
    eventType = xpp.next();
  }
}
 
开发者ID:UDOOboard,项目名称:UDOOBluLib-android,代码行数:29,代码来源:GattInfo.java

示例9: retrieveSupportedDevices

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
private static void retrieveSupportedDevices(final Resources resources) {
    final String tag = "retrieveDeviceData - ";

    if (supportedDevices == null) {
        final List<SupportedDevice> result = new ArrayList<>();
        final XmlResourceParser xml = resources.getXml(R.xml.supported_devices);
        try {
            xml.next();
            int eventType;
            while ((eventType = xml.getEventType()) != XmlPullParser.END_DOCUMENT) {
                switch (eventType) {
                    case XmlPullParser.START_TAG:
                        if (xml.getName().equals("usb-device")) {
                            final AttributeSet as = Xml.asAttributeSet(xml);
                            final Integer vendorId = parseInt(as.getAttributeValue(null, "vendor-id"));
                            final Integer productId = parseInt(as.getAttributeValue(null, "product-id"));

                            // Read description
                            String description=null;
                            xml.next();
                            if (xml.getName().equals("description")) {
                                xml.require(XmlPullParser.START_TAG, null, "description");
                                if (xml.next() == XmlPullParser.TEXT) {
                                    description = xml.getText();
                                    xml.nextTag();
                                }

                                xml.require(XmlPullParser.END_TAG, null, "description");
                            }
                            result.add(new SupportedDevice(new Pair<>(vendorId, productId), description));
                        }
                        break;
                }
                xml.next();
            }
        } catch (XmlPullParserException | IOException e) {
            Log.e(TAG, tag, e);
        }

        supportedDevices = result;
    }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:43,代码来源:UsbUtils.java

示例10: loadUiOptionsFromManifest

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
private static int loadUiOptionsFromManifest(Activity activity) {
    int uiOptions = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (ActionBarSherlock.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("uiOptions".equals(xml.getAttributeName(i))) {
                            uiOptions = xml.getAttributeIntValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityUiOptions = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("uiOptions".equals(attrName)) {
                            activityUiOptions = xml.getAttributeIntValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //out of for loop
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityUiOptions != null) && (activityPackage != null)) {
                            //Our activity, uiOptions specified, override with our value
                            uiOptions = activityUiOptions.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (ActionBarSherlock.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
    return uiOptions;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:71,代码来源:ActionBarSherlockCompat.java

示例11: loadLogoFromManifest

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
private static int loadLogoFromManifest(Activity activity) {
    int logo = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityLogo = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo));
    return logo;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:79,代码来源:Utility4.java

示例12: loadLogoFromManifest

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
public static int loadLogoFromManifest(Activity activity) {
    int logo = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (ActionBarSherlock.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityLogo = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (ActionBarSherlock.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo));
    return logo;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:79,代码来源:ResourcesCompat.java

示例13: init

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
protected boolean init(Resources resources) {
    if (isReadDone()) {
        return true;
    }
    if (resources == null) {
        return false;
    }

    if (mPackageName == null) {
        return false;
    }

    int resId = resources.getIdentifier(IconPackConfig.APPFIlTER,
            IconPackConfig.APPFILTERLOCATION, mPackageName);


    XmlResourceParser parser = resources.getXml(resId);
    try {
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                if (!IconPackConfig.APPFILTERXMLLABEL.equals(parser.getName())) {
                    event = parser.next();
                    continue;
                }
                IconPackBean bean = new IconPackBean();
                bean.drawable = parser.getAttributeValue(null, IconPackConfig.APPFILTERDRAWABLEELEMENT);
                if (TextUtils.isEmpty(bean.drawable)) {
                    event = parser.next();
                    continue;
                }
                if (bean.drawable.matches(".+?_\\d+")) {
                    bean.drawableNoSeq = bean.drawable.substring(0, bean.drawable.lastIndexOf('_'));
                } else {
                    bean.drawableNoSeq = bean.drawable;
                }
                String component = parser.getAttributeValue(null, IconPackConfig.APPFILTERCOMPONENTELEMENT);
                if (component == null) {
                    event = parser.next();
                    continue;
                }
                Matcher matcher = Pattern.compile("ComponentInfo\\{([^/]+?)/(.+?)\\}").matcher(component);
                if (matcher.matches()) {
                    bean.pkg = matcher.group(1);
                    bean.launcher = matcher.group(2);
                }

                if (!TextUtils.isEmpty(bean.launcher)) {
                    mAppFilterConfigMap.put(bean.launcher, bean);
                }
            }
            event = parser.next();
        }
        isReadDone = true;
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}
 
开发者ID:uchiaitachipro,项目名称:icon_pack_loader,代码行数:62,代码来源:AppFilterReader.java

示例14: init

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
protected boolean init(Resources resources) {
    if (isReadDone()) {
        return true;
    }
    if (resources == null) {
        return false;
    }
    int resId = getFilterConfigId();
    XmlResourceParser parser = resources.getXml(resId);
    try {
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {
            if (event == XmlPullParser.START_TAG) {
                if (!IconPackConfig.ICONPACKLABEL.equals(parser.getName())) {
                    event = parser.next();
                    continue;
                }
                Intent filter = new Intent();
                String action = parser.getAttributeValue(null,
                        IconPackConfig.ICONPACKACTIONELEMENT);
                if (TextUtils.isEmpty(action)) {
                    event = parser.next();
                    continue;
                }
                filter.setAction(action);
                String category = parser.getAttributeValue(null,
                        IconPackConfig.ICONPACKCATEGORYELEMENT);
                if (TextUtils.isEmpty(category)) {
                    event = parser.next();
                    continue;
                }
                filter.addCategory(category);

                mFilter.add(filter);
            }
            event = parser.next();
        }
        mDone = true;
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:uchiaitachipro,项目名称:icon_pack_loader,代码行数:45,代码来源:IconPackFilterReader.java

示例15: loadFromXml

import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
private void loadFromXml(int resourceId) {
    XmlResourceParser parser = getContext().getResources().getXml(
            resourceId);
    try {
        int eventType = parser.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_DOCUMENT) {

            } else if (eventType == XmlPullParser.START_TAG) {
                String name = parser.getName();
                if (!TextUtils.isEmpty(name) && name.equals("animation-list")) {
                    int size = parser.getAttributeCount();
                    for (int i = 0; i < size; i++) {
                        if (parser.getAttributeName(i).equals(
                                "oneshot")) {
                            mLoop = !parser.getAttributeBooleanValue(
                                    i, true);
                        }
                    }
                }
                if (parser.getName().equals("item")) {
                    for (int i = 0; i < parser.getAttributeCount(); i++) {
                        if (parser.getAttributeName(i).equals(
                                "drawable")) {
                            int resId = Integer.parseInt(parser
                                    .getAttributeValue(i)
                                    .substring(1));
                            if (resId != 0)
                                mRes.add(resId);
                        } else if (parser.getAttributeName(i)
                                .equals("duration")) {
                            duration = parser.getAttributeIntValue(
                                    i, 1000);
                        }
                    }
                }
            } else if (eventType == XmlPullParser.END_TAG) {
            } else if (eventType == XmlPullParser.TEXT) {
            }
            eventType = parser.next();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e2) {
        e2.printStackTrace();
    }
}
 
开发者ID:ronghao,项目名称:FrameAnimationView,代码行数:48,代码来源:FrameAnimView.java


注:本文中的android.content.res.XmlResourceParser.getEventType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。