summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Cells/CellFactory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Cells/CellFactory.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Cells/CellFactory.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Cells/CellFactory.cs b/Xamarin.Forms.Platform.Android/Cells/CellFactory.cs
new file mode 100644
index 00000000..589236c3
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/Cells/CellFactory.cs
@@ -0,0 +1,41 @@
+using Android.Content;
+using Android.Views;
+using AView = Android.Views.View;
+using AListView = Android.Widget.ListView;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ public static class CellFactory
+ {
+ public static AView GetCell(Cell item, AView convertView, ViewGroup parent, Context context, View view)
+ {
+ CellRenderer renderer = CellRenderer.GetRenderer(item);
+ if (renderer == null)
+ {
+ renderer = Registrar.Registered.GetHandler<CellRenderer>(item.GetType());
+ renderer.ParentView = view;
+ }
+
+ AView result = renderer.GetCell(item, convertView, parent, context);
+
+ if (view is TableView)
+ UpdateMinimumHeightFromParent(context, result, (TableView)view);
+ else if (view is ListView)
+ UpdateMinimumHeightFromParent(context, result, (ListView)view);
+
+ return result;
+ }
+
+ static void UpdateMinimumHeightFromParent(Context context, AView view, TableView table)
+ {
+ if (!table.HasUnevenRows && table.RowHeight > 0)
+ view.SetMinimumHeight((int)context.ToPixels(table.RowHeight));
+ }
+
+ static void UpdateMinimumHeightFromParent(Context context, AView view, ListView listView)
+ {
+ if (!listView.HasUnevenRows && listView.RowHeight > 0)
+ view.SetMinimumHeight((int)context.ToPixels(listView.RowHeight));
+ }
+ }
+} \ No newline at end of file