summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-08-02 14:48:25 -0700
committerRui Marinho <me@ruimarinho.net>2016-08-02 22:48:25 +0100
commitd5ad18b3e9947157ab073eb0e5c0a30e7f039c62 (patch)
tree39534e2b17e7100285fa0cba43fcd6c8057d710b
parentfd838d3d800ce9eca3f70f2d89d0bf10a59d9f5e (diff)
downloadxamarin-forms-d5ad18b3e9947157ab073eb0e5c0a30e7f039c62.tar.gz
xamarin-forms-d5ad18b3e9947157ab073eb0e5c0a30e7f039c62.tar.bz2
xamarin-forms-d5ad18b3e9947157ab073eb0e5c0a30e7f039c62.zip
[A, iOS] ListView Pull-To-Refresh indicator animates when navigating back to it (#274)
* Add repro for 33561 * [A] ListView refreshing on created shows indicator * [iOS] Refresh indicator restarts when appeared * Remove superfluous get
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33561.cs57
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs18
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs19
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs2
5 files changed, 91 insertions, 6 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33561.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33561.cs
new file mode 100644
index 00000000..ec55d370
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33561.cs
@@ -0,0 +1,57 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 33561, "ListView Pull-to-Refresh ActivityIndicator animation stuck when navigating away and then back again")]
+ public class Bugzilla33561 : TestTabbedPage
+ {
+ public class ListPage : ContentPage
+ {
+ ListView _listView;
+ bool _isRefreshing;
+
+ public ListPage()
+ {
+ var template = new DataTemplate(typeof(TextCell));
+ template.SetBinding(TextCell.TextProperty, ".");
+
+ _listView = new ListView()
+ {
+ IsPullToRefreshEnabled = true,
+ ItemsSource = Enumerable.Range(0, 10).Select(no => $"FAIL {no}"),
+ ItemTemplate = template,
+ IsRefreshing = true
+ };
+
+ _listView.Refreshing += async (object sender, EventArgs e) =>
+ {
+ if (_isRefreshing)
+ return;
+
+ _isRefreshing = true;
+ await Task.Delay(10000);
+ _listView.EndRefresh();
+ _listView.ItemsSource = Enumerable.Range(0, 10).Select(no => $"SUCCESS {no}");
+ _isRefreshing = false;
+ };
+
+ Content = _listView;
+
+ Device.StartTimer(TimeSpan.FromSeconds(5), () => { _listView.IsRefreshing = false; return false; });
+ }
+ }
+
+ protected override void Init()
+ {
+ Children.Add(new NavigationPage(new ListPage()) { Title = "page 1" });
+ Children.Add(new ContentPage() { Title = "page 2" });
+ Children.Add(new ContentPage() { Title = "page 3" });
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 1e3e9f34..67bfb32f 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -169,6 +169,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41842.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42277.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImageLoadingErrorHandling.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla33561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1075.cs" />
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
index 41758101..973cb86f 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
@@ -141,7 +141,7 @@ namespace Xamarin.Forms.Platform.Android
UpdateHeader();
UpdateFooter();
UpdateIsSwipeToRefreshEnabled();
- UpdateIsRefreshing();
+ UpdateIsRefreshing(isInitialValue: true);
}
}
@@ -296,10 +296,22 @@ namespace Xamarin.Forms.Platform.Android
Platform.SetRenderer(header, _headerRenderer);
}
- void UpdateIsRefreshing()
+ void UpdateIsRefreshing(bool isInitialValue = false)
{
if (_refresh != null)
- _refresh.Refreshing = Element.IsRefreshing;
+ {
+ var isRefreshing = Element.IsRefreshing;
+ if (isRefreshing && isInitialValue)
+ {
+ _refresh.Refreshing = false;
+ _refresh.Post(() =>
+ {
+ _refresh.Refreshing = true;
+ });
+ }
+ else
+ _refresh.Refreshing = isRefreshing;
+ }
}
void UpdateIsSwipeToRefreshEnabled()
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
index 5483a169..7cd691f9 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
@@ -41,6 +41,7 @@ namespace Xamarin.Forms.Platform.iOS
FormsUITableViewController _tableViewController;
IListViewController Controller => Element;
ITemplatedItemsView<Cell> TemplatedItemsView => Element;
+ public override UIViewController ViewController => _tableViewController;
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
@@ -927,7 +928,7 @@ namespace Xamarin.Forms.Platform.iOS
ITemplatedItemsList<Cell> GetSectionList(int section)
{
- return (ITemplatedItemsList<Cell>)((IList)TemplatedItemsView.TemplatedItems) [section];
+ return (ITemplatedItemsList<Cell>)((IList)TemplatedItemsView.TemplatedItems)[section];
}
void OnSectionPropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -1015,6 +1016,7 @@ namespace Xamarin.Forms.Platform.iOS
readonly ListView _list;
IListViewController Controller => _list;
UIRefreshControl _refresh;
+ bool _refreshingEventSent;
bool _refreshAdded;
@@ -1089,6 +1091,14 @@ namespace Xamarin.Forms.Platform.iOS
public override void ViewWillAppear(bool animated)
{
+ base.ViewWillAppear(animated);
+
+ if (_list.IsRefreshing && _refresh.Refreshing)
+ {
+ // Restart the refreshing to get the animation to trigger
+ UpdateIsRefreshing(false);
+ UpdateIsRefreshing(true);
+ }
}
protected override void Dispose(bool disposing)
@@ -1114,8 +1124,13 @@ namespace Xamarin.Forms.Platform.iOS
void OnRefreshingChanged(object sender, EventArgs eventArgs)
{
- if (_refresh.Refreshing)
+ if (_refresh.Refreshing && !_refreshingEventSent)
+ {
Controller.SendRefreshing();
+ _refreshingEventSent = true;
+ }
+ else if (!_refresh.Refreshing)
+ _refreshingEventSent = false;
}
void RemoveRefresh()
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
index 68ae10bb..ab212b21 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
@@ -121,7 +121,7 @@ namespace Xamarin.Forms.Platform.iOS
Layout.LayoutChildIntoBoundingRegion(Element, new Rectangle(Element.X, Element.Y, size.Width, size.Height));
}
- public UIViewController ViewController
+ public virtual UIViewController ViewController
{
get { return null; }
}