android.sax.StartElementListener Java Examples

The following examples show how to use android.sax.StartElementListener. 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: XmlDirectoryContentHandler.java    From android-vlc-remote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Object getContent(URLConnection connection) throws IOException {
    mDirectory = new Directory();
    RootElement root = new RootElement("", "root");
    Element element = root.getChild("", "element");
    element.setStartElementListener(new StartElementListener() {
        /** {@inheritDoc} */
        @Override
        public void start(Attributes attributes) {
            final String path = attributes.getValue("", "path");
            if (path != null && !path.startsWith("/")) {
                File.PATH_TYPE = File.PATH_WINDOWS;
            } else {
                File.PATH_TYPE = File.PATH_UNIX;
            }
            File file = createFile(attributes);
            mDirectory.add(file);
        }
    });
    parse(connection, root.getContentHandler());
    Directory.ROOT_DIRECTORY = (File.PATH_TYPE == File.PATH_WINDOWS) ? Directory.WINDOWS_ROOT_DIRECTORY : Directory.UNIX_DIRECTORY;
    if(Directory.ROOT_DIRECTORY.equals(mDirectory.getPath())) {
        hideParent();
        if(!mDirectory.isEmpty()) {
            mDirectory.add(0, File.LIBRARIES);
        }
    } else {
        setParentTop();
    }
    return mDirectory;
}