示例#1
0
    def createListLayoutCode(self, listMetadata, index, listView):
        baseListItemMetadata = listMetadata.mListItemMetadatas[0]
        #        document = XmlUtil.createDocument()
        rootView = RectView(baseListItemMetadata.bound, None)
        for rectView in baseListItemMetadata.baseViews:
            rootView.addChild(rectView)

        for rectView in baseListItemMetadata.additionalViews:
            rootView.addChild(rectView)

        rootView.mChildren.sort(
            key=cmp_to_key(RectUtil.getTopBottomComparator()))
        rootView.mChildren.sort(
            key=cmp_to_key(RectUtil.getLeftRightComparator()))

        rootElement = XmlUtil.createRoot(self.mDipCalculator,
                                         FRAMELAYOUT_ELEMENT, rootView,
                                         self.mColorWriter)
        _map = {}
        self.addChildrenLayout(rootElement, rootView, listView.x, listView.y,
                               _map)

        rectViews = RectUtil.toRects(rootView)
        rectViews.remove(rootView)
        XmlUtil.writeDocument(
            rootView, self.mOutProjectFolder + Constants.DEFAULT_LAYOUT_PATH +
            "/" + Constants.DEFAULT_LAYOUT_LIST_PREFIX + index + ".xml")
示例#2
0
    def createDocument(self):
        #        self.writeHierarchyLog("Un Categorized")
        self.pruneBasic(self.mRootView)
        #        self.writeHierarchyLog("Categorized")

        #        self.pruneToCreateGroupText(self.mRootView)

        #        self.pruneToCreateListItemsHasDrawable(self.mRootView, self.mDrawableMap.values(), 0)

        #        self.pruneToCreateListItemsHasViewsSameSize(self.mRootView, self.mDrawableMap.values(), self.mDefaultAlignThreshold)

        for i in range(len(self.mListViews)):
            listMetadata = self.mListViews[i]
            self.updateListContent(listMetadata, i)

        _map = {}

        #        self.updateColorBackground(self.mRootView)

        rootElement = XmlUtil.createRoot(self.mDipCalculator,
                                         LayoutHelper.FRAMELAYOUT_ELEMENT,
                                         self.mRootView, self.mColorWriter)
        self.addChildrenLayout(rootElement, self.mRootView, 0, 0, _map)

        return rootElement
示例#3
0
    def createListLayoutCode(self, listView, listMetadata,
                             aditionalListViewItemData, index):

        if len(listMetadata.getListItemMetadatas()) == 0:
            return

        baseListItemMetadata = listMetadata.getListItemMetadatas()[0]
        #         Document document = XmlUtil.createDocument()
        rootView = RectView(baseListItemMetadata.bound, None)
        for rectView in baseListItemMetadata.baseViews:
            rootView.addChild(rectView)

        for rectView in baseListItemMetadata.additionalViews:
            rootView.addChild(rectView)

        rootView.mChildren.sort(
            key=cmp_to_key(RectUtil.getTopBottomComparator()))
        rootView.mChildren.sort(
            key=cmp_to_key(RectUtil.getLeftRightComparator()))

        rootElement = XmlUtil.createRoot(self.mDipCalculator,
                                         self.FRAMELAYOUT_ELEMENT, rootView,
                                         self.mColorWriter)
        _map = {}
        self.addChildrenLayout(rootElement, rootView, listView.getX(),
                               listView.getY(), _map)

        rectViews = RectUtil.toRects(rootView)
        rectViews.remove(rootView)

        viewIdMap = {}
        # For baseview
        for rectView in baseListItemMetadata.baseViews:
            elementInfo = _map[rectView]
            viewIdMap[rectView] = elementInfo._id

        # For additionview
        for rectViewWrapper in aditionalListViewItemData:
            elementInfo = _map[rectViewWrapper.view]
            viewIdMap[rectViewWrapper.view] = elementInfo.id

        # TODO: since we checked already (#getAditionalListViewItemData), all
        # base view should only image views
        resourceInfoMap = {}

        listItemMetadatas = listMetadata.getListItemMetadatas()

        for listItemMetadata in listItemMetadatas:
            for baseView in listItemMetadata.baseViews:
                resourceInfoMap[baseView] = self.getInfoResource(baseView)

        for rectViewWrapper in aditionalListViewItemData:
            for viewWrapper in rectViewWrapper.relativeViews:
                resourceInfoMap[viewWrapper.view] = self.getInfoResource(
                    viewWrapper.view)

        listMetadata.generateCode(index,
                                  listView.getListInfo().xmlId,
                                  self.mOutProjectFolder,
                                  aditionalListViewItemData, viewIdMap,
                                  resourceInfoMap)

        # We need to store current x, y, w, h of element before we loss
        # them
        anotateMap = LayoutFilter.anotate(rootView)

        layoutFilter = RelativeLayoutFilter()
        layoutFilter.doFilter(rootView, anotateMap)

        XmlUtil.writeDocument(
            rootView, self.mOutProjectFolder + Constants.DEFAULT_LAYOUT_PATH +
            "/" + Constants.DEFAULT_LAYOUT_LIST_PREFIX + index + ".xml")