您的位置:首页 > 其它

给于 dom 解析的跳转框架

2015-12-02 20:00 239 查看
主要类

GoAction 节点的子节点 goto/type/containerActivity/name/kind

StubClassRef 类映射

UIComDesc 节点 (activity/fragment)

UIFlowManager 核心类,结合其他形成逻辑

UITransition 跳转动画框架

思路: 将app 中所有的fragment 和 activity 进行统一管理, 基于dom 解析。将

xml 中声明的activity 和 fragment 进行解析。存入固定的bean,和map中

留待调用,

知识点 dom 解析的运用,hashmap的使用。设置模式。依赖注入,解耦等

xml 格式:

"<?xml version=""1.0"" encoding=""utf-8""?>
<UIFlow package=""com.lepu.tm51"">                                                                                 <Fragment name=""com.lepu.app.fun.chat.controller.HistoryChatingFragment""/>
<!--//声明-->

<Fragment name=""com.lepu.app.fun.chat.controller.album.AlbumFragment"">
<Goto name=""gotoAlbumList""
target=""com.lepu.app.fun.chat.controller.album.AlbumListFragment"" />
<Goto name=""gotoPhotoPreview""
target=""com.lepu.app.fun.chat.controller.album.PhotoPreviewFragment"" />
</Fragment>                                                                                                                                        <Activity name=""com.lepu.app.fun.zhiyuan.activity.BottleGrabEdActivity"">
<Goto name=""gotoChatting"" container-activity=""common""
target=""com.lepu.app.fun.chat.controller.ChattingFragment"" />
</Activity>
</UIFlow>"


dom:    Document dom = XmlManager.createDomByString(content);
String defPackage = dom.getDocumentElement().getAttribute("package");
NodeList nl = dom.getDocumentElement().getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
if (nl.item(i).getNodeType() != Node.ELEMENT_NODE)
continue;
Element ele = (Element) nl.item(i);
UIComDesc uicom = new UIComDesc();
uicom.init(ele, defPackage);

NodeList gonl = ele.getChildNodes();
for (int j = 0; j < gonl.getLength(); j++) {
if (gonl.item(j).getNodeType() != Node.ELEMENT_NODE)
continue;
Element goele = (Element) gonl.item(j);
GoAction goAction = new GoAction();
goAction.init(goele, defPackage);
uicom.addGoAction(goAction.getName(), goAction);
}
uiflowMap.put(uicom.getName(), uicom);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: