From 19f06fe98dd0a96b6450b23344747a19c3e01147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Tue, 23 Mar 2010 15:57:23 +0100 Subject: [PATCH] StringBlock, AXmlResourceParser: use ExtDataInput instead of IntReader and ChunkUtil. --- .../androlib/res/decoder/AXmlResourceParser.java | 12 ++++++++---- src/brut/androlib/res/decoder/StringBlock.java | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/brut/androlib/res/decoder/AXmlResourceParser.java b/src/brut/androlib/res/decoder/AXmlResourceParser.java index 09a906e3..f23cbf0d 100644 --- a/src/brut/androlib/res/decoder/AXmlResourceParser.java +++ b/src/brut/androlib/res/decoder/AXmlResourceParser.java @@ -16,11 +16,14 @@ */ package brut.androlib.res.decoder; +import android.content.res.XmlResourceParser; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import org.xmlpull.v1.XmlPullParserException; import android.util.TypedValue; +import brut.util.ExtDataInput; +import com.mindprod.ledatastream.LEDataInputStream; /** * @author Ryszard Wiśniewski @@ -47,7 +50,8 @@ public class AXmlResourceParser implements XmlResourceParser { public void open(InputStream stream) { close(); if (stream != null) { - m_reader = new IntReader(stream, false); + m_reader = new ExtDataInput( + new LEDataInputStream(stream)); } } @@ -56,7 +60,7 @@ public class AXmlResourceParser implements XmlResourceParser { return; } m_operational = false; - m_reader.close(); +// m_reader.close(); m_reader = null; m_strings = null; m_resourceIDs = null; @@ -756,7 +760,7 @@ public class AXmlResourceParser implements XmlResourceParser { private final void doNext() throws IOException { // Delayed initialization. if (m_strings == null) { - ChunkUtil.readCheckType(m_reader, CHUNK_AXML_FILE); + m_reader.skipCheckInt(CHUNK_AXML_FILE); /*chunkSize*/ m_reader.skipInt(); m_strings = StringBlock.read(m_reader); m_namespaces.increaseDepth(); @@ -874,7 +878,7 @@ public class AXmlResourceParser implements XmlResourceParser { * All values are essentially indices, e.g. m_name is * an index of name in m_strings. */ - private IntReader m_reader; + private ExtDataInput m_reader; private boolean m_operational = false; private StringBlock m_strings; private int[] m_resourceIDs; diff --git a/src/brut/androlib/res/decoder/StringBlock.java b/src/brut/androlib/res/decoder/StringBlock.java index 74582c01..64180964 100644 --- a/src/brut/androlib/res/decoder/StringBlock.java +++ b/src/brut/androlib/res/decoder/StringBlock.java @@ -16,6 +16,7 @@ */ package brut.androlib.res.decoder; +import brut.util.ExtDataInput; import java.io.IOException; /** @@ -34,8 +35,8 @@ public class StringBlock { * Reads whole (including chunk type) string block from stream. * Stream must be at the chunk type. */ - public static StringBlock read(IntReader reader) throws IOException { - ChunkUtil.readCheckType(reader, CHUNK_TYPE); + public static StringBlock read(ExtDataInput reader) throws IOException { + reader.skipCheckInt(CHUNK_TYPE); int chunkSize = reader.readInt(); int stringCount = reader.readInt(); int styleOffsetCount = reader.readInt();