Skip to content

Commit

Permalink
Support "slidePackages" attr presentation XML root elem.
Browse files Browse the repository at this point in the history
This is the package search path for slide elements.
Multiple packages can be specified (separated by whitespace).

Issue #14.
  • Loading branch information
ZoogieZork committed Jun 13, 2011
1 parent f71c873 commit 74abdf3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/res/xml/main_presentation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
limitations under the License.
-->

<org.lugatgt.zoogie.introtoandroid.MainPresentation>
<org.lugatgt.zoogie.introtoandroid.MainPresentation slidePackages="org.lugatgt.zoogie.introtoandroid.slides">
</org.lugatgt.zoogie.introtoandroid.MainPresentation>
20 changes: 20 additions & 0 deletions framework/src/org/lugatgt/zoogie/present/PresentationInflater.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
Expand All @@ -38,6 +41,8 @@ public class PresentationInflater {

private static final String TAG = PresentationInflater.class.getSimpleName();

private static final Pattern PACKAGE_SPLIT_RX = Pattern.compile("[,;\\s]+");

private Context ctx;

// CONSTRUCTORS ////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -86,6 +91,7 @@ public Presentation inflate(int resId) {
private Presentation parsePresentation(XmlResourceParser parser, AttributeSet attrs)
throws XmlPullParserException, IOException
{
List<String> slidePackages = new ArrayList<String>();

int eventType = parser.getEventType();
String presentationClassName = null;
Expand All @@ -94,11 +100,25 @@ private Presentation parsePresentation(XmlResourceParser parser, AttributeSet at
do {
if (eventType == XmlPullParser.START_TAG) {
presentationClassName = parser.getName();

String slidePackagesStr = attrs.getAttributeValue(null, "slidePackages");
if (slidePackagesStr != null) {
String[] packageNames = PACKAGE_SPLIT_RX.split(slidePackagesStr.trim());
for (String packageName : packageNames) {
if (!packageName.endsWith(".")) {
packageName += '.';
}
slidePackages.add(packageName);
}
}

break;
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);

slidePackages.add("org.lugatgt.zoogie.present.slide.");

// The root tag is either:
// - "presentation" for the standard Presentation class.
// - The fully-qualified name of a class that extends Presentation.
Expand Down

0 comments on commit 74abdf3

Please sign in to comment.