Fix ListView GroupCell bug
authorSeungkeun Lee <sngn.lee@samsung.com>
Tue, 10 Jan 2017 08:33:50 +0000 (17:33 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 24 Apr 2017 04:36:47 +0000 (13:36 +0900)
 - When ViewCell was used for GroupHeaderTemplate
   ItemTemplate was used to make reusable view
 - Make disable Reusable feature for GroupHeader
 - Add a internal API to get low level Item object

Change-Id: I01d205a2070c813a170a6eb9aceab8f24bbdb092

Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs
Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs

index 449b6f3..9489901 100644 (file)
@@ -9,6 +9,8 @@ namespace Xamarin.Forms.Platform.Tizen
                const string _heightProperty = "Height";
                readonly Dictionary<Cell, Dictionary<string, EvasObject>> _realizedNativeViews = new Dictionary<Cell, Dictionary<string, EvasObject>>();
 
+               Native.ListView.ItemContext _currentItem;
+
                protected CellRenderer(string style)
                {
                        Class = new GenItemClass(style)
@@ -109,15 +111,22 @@ namespace Xamarin.Forms.Platform.Tizen
                        OnUnrealizedCell(cell);
                }
 
+               internal Native.ListView.ItemContext GetCurrentItem()
+               {
+                       return _currentItem;
+               }
+
                string GetText(object data, string part)
                {
-                       var span = OnGetText((data as Native.ListView.ItemContext).Cell, part);
+                       _currentItem = data as Native.ListView.ItemContext;
+                       var span = OnGetText(_currentItem.Cell, part);
                        return span != null ? ToNative(span).GetMarkupText() : null;
                }
 
                EvasObject GetContent(object data, string part)
                {
-                       var cell = (data as Native.ListView.ItemContext).Cell;
+                       _currentItem = data as Native.ListView.ItemContext;
+                       var cell = _currentItem.Cell;
                        EvasObject nativeView = OnGetContent(cell, part);
                        UpdateRealizedView(cell, part, nativeView);
                        return nativeView;
@@ -125,7 +134,8 @@ namespace Xamarin.Forms.Platform.Tizen
 
                EvasObject ReusableContent(object data, string part, EvasObject old)
                {
-                       var cell = (data as Native.ListView.ItemContext).Cell;
+                       _currentItem = data as Native.ListView.ItemContext;
+                       var cell = _currentItem.Cell;
                        EvasObject nativeView = OnReusableContent(cell, part, old);
                        UpdateRealizedView(cell, part, nativeView);
                        return nativeView;
@@ -148,7 +158,8 @@ namespace Xamarin.Forms.Platform.Tizen
 
                void ItemDeleted(object data)
                {
-                       var cell = (data as Native.ListView.ItemContext).Cell;
+                       _currentItem = data as Native.ListView.ItemContext;
+                       var cell = _currentItem.Cell;
                        _realizedNativeViews.Remove(cell);
                        OnDeleted(cell);
                }
index 564a1ef..bb17ec8 100644 (file)
@@ -38,7 +38,7 @@ namespace Xamarin.Forms.Platform.Tizen
                                // It is a condition for reusable the cell
                                if (listView != null &&
                                        listView.HasUnevenRows == false &&
-                                       !(listView.ItemTemplate is DataTemplateSelector))
+                                       !(listView.ItemTemplate is DataTemplateSelector) && !GetCurrentItem().IsGroupItem)
                                {
                                        return CreateReusableContent(viewCell);
                                }