--- /dev/null
+using System.Collections.Generic;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 44980, "ActivityIndicator disappears when scrolling", PlatformAffected.iOS)]
+ public class Bugzilla44980 : TestContentPage
+ {
+ protected override void Init()
+ {
+ var list = new List<string>();
+ for (var i = 0; i < 100; i++)
+ list.Add(i.ToString());
+
+ Content = new CListView
+ {
+ ItemsSource = list,
+ ItemTemplate = new DataTemplate(() =>
+ {
+ var activityIndicator = new ActivityIndicator
+ {
+ IsRunning = true,
+ IsVisible = true
+ };
+ return new ViewCell { View = activityIndicator };
+ })
+ };
+ }
+ }
+
+ public class CListView : ListView
+ {
+ public CListView() : base(ListViewCachingStrategy.RecycleElement)
+ {
+ }
+ }
+}
\ No newline at end of file
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
- UITableViewCell nativeCell = null;
+ Cell cell;
+ UITableViewCell nativeCell;
var cachingStrategy = Controller.CachingStrategy;
if (cachingStrategy == ListViewCachingStrategy.RetainElement)
{
- var cell = GetCellForPath(indexPath);
+ cell = GetCellForPath(indexPath);
nativeCell = CellTableViewCell.GetNativeCell(tableView, cell);
}
else if (cachingStrategy == ListViewCachingStrategy.RecycleElement)
nativeCell = tableView.DequeueReusableCell(ContextActionsCell.Key + id);
if (nativeCell == null)
{
- var cell = GetCellForPath(indexPath);
+ cell = GetCellForPath(indexPath);
nativeCell = CellTableViewCell.GetNativeCell(tableView, cell, true, id.ToString());
}
else
{
var templatedList = TemplatedItemsView.TemplatedItems.GetGroup(indexPath.Section);
- var cell = (Cell)((INativeElementView)nativeCell).Element;
+ cell = (Cell)((INativeElementView)nativeCell).Element;
ICellController controller = cell;
controller.SendDisappearing();
templatedList.UpdateContent(cell, indexPath.Row);
var bgColor = tableView.IndexPathForSelectedRow != null && tableView.IndexPathForSelectedRow.Equals(indexPath) ? UIColor.Clear : DefaultBackgroundColor;
SetCellBackgroundColor(nativeCell, bgColor);
-
+ PreserveActivityIndicatorState(cell);
return nativeCell;
}
-
+
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
{
if (List.IsGroupingEnabled)
base.Dispose(disposing);
}
+
+ void PreserveActivityIndicatorState(Element element)
+ {
+ if (element == null)
+ return;
+
+ var activityIndicator = element as ActivityIndicator;
+ if (activityIndicator != null)
+ {
+ var renderer = Platform.GetRenderer(activityIndicator) as ActivityIndicatorRenderer;
+ renderer?.PreserveState();
+ }
+ else
+ {
+ foreach (Element childElement in (element as IElementController).LogicalChildren)
+ PreserveActivityIndicatorState(childElement);
+ }
+ }
}
}