From 0bf9e65bc3ba98391e7835c922b15baab3c77876 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 01 六月 2020 14:59:39 +0800
Subject: [PATCH] 上传一个合并的版本

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameRefreshControl.cs |  101 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 77 insertions(+), 24 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameRefreshControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameRefreshControl.cs
index 3ad73c6..2ed4d25 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameRefreshControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameRefreshControl.cs
@@ -5,7 +5,7 @@
 namespace Shared.Phone.UserCenter
 {
     /// <summary>
-    /// 鍋氭垚涓�涓噷闈㈠彧瑁匜rameLayout鐨勫垪琛ㄥ瀷鎺т欢,鏈夊埛鏂板姛鑳�(瀹冧笉浼氳皟鏁撮珮搴�)
+    /// 鍋氭垚涓�涓噷闈㈠彧瑁匜rameLayout鐨勫垪琛ㄥ瀷鎺т欢,鏈夊埛鏂板姛鑳�(鏈夋甯�,瀹冧笉浼氳皟鏁撮珮搴�)
     /// </summary>
     public class VerticalFrameRefreshControl : VerticalRefreshLayout
     {
@@ -30,6 +30,11 @@
                 return m_frameTable;
             }
         }
+
+        /// <summary>
+        /// 涓�涓复鏃剁殑涓滆タ
+        /// </summary>
+        private FrameLayout frameBackTemp = null;
 
         #endregion
 
@@ -80,10 +85,10 @@
             //鍒濆鍖栨甯冩帶浠�
             this.InitFrameTable();
 
-            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
-            if (child != null)
+            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
+            if (value != -1)
             {
-                frame.Y = child.Bottom + rowSpace;
+                frame.Y = value + rowSpace;
             }
             this.m_frameTable.AddChidren(frame);
             //璋冩暣妗屽竷楂樺害
@@ -102,10 +107,11 @@
             //鍒濆鍖栨甯冩帶浠�
             this.InitFrameTable();
 
-            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
-            if (child != null)
+            //鑾峰彇鍧愭爣搴曢儴鏈�涓嬮潰鐨勯偅涓帶浠剁殑搴曢儴鍧愭爣
+            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
+            if (value != -1)
             {
-                frame.Y = child.Bottom;
+                frame.Y = value;
             }
             this.m_frameTable.AddChidren(frame);
             if (rowSpace > 0)
@@ -128,10 +134,11 @@
             //鍒濆鍖栨甯冩帶浠�
             this.InitFrameTable();
 
-            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
-            if (child != null)
+            //鑾峰彇鍧愭爣搴曢儴鏈�涓嬮潰鐨勯偅涓帶浠剁殑搴曢儴鍧愭爣
+            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
+            if (value != -1)
             {
-                row.Y = child.Bottom;
+                row.Y = value;
             }
             this.m_frameTable.AddChidren(row);
             if (rowSpace > 0)
@@ -156,14 +163,12 @@
         /// <param name="buttomSpace">搴曢儴绌虹櫧闂磋窛(鐪熷疄鍊�)</param>
         public void AdjustChidrenFrameHeight(FrameLayout frame, int buttomSpace)
         {
-            var child = frame.GetChildren(frame.ChildrenCount - 1);
-            if (child != null)
+            //鑾峰彇鍧愭爣搴曢儴鏈�涓嬮潰鐨勯偅涓帶浠剁殑搴曢儴鍧愭爣
+            int value = this.GetLocationMostLastViewBottom(frame);
+            if (value != -1)
             {
                 //璋冩暣妗屽竷楂樺害
-                if (frame.Height < child.Bottom + buttomSpace)
-                {
-                    frame.Height = child.Bottom + buttomSpace;
-                }
+                frame.Height = value + buttomSpace;
             }
         }
 
@@ -173,15 +178,23 @@
         /// <param name="buttomSpace">搴曢儴绌虹櫧闂磋窛(鐪熷疄鍊�)</param>
         public void AdjustTableHeight(int buttomSpace = 0)
         {
-            var child = this.m_frameTable?.GetChildren(this.m_frameTable.ChildrenCount - 1);
-            if (child != null)
+            //2020.05.25杩藉姞
+            if (this.frameBackTemp != null && this.frameBackTemp.Parent != null)
+            {
+                this.frameBackTemp.RemoveFromParent();
+            }
+
+            //鑾峰彇鍧愭爣搴曢儴鏈�涓嬮潰鐨勯偅涓帶浠剁殑搴曢儴鍧愭爣
+            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
+            if (value != -1)
             {
                 //璋冩暣妗屽竷楂樺害
-                this.m_frameTable.Height = child.Bottom + buttomSpace;
-                //if (this.m_frameTable.Height < child.Bottom)
-                //{
-                //    this.m_frameTable.Height = child.Bottom;
-                //}
+                this.m_frameTable.Height = value + buttomSpace;
+            }
+            else
+            {
+                //杩樺師涓哄師鏉ョ殑楂樺害
+                this.RecoverTableHeight();
             }
         }
 
@@ -191,6 +204,9 @@
         /// <param name="correctionsValue">Y杞磋ˉ姝e��(鐪熷疄鍊�,鍒楄〃鎺т欢涓嶅湪bodyFramelayout鐨勬椂鍊欎娇鐢�)</param>
         public void AdjustRealHeightByBottomButton(int correctionsValue = 0)
         {
+            //璋冩暣妗屽竷楂樺害 2020.05.25杩藉姞
+            this.AdjustTableHeight();
+
             var btnTemp = new BottomClickButton();
             if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
             {
@@ -198,9 +214,46 @@
                 return;
             }
             //娣诲姞涓存椂鎺т欢,鐩磋嚦鍙互婊戝姩瓒呰繃搴曢儴鎸夐挳
-            var frameBackTemp = new FrameLayout();
+            int oldRowSpace = this.rowSpace;
+            this.rowSpace = 0;
+
+            this.frameBackTemp = new FrameLayout();
             frameBackTemp.Height = ControlCommonResourse.BodyFrameHeight - btnTemp.Yaxis + Application.GetRealHeight(23);
             this.AddChidrenFrame(frameBackTemp);
+
+            this.rowSpace = oldRowSpace;
+        }
+
+        /// <summary>
+        /// 杩樺師妗屽竷楂樺害
+        /// </summary>
+        public void RecoverTableHeight()
+        {
+            if (this.m_frameTable != null)
+            {
+                m_frameTable.Height = this.Height;
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍧愭爣搴曢儴鏈�涓嬮潰鐨勯偅涓帶浠剁殑搴曢儴鍧愭爣
+        /// </summary>
+        /// <returns></returns>
+        private int GetLocationMostLastViewBottom(FrameLayout frame)
+        {
+            int bottomHeight = -1;
+
+            if (frame == null) { return bottomHeight; }
+
+            for (int i = 0; i < frame.ChildrenCount; i++)
+            {
+                var child = frame.GetChildren(i);
+                if (child.Bottom > bottomHeight)
+                {
+                    bottomHeight = child.Bottom;
+                }
+            }
+            return bottomHeight;
         }
 
         #endregion

--
Gitblit v1.8.0