summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen
diff options
context:
space:
mode:
authorSeungkeun Lee <sngn.lee@samsung.com>2016-12-21 00:55:45 (GMT)
committerSeungkeun Lee <sngn.lee@samsung.com>2017-01-04 04:42:12 (GMT)
commitd3c61a8c72daa733aeef5f4446a5b33450df9184 (patch)
tree735a529404b562f93faea585c1bbd801696289ba /Xamarin.Forms.Platform.Tizen
parent7120d48f92fdb17d0eca935a5e35535719c5cd98 (diff)
downloadxamarin-forms-d3c61a8c72daa733aeef5f4446a5b33450df9184.zip
xamarin-forms-d3c61a8c72daa733aeef5f4446a5b33450df9184.tar.gz
xamarin-forms-d3c61a8c72daa733aeef5f4446a5b33450df9184.tar.bz2
Implement Reusable ViewCellrefs/changes/88/106188/6
- Reusable feature was applied when HasUneventRows is false and the ItemTemplate is not created from the DataTEmplateSelector - It means all items has same looks Change-Id: Iadc1262ff4dcf001b1c767fb479851efa6632c44
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs61
1 files changed, 52 insertions, 9 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs
index 69065c8..6328778 100644
--- a/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs
@@ -5,6 +5,7 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class ViewCellRenderer : CellRenderer
{
+ readonly Dictionary<EvasObject, ViewCell> _cacheCandidate = new Dictionary<EvasObject, ViewCell>();
public ViewCellRenderer() : base("full")
{
MainContentPart = "elm.swallow.content";
@@ -12,21 +13,42 @@ namespace Xamarin.Forms.Platform.Tizen
protected string MainContentPart { get; set; }
+ protected override EvasObject OnReusableContent(Cell cell, string part, EvasObject old)
+ {
+ if (_cacheCandidate.ContainsKey(old))
+ {
+ var viewCell = _cacheCandidate[old];
+ var widget = (old as Widget);
+ if (widget != null)
+ widget.IsEnabled = true;
+ viewCell.BindingContext = cell.BindingContext;
+ return old;
+ }
+ return null;
+ }
+
protected override EvasObject OnGetContent(Cell cell, string part)
{
if (part == MainContentPart)
{
- var viewCell = cell as ViewCell;
- if (viewCell != null)
- {
- var renderer = Platform.GetOrCreateRenderer(viewCell.View);
- int height = (int)viewCell.RenderHeight;
- height = height <= 0 ? FindCellContentHeight(viewCell) : height;
+ var viewCell = (ViewCell)cell;
- renderer.NativeView.MinimumHeight = height;
- return renderer.NativeView;
+ var listView = viewCell?.RealParent as ListView;
+
+ // It is a condition for reusable the cell
+ if (listView != null &&
+ listView.HasUnevenRows == false &&
+ !(listView.ItemTemplate is DataTemplateSelector))
+ {
+ return CreateReusableContent(viewCell);
}
- return null;
+
+ var renderer = Platform.GetOrCreateRenderer(viewCell.View);
+ int height = (int)viewCell.RenderHeight;
+ height = height > 0 ? height : FindCellContentHeight(viewCell);
+
+ renderer.NativeView.MinimumHeight = height;
+ return renderer.NativeView;
}
return null;
}
@@ -39,5 +61,26 @@ namespace Xamarin.Forms.Platform.Tizen
}
return base.OnCellPropertyChanged(cell, property, realizedView);
}
+
+ EvasObject CreateReusableContent(ViewCell viewCell)
+ {
+ var listView = viewCell.RealParent as ListView;
+ ViewCell duplicatedCell = (ViewCell)listView.ItemTemplate.CreateContent();
+ duplicatedCell.BindingContext = viewCell.BindingContext;
+ duplicatedCell.Parent = listView;
+
+ var renderer = Platform.GetOrCreateRenderer(duplicatedCell.View);
+ int height = (int)duplicatedCell.RenderHeight;
+ height = height > 0 ? height : FindCellContentHeight(duplicatedCell);
+ renderer.NativeView.MinimumHeight = height;
+
+ _cacheCandidate[renderer.NativeView] = duplicatedCell;
+ renderer.NativeView.Deleted += (sender, e) =>
+ {
+ _cacheCandidate.Remove((EvasObject)sender);
+ };
+
+ return renderer.NativeView;
+ }
}
}