Java Code Examples for android.content.res.XmlResourceParser#getEventType()
The following examples show how to use
android.content.res.XmlResourceParser#getEventType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WhatsNewDialog.java From trekarta with GNU General Public License v3.0 | 6 votes |
private void readRelease(XmlResourceParser parser) throws XmlPullParserException, IOException { parser.require(XmlPullParser.START_TAG, null, TAG_RELEASE); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); if (name.equals(TAG_CHANGE)) { parser.require(XmlPullParser.START_TAG, null, TAG_CHANGE); String variant = parser.getAttributeValue(null, ATTRIBUTE_VARIANT); ChangeListItem changeItem = new ChangeListItem(); changeItem.change = readText(parser); if (BuildConfig.FULL_VERSION || !"full".equals(variant)) mChangelog.add(changeItem); parser.require(XmlPullParser.END_TAG, null, TAG_CHANGE); } else { skip(parser); } } parser.require(XmlPullParser.END_TAG, null, TAG_RELEASE); }
Example 2
Source File: KeyboardLayoutSet.java From openboard with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 3
Source File: KeyboardLayoutSet.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
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(); } }
Example 4
Source File: XmlHelper.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@NonNull public static Map<String, String> getFilterMap(XmlResourceParser parser) throws XmlPullParserException, IOException { Map<String, String> map = new HashMap<>(); for (int type = parser.getEventType(); type != XmlPullParser.END_DOCUMENT; type = parser.next()) { if (type == XmlPullParser.START_TAG && Constants.FILTER_TAG_ITEM.equals(parser.getName())) { map.put( parser.getAttributeValue(null, Constants.FILTER_TAG_NAME), parser.getAttributeValue(null, Constants.FILTER_TAG_VALUE) ); } } return map; }
Example 5
Source File: KeyboardLayoutSet.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
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; }
Example 6
Source File: LiteIconActivityV1.java From NanoIconPackLite with Apache License 2.0 | 6 votes |
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; }
Example 7
Source File: PluginManifestParser.java From Android-Plugin-Framework with MIT License | 5 votes |
private static String addIntentFilter(HashMap<String, ArrayList<PluginIntentFilter>> map, String packageName, String namespace, XmlResourceParser parser, String endTagName) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); String activityName = parser.getAttributeValue(namespace, "name"); activityName = getName(activityName, packageName); ArrayList<PluginIntentFilter> filters = map.get(activityName); if (filters == null) { filters = new ArrayList<PluginIntentFilter>(); map.put(activityName, filters); } PluginIntentFilter intentFilter = new PluginIntentFilter(); do { switch (eventType) { case XmlPullParser.START_TAG: { String tag = parser.getName(); if ("intent-filter".equals(tag)) { intentFilter = new PluginIntentFilter(); filters.add(intentFilter); } else { intentFilter.readFromXml(tag, namespace, parser); } } } eventType = parser.next(); } while (!endTagName.equals(parser.getName()));//再次到达,表示一个标签结束了 return activityName; }
Example 8
Source File: ChangeLogDialog.java From iBeebo with GNU General Public License v3.0 | 5 votes |
private String ParseReleaseTag(XmlResourceParser aXml) throws XmlPullParserException, IOException { String _Result = "<h1>版本: " + aXml.getAttributeValue(null, "version") + "</h1><ul>"; int eventType = aXml.getEventType(); while ((eventType != XmlPullParser.END_TAG) || (aXml.getName().equals("change"))) { if ((eventType == XmlPullParser.START_TAG) && (aXml.getName().equals("change"))) { eventType = aXml.next(); _Result = _Result + "<li>" + aXml.getText() + "</li>"; } eventType = aXml.next(); } _Result = _Result + "</ul>"; return _Result; }
Example 9
Source File: AppfilterReader.java From NanoIconPack with Apache License 2.0 | 5 votes |
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; }
Example 10
Source File: UENavigationFragmentActivity.java From Auie with GNU General Public License v2.0 | 5 votes |
/** * 读取XML配置文件 * @param id 配置文件索引 */ private void readXML(int id){ String name; String className = getClass().getSimpleName(); XmlResourceParser xrp = getResources().getXml(id); try { while(xrp.getEventType() != XmlResourceParser.END_DOCUMENT){ if (xrp.getEventType() == XmlResourceParser.START_TAG) { name = xrp.getName(); if (name.equals("BackgroundColor")) { mNavigationView.setBackgroundColor(xrp.getAttributeIntValue(0, mNavigationView.getBackgroundColor())); } if (name.equals("StatusType")) { mNavigationView.setStatusType(xrp.getAttributeIntValue(0, mNavigationView.getStatusType())); } if (name.equals("TitleColor")) { mNavigationView.setTitleColor(xrp.getAttributeIntValue(0, mNavigationView.getTitleColor())); } if (name.equals("LineBackgroundColor")) { mNavigationView.setLineBackgroundColor(xrp.getAttributeIntValue(0, mNavigationView.getTitleColor())); } if (name.equals("NavigationTextColor")) { mNavigationView.setNavigationTextColor(xrp.getAttributeIntValue(0, mNavigationView.getNavigationTextColor())); } if (name.equals("Title") && xrp.getAttributeValue(0).equals(className)) { mNavigationView.setTitle(xrp.getAttributeValue(1)); } } xrp.next(); } } catch (Exception e) { Log.d(UE.TAG, "UEConfig配置出错"+e.toString()); } }
Example 11
Source File: UENavigationActivity.java From Auie with GNU General Public License v2.0 | 5 votes |
/** * 读取XML配置文件 * @param id 配置文件索引 */ private void readXML(int id){ String name; String className = getClass().getSimpleName(); XmlResourceParser xrp = getResources().getXml(id); try { while(xrp.getEventType() != XmlResourceParser.END_DOCUMENT){ if (xrp.getEventType() == XmlResourceParser.START_TAG) { name = xrp.getName(); if (name.equals("BackgroundColor")) { mNavigationView.setBackgroundColor(xrp.getAttributeIntValue(0, mNavigationView.getBackgroundColor())); } if (name.equals("StatusType")) { mNavigationView.setStatusType(xrp.getAttributeIntValue(0, mNavigationView.getStatusType())); } if (name.equals("TitleColor")) { mNavigationView.setTitleColor(xrp.getAttributeIntValue(0, mNavigationView.getTitleColor())); } if (name.equals("LineBackgroundColor")) { mNavigationView.setLineBackgroundColor(xrp.getAttributeIntValue(0, mNavigationView.getTitleColor())); } if (name.equals("NavigationTextColor")) { mNavigationView.setNavigationTextColor(xrp.getAttributeIntValue(0, mNavigationView.getNavigationTextColor())); } if (name.equals("Title") && xrp.getAttributeValue(0).equals(className)) { mNavigationView.setTitle(xrp.getAttributeValue(1)); } } xrp.next(); } } catch (Exception e) { Log.d(UE.TAG, "UEConfig配置出错"+e.toString()); } }
Example 12
Source File: ChangeLogDialog.java From iBeebo with GNU General Public License v3.0 | 5 votes |
private String ParseReleaseTag(XmlResourceParser aXml) throws XmlPullParserException, IOException { String _Result = "<h1>版本: " + aXml.getAttributeValue(null, "version") + "</h1><ul>"; int eventType = aXml.getEventType(); while ((eventType != XmlPullParser.END_TAG) || (aXml.getName().equals("change"))) { if ((eventType == XmlPullParser.START_TAG) && (aXml.getName().equals("change"))) { eventType = aXml.next(); _Result = _Result + "<li>" + aXml.getText() + "</li>"; } eventType = aXml.next(); } _Result = _Result + "</ul>"; return _Result; }
Example 13
Source File: SettingChangeLogDialog.java From iBeebo with GNU General Public License v3.0 | 5 votes |
private String ParseReleaseTag(XmlResourceParser aXml) throws XmlPullParserException, IOException { String _Result = "<h1>Release: " + aXml.getAttributeValue(null, "version") + "</h1><ul>"; int eventType = aXml.getEventType(); while ((eventType != XmlPullParser.END_TAG) || (aXml.getName().equals("change"))) { if ((eventType == XmlPullParser.START_TAG) && (aXml.getName().equals("change"))) { eventType = aXml.next(); _Result = _Result + "<li>" + aXml.getText() + "</li>"; } eventType = aXml.next(); } _Result = _Result + "</ul>"; return _Result; }
Example 14
Source File: TrustManagerBuilder.java From cwac-netsecurity with Apache License 2.0 | 5 votes |
private void validateConfig(Context ctxt, int resourceId, boolean isUserAllowed) { XmlResourceParser xpp=ctxt.getResources().getXml(resourceId); RuntimeException result=null; try { while (xpp.getEventType()!=XmlPullParser.END_DOCUMENT) { if (xpp.getEventType()==XmlPullParser.START_TAG) { if ("certificates".equals(xpp.getName())) { for (int i=0; i<xpp.getAttributeCount(); i++) { String name=xpp.getAttributeName(i); if ("src".equals(name)) { String src=xpp.getAttributeValue(i); if ("user".equals(src)) { if (isUserAllowed) { Log.w("CWAC-NetSecurity", "requested <certificates src=\"user\">, treating as <certificates src=\"system\">"); } else { result=new RuntimeException( "requested <certificates src=\"user\">, not supported"); } } } } } } xpp.next(); } } catch (Exception e) { throw new RuntimeException("Could not parse config XML", e); } if (result!=null) { throw result; } }
Example 15
Source File: ResourcesCompat.java From Libraries-for-Android-Developers with MIT License | 4 votes |
/** * 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; }
Example 16
Source File: DataService.java From tilt-game-android with MIT License | 4 votes |
private void loadLevels(Intent intent) { XmlResourceParser parser = getResources().getXml(R.xml.levels); String levelPackage = ""; String controllerPackage = ""; List<LevelVO> newLevels = new ArrayList<>(); try { parser.next(); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { switch (parser.getName()) { case "levels": levelPackage = parser.getAttributeValue(null, "levelpackage"); controllerPackage = parser.getAttributeValue(null, "controllerpackage"); break; case "level": newLevels.add(LevelVO.createFromXML(parser, levelPackage, controllerPackage)); break; } } eventType = parser.next(); } } catch (XmlPullParserException | IOException e) { e.printStackTrace(); } List<LevelVO> allLevels = new ArrayList<>(newLevels); if (newLevels.size() > 0) { // retrieve current set of stored levels List<LevelVO> oldLevels = cupboard().withContext(this).query(LevelVO.URI, LevelVO.class).list(); for (LevelVO oldLevelVO : oldLevels) { LevelVO newLevelVO = getLevelById(newLevels, oldLevelVO.id); if (newLevelVO != null) { newLevelVO.unlocked = oldLevelVO.unlocked; } } cupboard().withContext(this).put(LevelVO.URI, LevelVO.class, newLevels); // determine if there are new levels boolean hasNewLevels = (oldLevels.size() == 0) || newLevels.removeAll(oldLevels); // insert empty LevelResultVO instances into database for new levels if (hasNewLevels) { List<LevelResultVO> newResults = new ArrayList<>(); for (LevelVO levelVO : newLevels) { newResults.add(new LevelResultVO(levelVO.id)); } cupboard().withContext(this).put(LevelResultVO.URI, LevelResultVO.class, newResults); } } List<LevelResultVO> results = cupboard().withContext(this).query(LevelResultVO.URI, LevelResultVO.class).list(); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_LOAD_LEVELS) .putParcelableArrayListExtra(KEY_LEVELS, (ArrayList<? extends Parcelable>) allLevels) .putParcelableArrayListExtra(KEY_LEVEL_RESULTS, (ArrayList<? extends Parcelable>) results)); }
Example 17
Source File: ActionBarSherlockCompat.java From Libraries-for-Android-Developers with MIT License | 4 votes |
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; }
Example 18
Source File: IconsHelper.java From candybar-library with Apache License 2.0 | 4 votes |
@NonNull public static List<Icon> getIconsList(@NonNull Context context) throws Exception { XmlResourceParser parser = context.getResources().getXml(R.xml.drawable); int eventType = parser.getEventType(); String sectionTitle = ""; List<Icon> icons = new ArrayList<>(); List<Icon> sections = new ArrayList<>(); int count = 0; while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("category")) { String title = parser.getAttributeValue(null, "title"); if (!sectionTitle.equals(title)) { if (sectionTitle.length() > 0) { count += icons.size(); sections.add(new Icon(sectionTitle, icons)); } } sectionTitle = title; icons = new ArrayList<>(); } else if (parser.getName().equals("item")) { String name = parser.getAttributeValue(null, "drawable"); int id = getResourceId(context, name); if (id > 0) { icons.add(new Icon(name, id)); } } } eventType = parser.next(); } count += icons.size(); CandyBarMainActivity.sIconsCount = count; if (!CandyBarApplication.getConfiguration().isAutomaticIconsCountEnabled() && CandyBarApplication.getConfiguration().getCustomIconsCount() == 0) { CandyBarApplication.getConfiguration().setCustomIconsCount(count); } sections.add(new Icon(sectionTitle, icons)); parser.close(); return sections; }
Example 19
Source File: ActionBarSherlockCompat.java From zen4android with MIT License | 4 votes |
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; }
Example 20
Source File: ApduParser.java From smartcard-reader with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") static Apdu7816 readTag(Class<? extends Apdu7816> clazz, XmlResourceParser xml) throws Exception { if (xml.getEventType() != START_TAG) return null; final String thisTag = xml.getName(); final String testTag = (String) clazz.getDeclaredField("TAG").get(null); if (!thisTag.equalsIgnoreCase(testTag)) return null; final String apduName = xml.getAttributeValue(null, "name"); final String apduVal = xml.getAttributeValue(null, "val"); final ArrayList<Apdu7816> list = new ArrayList<Apdu7816>(); final Object child = clazz.getDeclaredField("SUB").get(null); while (true) { int event = xml.next(); if (event == END_DOCUMENT) break; if (event == END_TAG && thisTag.equalsIgnoreCase(xml.getName())) break; if (child != null) { Apdu7816 apdu = readTag((Class<? extends Apdu7816>) child, xml); if (apdu != null) list.add(apdu); } } final Apdu7816[] sub; if (list.isEmpty()) sub = null; else sub = list.toArray(new Apdu7816[list.size()]); final Apdu7816 ret = clazz.newInstance(); ret.init(parseValue(apduVal), apduName, sub); return ret; }