Java Code Examples for android.content.res.XmlResourceParser#END_TAG
The following examples show how to use
android.content.res.XmlResourceParser#END_TAG .
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: XmlPreferenceParser.java From WearPreferenceActivity with Apache License 2.0 | 6 votes |
private void parsePreference(@NonNull final Context context, @NonNull final XmlResourceParser parser, @NonNull final WearPreferenceScreen screen) throws XmlPullParserException, IOException { final String name = parser.getName(); WearPreference preference = parsePreference(context, name, parser); if(preference == null) { preference = parsePreferenceInternal(context, name, parser); } screen.addChild(preference); while(parser.getEventType() != XmlResourceParser.END_TAG) { parser.next(); } }
Example 2
Source File: Keyboard.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void skipToEndOfRow(XmlResourceParser parser) throws XmlPullParserException, IOException { int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.END_TAG && parser.getName().equals(TAG_ROW)) { break; } } }
Example 3
Source File: Keyboard.java From libcommon with Apache License 2.0 | 5 votes |
private void skipToEndOfRow(XmlResourceParser parser) throws XmlPullParserException, IOException { if (DEBUG) Log.v(TAG, "skipToEndOfRow:"); int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.END_TAG && parser.getName().equals(TAG_ROW)) { break; } } }
Example 4
Source File: Keyboard.java From hackerskeyboard with Apache License 2.0 | 5 votes |
private void skipToEndOfRow(XmlResourceParser parser) throws XmlPullParserException, IOException { int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.END_TAG && parser.getName().equals(TAG_ROW)) { break; } } }
Example 5
Source File: BundleParser.java From Small with Apache License 2.0 | 5 votes |
private static void skipCurrentTag(XmlResourceParser parser) throws XmlPullParserException, IOException { int outerDepth = parser.getDepth(); int type; while ((type=parser.next()) != XmlResourceParser.END_DOCUMENT && (type != XmlResourceParser.END_TAG || parser.getDepth() > outerDepth)) { } }
Example 6
Source File: XmlPreferenceParser.java From WearPreferenceActivity with Apache License 2.0 | 5 votes |
private void parsePreferences(@NonNull final Context context, @NonNull final XmlResourceParser parser, @NonNull final WearPreferenceScreen screen) throws XmlPullParserException, IOException { if(parser.getEventType() == XmlResourceParser.START_TAG) { parser.next(); while(parser.getEventType() != XmlResourceParser.END_TAG) { parseItem(context, parser, screen); parser.next(); } } }
Example 7
Source File: Keyboard.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void loadKeyboard(Context context, XmlResourceParser parser) { boolean inKey = false; boolean inRow = false; boolean leftMostKey = false; int row = 0; int x = 0; int y = 0; Key key = null; Row currentRow = null; Resources res = context.getResources(); boolean skipRow = false; try { int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { String tag = parser.getName(); if (TAG_ROW.equals(tag)) { inRow = true; x = 0; currentRow = createRowFromXml(res, parser); rows.add(currentRow); skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; if (skipRow) { skipToEndOfRow(parser); inRow = false; } } else if (TAG_KEY.equals(tag)) { inKey = true; key = createKeyFromXml(res, currentRow, x, y, parser); mKeys.add(key); if (key.codes[0] == KEYCODE_SHIFT) { // Find available shift key slot and put this shift key in it for (int i = 0; i < mShiftKeys.length; i++) { if (mShiftKeys[i] == null) { mShiftKeys[i] = key; mShiftKeyIndices[i] = mKeys.size()-1; break; } } mModifierKeys.add(key); } else if (key.codes[0] == KEYCODE_ALT) { mModifierKeys.add(key); } currentRow.mKeys.add(key); } else if (TAG_KEYBOARD.equals(tag)) { parseKeyboardAttributes(res, parser); } } else if (event == XmlResourceParser.END_TAG) { if (inKey) { inKey = false; x += key.gap + key.width; if (x > mTotalWidth) { mTotalWidth = x; } } else if (inRow) { inRow = false; y += currentRow.verticalGap; y += currentRow.defaultHeight; row++; } else { // TODO: error or extend? } } } } catch (Exception e) { Log.e(TAG, "Parse error:" + e); e.printStackTrace(); } mTotalHeight = y - mDefaultVerticalGap; }
Example 8
Source File: Keyboard.java From libcommon with Apache License 2.0 | 4 votes |
private void loadKeyboard(Context context, XmlResourceParser parser) { if (DEBUG) Log.v(TAG, "loadKeyboard:"); boolean inKey = false; boolean inRow = false; boolean leftMostKey = false; int row = 0; int x = 0; int y = 0; Key key = null; Row currentRow = null; Resources res = context.getResources(); boolean skipRow = false; try { int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { String tag = parser.getName(); if (TAG_ROW.equals(tag)) { inRow = true; x = 0; currentRow = createRowFromXml(res, parser); rows.add(currentRow); skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; if (skipRow) { skipToEndOfRow(parser); inRow = false; } } else if (TAG_KEY.equals(tag)) { inKey = true; key = createKeyFromXml(res, currentRow, x, y, parser); Log.d(TAG, "loadKeyboard:key=" + key); mKeys.add(key); if (key.codes[0] == KEYCODE_SHIFT) { // Find available shift key slot and put this shift key in it for (int i = 0; i < mShiftKeys.length; i++) { if (mShiftKeys[i] == null) { mShiftKeys[i] = key; mShiftKeyIndices[i] = mKeys.size() - 1; break; } } mModifierKeys.add(key); } else if (key.codes[0] == KEYCODE_ALT) { mModifierKeys.add(key); } currentRow.mKeys.add(key); } else if (TAG_KEYBOARD.equals(tag)) { parseKeyboardAttributes(res, parser); } } else if (event == XmlResourceParser.END_TAG) { if (inKey) { inKey = false; x += key.gap + key.width; if (x > mTotalWidth) { mTotalWidth = x; } } else if (inRow) { inRow = false; y += currentRow.verticalGap; y += currentRow.defaultHeight; row++; } else { // TODO: error or extend? } } } } catch (Exception e) { Log.e(TAG, "Parse error:" + e); e.printStackTrace(); } mTotalHeight = y - mDefaultVerticalGap; }
Example 9
Source File: SwipeItemParser.java From SwipeSelector with Apache License 2.0 | 4 votes |
private boolean isAtEndOfAnItem() { return currentEventType == XmlResourceParser.END_TAG && "item".equals(parser.getName()) && currentlyProcessedItem != null; }
Example 10
Source File: Keyboard.java From WirelessHid with Apache License 2.0 | 4 votes |
private LinearLayout parseKeyLayout(Context context, XmlResourceParser xmlParser) throws XmlPullParserException, IOException { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setLayoutParams(new LayoutParams( xmlParser.getAttributeIntValue(null, "width", LayoutParams.MATCH_PARENT), xmlParser.getAttributeIntValue(null, "height", 0), xmlParser.getAttributeFloatValue(null, "weight", 1.0f))); linearLayout.setOrientation(xmlParser.getAttributeIntValue(null, "orientation", LinearLayout.HORIZONTAL)); String tag; do { xmlParser.next(); tag = xmlParser.getName(); if (xmlParser.getEventType() == XmlResourceParser.START_TAG) { if (tag.equals(XML_TAG_LAYOUT)) { linearLayout.addView(parseKeyLayout(context, xmlParser)); } else if (tag.equals(XML_TAG_KEY)) { Key.KeyAttributes attrs = new Key.KeyAttributes(); attrs.keyFunction = getStringAttributeValue(xmlParser, "keyFunc", ""); attrs.mainLabel = getStringAttributeValue(xmlParser, "keyLabel", ""); attrs.shiftLabel = getStringAttributeValue(xmlParser, "shiftLabel", ""); attrs.keyCode = xmlParser.getAttributeIntValue(null, "keyCode", 0); Key key = new Key(context, attrs); key.setLayoutParams(new LayoutParams( xmlParser.getAttributeIntValue(null, "width", 0), xmlParser.getAttributeIntValue(null, "height", LayoutParams.MATCH_PARENT), xmlParser.getAttributeFloatValue(null, "weight", 1))); key.setVisibility(xmlParser.getAttributeBooleanValue(null, "visible", true) ? VISIBLE : INVISIBLE); key.setKeyListener(this); if (attrs.shiftLabel != null & attrs.shiftLabel.length() > 0) { mKeysWithShiftLabel.add(key); } linearLayout.addView(key); } } } while (xmlParser.getEventType() != XmlResourceParser.END_TAG || !tag.equals(XML_TAG_LAYOUT)); return linearLayout; }
Example 11
Source File: Keyboard.java From hackerskeyboard with Apache License 2.0 | 4 votes |
private void loadKeyboard(Context context, XmlResourceParser parser) { boolean inKey = false; boolean inRow = false; float x = 0; int y = 0; Key key = null; Row currentRow = null; Resources res = context.getResources(); boolean skipRow = false; mRowCount = 0; try { int event; Key prevKey = null; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { String tag = parser.getName(); if (TAG_ROW.equals(tag)) { inRow = true; x = 0; currentRow = createRowFromXml(res, parser); skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; if (currentRow.extension) { if (mUseExtension) { ++mExtensionRowCount; } else { skipRow = true; } } if (skipRow) { skipToEndOfRow(parser); inRow = false; } } else if (TAG_KEY.equals(tag)) { inKey = true; key = createKeyFromXml(res, currentRow, Math.round(x), y, parser); key.realX = x; if (key.codes == null) { // skip this key, adding its width to the previous one if (prevKey != null) { prevKey.width += key.width; } } else { mKeys.add(key); prevKey = key; if (key.codes[0] == KEYCODE_SHIFT) { if (mShiftKeyIndex == -1) { mShiftKey = key; mShiftKeyIndex = mKeys.size()-1; } mModifierKeys.add(key); } else if (key.codes[0] == KEYCODE_ALT_SYM) { mModifierKeys.add(key); } else if (key.codes[0] == LatinKeyboardView.KEYCODE_CTRL_LEFT) { mCtrlKey = key; } else if (key.codes[0] == LatinKeyboardView.KEYCODE_ALT_LEFT) { mAltKey = key; } else if (key.codes[0] == LatinKeyboardView.KEYCODE_META_LEFT) { mMetaKey = key; } } } else if (TAG_KEYBOARD.equals(tag)) { parseKeyboardAttributes(res, parser); } } else if (event == XmlResourceParser.END_TAG) { if (inKey) { inKey = false; x += key.realGap + key.realWidth; if (x > mTotalWidth) { mTotalWidth = Math.round(x); } } else if (inRow) { inRow = false; y += currentRow.verticalGap; y += currentRow.defaultHeight; mRowCount++; } else { // TODO: error or extend? } } } } catch (Exception e) { Log.e(TAG, "Parse error:" + e); e.printStackTrace(); } mTotalHeight = y - mDefaultVerticalGap; }
Example 12
Source File: ParseLicenseXml.java From LicenseView with Apache License 2.0 | 4 votes |
public static List<License> Parse(XmlResourceParser parser) throws XmlPullParserException, IOException { List<License> licenses = new ArrayList<License>(); int event = parser.getEventType(); String name = null; String type = null; String license = null; while (event != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { if (!parser.getName().equals(TAG_ROOT) && !parser.getName().equals(TAG_CHILD)) throw new XmlPullParserException( "Error in xml: tag isn't '" + TAG_ROOT + "' or '" + TAG_CHILD + "' at line:" + parser.getLineNumber()); name = parser.getAttributeValue(null, ATTR_NAME); type = parser.getAttributeValue(null, ATTR_TYPE); } else if (event == XmlResourceParser.TEXT) { license = parser.getText(); } else if (event == XmlResourceParser.END_TAG) { if (name != null && type != null && license != null && !parser.getName().equals(TAG_ROOT)) { if (type.equals(VALUE_FILE)) { licenses.add(new License(name, License.TYPE_FILE, license)); System.out.println(name); } else if (type.equals(VALUE_LIBRARY)) { licenses.add(new License(name, License.TYPE_LIBRARY, license)); System.out.println(name); } else { throw new XmlPullParserException( "Error in xml: 'type' isn't valid at line:" + parser.getLineNumber()); } } else if (name == null) { throw new XmlPullParserException( "Error in xml: doesn't contain a 'name' at line:" + parser.getLineNumber()); } else if (type == null) { throw new XmlPullParserException( "Error in xml: doesn't contain a 'type' at line:" + parser.getLineNumber()); } else if (license == null){ throw new XmlPullParserException( "Error in xml: doesn't contain a 'license text' at line:" + parser.getLineNumber()); } } event = parser.next(); } parser.close(); return licenses; }