Java Code Examples for org.xmlpull.v1.XmlPullParser

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-client_1, under directory /src/com/googlecode/asmack/parser/.

Source file: SmackParser.java

  18 
vote

/** 
 * Create a new xml pull parser for a given stanza.
 * @param stanza The stanza to use as input.
 * @return A new pull parser, seeked to the first START_TAG.
 * @throws XmlPullParserException In case of a XML error.
 * @throws IOException In case of a read error.
 */
private XmlPullParser getParser(Stanza stanza) throws XmlPullParserException, IOException {
  XmlPullParser parser=xmlPullParserFactory.newPullParser();
  parser.setInput(new StringReader(stanza.getXml()));
  parser.nextTag();
  return parser;
}
 

Example 2

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/addons/.

Source file: AddOnsFactory.java

  18 
vote

protected boolean isPackageContainAnAddon(Context context,String packageNameSchemePart) throws NameNotFoundException {
  PackageInfo newPackage=context.getPackageManager().getPackageInfo(packageNameSchemePart,PackageManager.GET_RECEIVERS + PackageManager.GET_META_DATA);
  if (newPackage.receivers != null) {
    ActivityInfo[] receivers=newPackage.receivers;
    for (    ActivityInfo aReceiver : receivers) {
      if (aReceiver == null || aReceiver.applicationInfo == null || !aReceiver.enabled || !aReceiver.applicationInfo.enabled)       continue;
      final XmlPullParser xml=aReceiver.loadXmlMetaData(context.getPackageManager(),RECEIVER_META_DATA);
      if (xml != null) {
        return true;
      }
    }
  }
  return false;
}
 

Example 3

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/util/.

Source file: ParserUtils.java

  18 
vote

/** 
 * Build and return a new  {@link XmlPullParser} with the given{@link InputStream} assigned to it.
 */
public static XmlPullParser newPullParser(InputStream input) throws XmlPullParserException {
  if (sFactory == null) {
    sFactory=XmlPullParserFactory.newInstance();
  }
  final XmlPullParser parser=sFactory.newPullParser();
  parser.setInput(input,null);
  return parser;
}
 

Example 4

From project be.norio.twunch.android, under directory /src/com/google/android/apps/iosched/util/.

Source file: ParserUtils.java

  18 
vote

/** 
 * Build and return a new  {@link XmlPullParser} with the given{@link InputStream} assigned to it.
 */
public static XmlPullParser newPullParser(InputStream input) throws XmlPullParserException {
  if (sFactory == null) {
    sFactory=XmlPullParserFactory.newInstance();
  }
  final XmlPullParser parser=sFactory.newPullParser();
  parser.setInput(input,null);
  return parser;
}
 

Example 5

From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/util/.

Source file: ParserUtils.java

  18 
vote

/** 
 * Build and return a new  {@link XmlPullParser} with the given{@link InputStream} assigned to it.
 */
public static XmlPullParser newPullParser(InputStream input) throws XmlPullParserException {
  if (sFactory == null) {
    sFactory=XmlPullParserFactory.newInstance();
  }
  final XmlPullParser parser=sFactory.newPullParser();
  parser.setInput(input,null);
  return parser;
}
 

Example 6

From project Android, under directory /AndroidNolesCore/src/util/.

Source file: XMLParserConnection.java

  17 
vote

public void execute(String urlString,int size,XMLParserListener listener){
  HttpURLConnection urlConnection=null;
  try {
    final URL url=new URL(urlString);
    urlConnection=(HttpURLConnection)url.openConnection();
    urlConnection.setRequestProperty("User-Agent",mUserAgent);
    final InputStream input=new BufferedInputStream(urlConnection.getInputStream(),size);
    try {
      final XmlPullParser parser=Xml.newPullParser();
      parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,false);
      parser.setInput(input,null);
      parser.nextTag();
      listener.onPostExecute(parser);
    }
 catch (    XmlPullParserException e) {
      LogUtils.LOGW(LOG_TAG,"Malformed response for ",e);
    }
 finally {
      if (input != null) {
        input.close();
      }
    }
  }
 catch (  IOException e) {
    LogUtils.LOGW(LOG_TAG,"Problem reading remote response for ",e);
  }
 finally {
    if (urlConnection != null) {
      urlConnection.disconnect();
    }
  }
}
 

Example 7

From project android-api_1, under directory /android-lib/src/com/catchnotes/api/.

Source file: CatchNotesXmlParser.java

  17 
vote

public void parseNotesXml(HttpResponse response,ArrayList<CatchNote> notes,long parentId) throws XmlPullParserException, IOException, IllegalArgumentException {
  if (response == null || notes == null) {
    throw new IllegalArgumentException();
  }
  XmlPullParserFactory factory=XmlPullParserFactory.newInstance();
  factory.setNamespaceAware(true);
  XmlPullParser parser=factory.newPullParser();
  parser.setInput(response.getEntity().getContent(),null);
  int eventType=parser.getEventType();
  while (eventType != XmlPullParser.END_DOCUMENT) {
    if (eventType == XmlPullParser.START_DOCUMENT) {
      parse_trace("Beginning XML pullparse.");
    }
 else     if (eventType == XmlPullParser.START_TAG) {
      String startTag=parser.getName();
      if (XML_TAG_NOTES.equals(startTag)) {
        parse_trace("Parsing notes.");
      }
 else       if (XML_TAG_NOTE.equals(startTag)) {
        parse_trace("Parsing a note.");
        parseNote(parser,notes,parentId);
      }
 else {
        parse_trace("(parseNotesXml) unknown XML tag: <" + startTag + ">");
      }
    }
 else     if (eventType == XmlPullParser.END_TAG) {
      String endTag=parser.getName();
      if (XML_TAG_NOTES.equals(endTag)) {
        parse_trace("Parsed " + notes.size() + " notes.");
      }
    }
    eventType=parser.next();
  }
}
 

Example 8

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/keyboard/internal/.

Source file: KeyboardBuilder.java

  17 
vote

public static String parseKeyboardLocale(Context context,int resId) throws XmlPullParserException, IOException {
  final Resources res=context.getResources();
  final XmlPullParser parser=res.getXml(resId);
  if (parser == null)   return "";
  int event;
  while ((event=parser.next()) != XmlPullParser.END_DOCUMENT) {
    if (event == XmlPullParser.START_TAG) {
      final String tag=parser.getName();
      if (TAG_KEYBOARD.equals(tag)) {
        final TypedArray keyboardAttr=res.obtainAttributes(Xml.asAttributeSet(parser),R.styleable.Keyboard);
        final String locale=keyboardAttr.getString(R.styleable.Keyboard_keyboardLocale);
        keyboardAttr.recycle();
        return locale;
      }
 else {
        throw new IllegalStartTag(parser,TAG_KEYBOARD);
      }
    }
  }
  return "";
}
 

Example 9

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/provider/.

Source file: GoogleBooksStore.java

  17 
vote

@Override void parseResponse(InputStream in,ResponseParser responseParser) throws IOException {
  final XmlPullParser parser=Xml.newPullParser();
  try {
    parser.setInput(new InputStreamReader(in));
    int type;
    while ((type=parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
    }
    if (type != XmlPullParser.START_TAG) {
      throw new InflateException(parser.getPositionDescription() + ": No start tag found!");
    }
    String name=parser.getName();
    if (RESPONSE_TAG_FEED.equals(name)) {
      responseParser.parseResponse(parser);
    }
  }
 catch (  XmlPullParserException e) {
    final IOException ioe=new IOException("Could not parse the response");
    ioe.initCause(e);
    throw ioe;
  }
}
 

Example 10

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/adapter/.

Source file: ProvisionParser.java

  17 
vote

void parseProvisionDocXml(String doc) throws IOException {
  Policy policy=new Policy();
  try {
    XmlPullParserFactory factory=XmlPullParserFactory.newInstance();
    XmlPullParser parser=factory.newPullParser();
    parser.setInput(new ByteArrayInputStream(doc.getBytes()),"UTF-8");
    int type=parser.getEventType();
    if (type == XmlPullParser.START_DOCUMENT) {
      type=parser.next();
      if (type == XmlPullParser.START_TAG) {
        String tagName=parser.getName();
        if (tagName.equals("wap-provisioningdoc")) {
          parseWapProvisioningDoc(parser,policy);
        }
      }
    }
  }
 catch (  XmlPullParserException e) {
    throw new IOException();
  }
  setPolicy(policy);
}
 

Example 11

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/util/.

Source file: BackupUtil.java

  17 
vote

public static int restoreBackup(Context context){
  XmlPullParser parser=Xml.newPullParser();
  FileInputStream file=null;
  int appsRestored=0;
  try {
    file=new FileInputStream(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/subackup.xml"));
    parser.setInput(file,"UTF-8");
    int eventType=parser.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG:
        if (parser.getName().equalsIgnoreCase("apps")) {
          parser.next();
          appsRestored=restoreApps(context,parser);
        }
 else         if (parser.getName().equalsIgnoreCase("prefs")) {
          parser.next();
          restorePrefs(context,parser);
        }
      break;
  }
  eventType=parser.next();
}
}
 catch (XmlPullParserException e) {
Log.e(TAG,"Error restoring backup",e);
return -1;
}
catch (IOException e) {
Log.e(TAG,"Error restoring backup",e);
return -1;
}
return appsRestored;
}
 

Example 12

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/keyboard/internal/.

Source file: KeyboardBuilder.java

  17 
vote

public static String parseKeyboardLocale(Context context,int resId) throws XmlPullParserException, IOException {
  final Resources res=context.getResources();
  final XmlPullParser parser=res.getXml(resId);
  if (parser == null)   return "";
  int event;
  while ((event=parser.next()) != XmlPullParser.END_DOCUMENT) {
    if (event == XmlPullParser.START_TAG) {
      final String tag=parser.getName();
      if (TAG_KEYBOARD.equals(tag)) {
        final TypedArray keyboardAttr=res.obtainAttributes(Xml.asAttributeSet(parser),R.styleable.Keyboard);
        final String locale=keyboardAttr.getString(R.styleable.Keyboard_keyboardLocale);
        keyboardAttr.recycle();
        return locale;
      }
 else {
        throw new IllegalStartTag(parser,TAG_KEYBOARD);
      }
    }
  }
  return "";
}
 

Example 13

From project apps-for-android, under directory /Photostream/src/com/google/android/photostream/.

Source file: Flickr.java

  17 
vote

/** 
 * Parses a valid Flickr XML response from the specified input stream. When the Flickr response contains the OK tag, the response is sent to the specified response parser.
 * @param in The input stream containing the response sent by Flickr.
 * @param responseParser The parser to use when the response is valid.
 * @throws IOException
 */
private void parseResponse(InputStream in,ResponseParser responseParser) throws IOException {
  final XmlPullParser parser=Xml.newPullParser();
  try {
    parser.setInput(new InputStreamReader(in));
    int type;
    while ((type=parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
    }
    if (type != XmlPullParser.START_TAG) {
      throw new InflateException(parser.getPositionDescription() + ": No start tag found!");
    }
    String name=parser.getName();
    if (RESPONSE_TAG_RSP.equals(name)) {
      final String value=parser.getAttributeValue(null,RESPONSE_ATTR_STAT);
      if (!RESPONSE_STATUS_OK.equals(value)) {
        throw new IOException("Wrong status: " + value);
      }
    }
    responseParser.parseResponse(parser);
  }
 catch (  XmlPullParserException e) {
    final IOException ioe=new IOException("Could not parser the response");
    ioe.initCause(e);
    throw ioe;
  }
}
 

Example 14

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/dal/repository/.

Source file: XmlTskRepository.java

  17 
vote

private XmlPullParser getParser() throws XmlPullParserException, UnsupportedEncodingException, TskNotFoundException {
  File tskDir=new File(DataConstants.FS_APP_DIR_NAME);
  File tsk=new File(tskDir,"tsk.xml");
  InputStreamReader iReader;
  try {
    iReader=new InputStreamReader(new FileInputStream(tsk),"UTF-8");
  }
 catch (  FileNotFoundException e) {
    throw new TskNotFoundException();
  }
  BufferedReader buf=new BufferedReader(iReader);
  XmlPullParser parser=Xml.newPullParser();
  parser.setInput(buf);
  return parser;
}
 

Example 15

From project BusFollower, under directory /src/net/argilo/busfollower/ocdata/.

Source file: OCTranspoDataFetcher.java

  17 
vote

public GetNextTripsForStopResult getNextTripsForStop(String stopNumber,String routeNumber) throws IOException, XmlPullParserException, IllegalArgumentException {
  validateStopNumber(stopNumber);
  validateRouteNumber(routeNumber);
  httpClient=new DefaultHttpClient(getHttpParams());
  HttpPost post=new HttpPost("https://api.octranspo1.com/v1.1/GetNextTripsForStop");
  List<NameValuePair> params=new ArrayList<NameValuePair>(4);
  params.add(new BasicNameValuePair("appID",context.getString(R.string.oc_transpo_application_id)));
  params.add(new BasicNameValuePair("apiKey",context.getString(R.string.oc_transpo_application_key)));
  params.add(new BasicNameValuePair("routeNo",routeNumber));
  params.add(new BasicNameValuePair("stopNo",stopNumber));
  post.setEntity(new UrlEncodedFormEntity(params));
  HttpResponse response=httpClient.execute(post);
  XmlPullParserFactory factory=XmlPullParserFactory.newInstance();
  factory.setNamespaceAware(true);
  XmlPullParser xpp=factory.newPullParser();
  InputStream in=response.getEntity().getContent();
  xpp.setInput(in,"UTF-8");
  xpp.next();
  xpp.next();
  xpp.next();
  xpp.next();
  GetNextTripsForStopResult result=new GetNextTripsForStopResult(context,db,xpp,stopNumber);
  in.close();
  return result;
}
 

Example 16

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/item/.

Source file: DrawableItem.java

  15 
vote

@Override public void inflate(Resources r,XmlPullParser parser,AttributeSet attrs) throws XmlPullParserException, IOException {
  super.inflate(r,parser,attrs);
  TypedArray a=r.obtainAttributes(attrs,R.styleable.DrawableItem);
  drawableId=a.getResourceId(R.styleable.DrawableItem_drawable,0);
  a.recycle();
}
 

Example 17

From project androidpn, under directory /androidpn-client/src/org/androidpn/client/.

Source file: NotificationIQProvider.java

  15 
vote

@Override public IQ parseIQ(XmlPullParser parser) throws Exception {
  NotificationIQ notification=new NotificationIQ();
  for (boolean done=false; !done; ) {
    int eventType=parser.next();
    if (eventType == 2) {
      if ("id".equals(parser.getName())) {
        notification.setId(parser.nextText());
      }
      if ("apiKey".equals(parser.getName())) {
        notification.setApiKey(parser.nextText());
      }
      if ("title".equals(parser.getName())) {
        notification.setTitle(parser.nextText());
      }
      if ("message".equals(parser.getName())) {
        notification.setMessage(parser.nextText());
      }
      if ("uri".equals(parser.getName())) {
        notification.setUri(parser.nextText());
      }
    }
 else     if (eventType == 3 && "notification".equals(parser.getName())) {
      done=true;
    }
  }
  return notification;
}
 

Example 18

From project androidquery, under directory /demo/src/com/androidquery/test/async/.

Source file: AjaxLoadingActivity.java

  15 
vote

public void async_xpp(){
  String url="https://picasaweb.google.com/data/feed/base/featured?max-results=8";
  aq.progress(R.id.progress).ajax(url,XmlPullParser.class,new AjaxCallback<XmlPullParser>(){
    public void callback(    String url,    XmlPullParser xpp,    AjaxStatus status){
      Map<String,String> images=new LinkedHashMap<String,String>();
      String currentTitle=null;
      try {
        int eventType=xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
          if (eventType == XmlPullParser.START_TAG) {
            String tag=xpp.getName();
            if ("title".equals(tag)) {
              currentTitle=xpp.nextText();
            }
 else             if ("content".equals(tag)) {
              String imageUrl=xpp.getAttributeValue(0);
              images.put(currentTitle,imageUrl);
            }
          }
          eventType=xpp.next();
        }
      }
 catch (      Exception e) {
        AQUtility.report(e);
      }
      showResult(images,status);
    }
  }
);
}
 

Example 19

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/util/.

Source file: MimeTypeParser.java

  15 
vote

public MimeTypes parse() throws XmlPullParserException, IOException {
  mMimeTypes=new MimeTypes();
  int eventType=mXpp.getEventType();
  while (eventType != XmlPullParser.END_DOCUMENT) {
    String tag=mXpp.getName();
    if (eventType == XmlPullParser.START_TAG) {
      if (tag.equals(TAG_MIMETYPES)) {
      }
 else       if (tag.equals(TAG_TYPE)) {
        addMimeTypeStart();
      }
    }
 else     if (eventType == XmlPullParser.END_TAG) {
      if (tag.equals(TAG_MIMETYPES)) {
      }
    }
    eventType=mXpp.next();
  }
  return mMimeTypes;
}
 

Example 20

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/.

Source file: RegisteredComponentCache.java

  15 
vote

void parseTechLists(Resources res,String packageName,XmlPullParser parser,ResolveInfo resolveInfo,ArrayList<ComponentInfo> components) throws XmlPullParserException, IOException {
  int eventType=parser.getEventType();
  while (eventType != XmlPullParser.START_TAG) {
    eventType=parser.next();
  }
  ArrayList<String> items=new ArrayList<String>();
  String tagName;
  eventType=parser.next();
  do {
    tagName=parser.getName();
    if (eventType == XmlPullParser.START_TAG && "tech".equals(tagName)) {
      items.add(parser.nextText());
    }
 else     if (eventType == XmlPullParser.END_TAG && "tech-list".equals(tagName)) {
      int size=items.size();
      if (size > 0) {
        String[] techs=new String[size];
        techs=items.toArray(techs);
        items.clear();
        components.add(new ComponentInfo(resolveInfo,techs));
      }
    }
    eventType=parser.next();
  }
 while (eventType != XmlPullParser.END_DOCUMENT);
}
 

Example 21

From project AsmackService, under directory /src/com/googlecode/asmack/connection/impl/.

Source file: XmppInputStream.java

  15 
vote

/** 
 * Read the stream opening.
 * @throws XmlPullParserException In case of invalid xml.
 * @throws IOException In case of a transport error.
 */
public void readOpening() throws XmlPullParserException, IOException {
  parser.nextTag();
  Log.d(TAG,"Receiving stream start...");
  parser.require(XmlPullParser.START_TAG,"http://etherx.jabber.org/streams","stream");
  for (int i=0, l=parser.getAttributeCount(); i < l; i++) {
    String attributeName=parser.getAttributeName(i);
    String attributeNamespace=parser.getAttributeNamespace(i);
    if (attributeNamespace.length() == 0) {
      attributeNamespace=parser.getNamespace();
    }
    if (attributeNamespace.equals("http://www.w3.org/XML/1998/namespace") && attributeName.equals("lang")) {
      language=parser.getAttributeValue(i).toString();
      continue;
    }
    if (!attributeNamespace.equals("http://etherx.jabber.org/streams")) {
      Log.d(TAG,"Unknown stream attribute namespace " + attributeNamespace + " containing "+ attributeName);
      continue;
    }
    if (attributeName.equals("version")) {
      version=parser.getAttributeValue(i).toString();
      continue;
    }
    if (attributeName.equals("from")) {
      from=parser.getAttributeValue(i).toString();
      continue;
    }
    if (attributeName.equals("to")) {
      to=parser.getAttributeValue(i).toString();
      continue;
    }
    if (attributeName.equals("id")) {
      id=parser.getAttributeValue(i).toString();
      continue;
    }
    Log.d(TAG,"Unknown stream attribute " + attributeName + " from namespace"+ attributeNamespace);
  }
  Log.d(TAG,"Stream started!");
}
 

Example 22

From project callmeter, under directory /src/de/ub0r/android/callmeter/data/.

Source file: DataProvider.java

  15 
vote

/** 
 * Parse all values of a given XML element to import it as {@link ContentValues} into {@link SQLiteDatabase}.
 * @param context {@link Context}
 * @param parser XmlPullParser
 * @param lists list of  {@link ContentValues} {@link ArrayList}s.
 * @param name name of the holding element
 * @param list current list
 * @throws XmlPullParserException XmlPullParserException
 * @throws IOException IOException
 */
private static void parseValues(final Context context,final XmlPullParser parser,final HashMap<String,ArrayList<ContentValues>> lists,final String name,final ArrayList<ContentValues> list) throws XmlPullParserException, IOException {
  String element=name.substring(0,name.length() - 1);
  while (parser.next() != XmlPullParser.END_TAG) {
    if (parser.getEventType() != XmlPullParser.START_TAG) {
      continue;
    }
    parser.require(XmlPullParser.START_TAG,null,element);
    ContentValues cv=new ContentValues();
    while (parser.next() != XmlPullParser.END_TAG || !element.equals(parser.getName())) {
      if (parser.getEventType() != XmlPullParser.START_TAG) {
        continue;
      }
      String k=parser.getName();
      if (k.equals("hours")) {
        parser.next();
        ArrayList<ContentValues> l=new ArrayList<ContentValues>();
        lists.put(DataProvider.Hours.TABLE,l);
        parseValues(context,parser,lists,k,l);
      }
 else       if (k.equals("numbers")) {
        parser.next();
        ArrayList<ContentValues> l=new ArrayList<ContentValues>();
        lists.put(DataProvider.Numbers.TABLE,l);
        parseValues(context,parser,lists,k,l);
      }
 else {
        parser.next();
        String v=parser.getText();
        if (!TextUtils.isEmpty(v)) {
          cv.put(k,decodeString(v));
        }
      }
    }
    if (cv.size() > 0) {
      list.add(cv);
    }
  }
}
 

Example 23

From project channel-directory, under directory /src/org/jivesoftware/smackx/provider/.

Source file: DiscoverItemsProvider.java

  15 
vote

public IQ parseIQ(XmlPullParser parser) throws Exception {
  DiscoverItems discoverItems=new DiscoverItems();
  boolean done=false;
  DiscoverItems.Item item;
  String jid="";
  String name="";
  String action="";
  String node="";
  discoverItems.setNode(parser.getAttributeValue("","node"));
  while (!done) {
    int eventType=parser.next();
    if (eventType == XmlPullParser.START_TAG && "item".equals(parser.getName())) {
      jid=parser.getAttributeValue("","jid");
      name=parser.getAttributeValue("","name");
      node=parser.getAttributeValue("","node");
      action=parser.getAttributeValue("","action");
    }
 else     if (eventType == XmlPullParser.END_TAG && "item".equals(parser.getName())) {
      item=new DiscoverItems.Item(jid);
      item.setName(name);
      item.setNode(node);
      item.setAction(action);
      discoverItems.addItem(item);
    }
 else     if (eventType == XmlPullParser.START_TAG && "set".equals(parser.getName())) {
      RSMSet rsmSet=RSMSet.parse(parser);
      discoverItems.setRsmSet(rsmSet);
    }
 else     if (eventType == XmlPullParser.END_TAG && "query".equals(parser.getName())) {
      done=true;
    }
  }
  return discoverItems;
}
 

Example 24

From project CineShowTime-Android, under directory /Libraries/GreenDroid/src/greendroid/widget/item/.

Source file: DrawableItem.java

  15 
vote

@Override public void inflate(Resources r,XmlPullParser parser,AttributeSet attrs) throws XmlPullParserException, IOException {
  super.inflate(r,parser,attrs);
  TypedArray a=r.obtainAttributes(attrs,R.styleable.DrawableItem);
  drawableId=a.getResourceId(R.styleable.DrawableItem_drawable,0);
  a.recycle();
}
 

Example 25

From project com.juick.xmpp, under directory /src/com/juick/xmpp/extensions/.

Source file: Delay.java

  15 
vote

public static Delay parse(XmlPullParser parser) throws XmlPullParserException, IOException {
  Delay delay=new Delay();
  String from=parser.getAttributeValue(null,"from");
  if (from != null) {
    delay.from=new JID(from);
  }
  delay.stamp=parser.getAttributeValue(null,"stamp");
  delay.description=XmlUtils.getTagText(parser);
  return delay;
}
 

Example 26

From project cornerstone, under directory /packages/apps/CSLauncher/src/com/onskreen/cornerstone/launcher/.

Source file: CSLauncher.java

  15 
vote

/** 
 * Refreshes the favorite applications stacked over the all apps button. The number of favorites depends on the user.
 */
private static void beginDocument(XmlPullParser parser,String firstElementName) throws XmlPullParserException, IOException {
  int type;
  while ((type=parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
  }
  if (type != XmlPullParser.START_TAG) {
    throw new XmlPullParserException("No start tag found");
  }
  if (!parser.getName().equals(firstElementName)) {
    throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() + ", expected "+ firstElementName);
  }
}