From b2dc509d5530a9af3b48d7dce7db1e7bf66b06d5 Mon Sep 17 00:00:00 2001 From: Linjiajia <319408893@qq.com> Date: 星期三, 28 二月 2024 17:26:58 +0800 Subject: [PATCH] 1、修复新增家庭设备时存在备忘录问题\n2、旅游模块新增加“感言”、“其他费用”、“备注”字段 --- app/src/main/java/com/application/zhangshi_app_android/widget/Node.java | 47 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/application/zhangshi_app_android/widget/Node.java b/app/src/main/java/com/application/zhangshi_app_android/widget/Node.java index 7447534..26f2acc 100644 --- a/app/src/main/java/com/application/zhangshi_app_android/widget/Node.java +++ b/app/src/main/java/com/application/zhangshi_app_android/widget/Node.java @@ -96,7 +96,7 @@ if (this.parent!=null){ throw new RuntimeException("鍙兘鍒濆鍖栨牴鑺傜偣"); } - //鏍规嵁鍙鎬ф壘鍒版渶鍚庝竴涓涓�瀛愯妭鐐癸紝鍗虫渶涓婅竟鐨勮妭鐐� + //鏍规嵁鍙鎬ф壘鍒版渶鍚庝竴涓涓�瀛愯妭鐐癸紝鍗虫渶鍙充笂杈圭殑鑺傜偣 setViewPositionRecursion(getVisibleTopNode(), this,x,y); } @@ -116,12 +116,17 @@ } //鍥犱负 y 鏄暣棰楄妭鐐规爲鐨剏鍧愭爣锛屾甯告儏鍐典笅锛寉閮戒細鏄� 椤堕儴鑺傜偣topNode 鐨剏鍧愭爣 - //浣嗘槸 鏈変竴绉嶆儏鍐碉紝灏辨槸椤堕儴鑺傜偣topNode鍒氬ソ鏄牴鑺傜偣rootNode鐨勫敮涓�瀛愯妭鐐癸紝涓攖opNode娌℃湁閰嶅伓锛屾鏃秚opNode鐨勯珮搴︽瘮rootNode鐨勯珮搴﹀皬锛屾墍浠ユ鏃剁殑y鏄痳ootNode鐨剏鍧愭爣 - int centerY; - if (rootNode.height >= topNode.height && rootNode == topNode.parent && rootNode.children.size() == 1){ - centerY = y + rootNode.getAllVisibleHeight()/2; - }else { - centerY = y + topNode.getAllVisibleHeight()/2; + int centerY = y + topNode.getAllVisibleHeight()/2; + //浣嗘槸 鏈変竴绉嶆儏鍐碉紝灏辨槸椤堕儴鑺傜偣topNode娌℃湁閰嶅伓锛屽鏋渢opNode鐨勭鍏堣妭鐐规湁閰嶅伓锛屼笖娌℃湁澶氬瓙瀛欙紝姝ゆ椂topNode鐨勯珮搴︽瘮鏈夐厤鍋剁殑绁栧厛鑺傜偣鐨勯珮搴﹀皬锛屾墍浠ユ鏃剁殑y鏄珮搴︽渶楂樼殑绁栧厛鑺傜偣鐨剏鍧愭爣 + if (topNode instanceof SimpleNode){ + Node tempNode = topNode.parent; + while (tempNode.children.size() == 1){ + if (tempNode.height > topNode.height){ + centerY = y + tempNode.getAllVisibleHeight()/2; + break; + } + tempNode = tempNode.parent; + } } topNode.setViewPosition(x + topNode.getToSpecifyNodeWidth(rootNode) - topNode.width, centerY); // 鏍规嵁topNode鐨勪綅缃紝閫掑綊璁剧疆鎵�鏈夎妭鐐圭殑浣嶇疆 @@ -133,7 +138,7 @@ for (Node child : parentNode.children) { if (child == node) { centerYList.add(child.centerY); - currentBottom = currentBottom + node.getVisibleTopNode().top + node.getAllVisibleHeight(); + currentBottom = currentBottom + child.getVisibleTop() + child.getAllVisibleHeight(); continue; } if (!child.isVisible){ @@ -148,7 +153,7 @@ //鍙栨渶澶у�笺�佹渶灏忓�� 鍜� 鐨勪腑闂� int totalCenterY = 0; - if (centerYList.size() > 0) { + if (centerYList.size() > 1) { int min = centerYList.get(0); int max = centerYList.get(0); for (int i = 1; i < centerYList.size(); i++) { @@ -161,6 +166,8 @@ } } totalCenterY = (min + max) / 2; + }else{ + totalCenterY = centerYList.get(0); } if (parentNode.children.size() > 1) { @@ -174,7 +181,21 @@ node = parentNode; } } + //鑾峰彇 浠ュ綋鍓嶈妭鐐逛负鏍硅妭鐐圭殑鏍� 鐨勬渶椤堕儴鐨剏鍧愭爣 + public int getVisibleTop(){ + if (!isVisible){ + return 0; + } + if (!isExpand){ + return top; + } + if (children.size() > 0){ + return Math.min(top,children.get(0).getVisibleTop()); + } + return top; + } + //鑾峰彇 浠ュ綋鍓嶈妭鐐逛负鏍硅妭鐐圭殑鏍� 鐨勬渶娣变竴鑺傜偣 public Node getVisibleTopNode(){ Node topNode; if (!isVisible){ @@ -417,13 +438,15 @@ } if (node.children.size() == 0){ return node.height; - }else { + } else { int heightSum = 0; for (Node child : node.children) { - if (getNodeTreeHeightRecursion(child,considerVisible)!=0){ + int childHeight = getNodeTreeHeightRecursion(child,considerVisible); + //濡傛灉鏈夊涓瓙鑺傜偣涓斿瓙鑺傜偣鏈夐珮搴︼紝閭d箞瀛愯妭鐐逛箣闂磋繕鏈夌珫鐩撮棿闅� + if (node.children.size() > 1 && childHeight > 0){ heightSum += verticalMargin; } - heightSum += getNodeTreeHeightRecursion(child,considerVisible); + heightSum += childHeight; } //瀛愯妭鐐规瘡涓や釜涔嬮棿杩樻湁绔栫洿闂撮殧 return Math.max(node.height,heightSum); -- Gitblit v1.9.1