summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungkeun Lee <sngn.lee@samsung.com>2016-11-29 07:44:19 +0900
committerGerrit Code Review <gerrit@s001>2016-11-29 07:44:19 +0900
commitc0d4d3afe313964343df9c476ddc9b7e2452084e (patch)
treeca601051c3009781e4393660bee190e34ab62883
parent82c4d45b5478dcae70b51e2f73160204aad50f0f (diff)
parentdc7ae96095325efc158b0e7ac8f86c3c381efaf6 (diff)
downloadxamarin-forms-c0d4d3afe313964343df9c476ddc9b7e2452084e.tar.gz
xamarin-forms-c0d4d3afe313964343df9c476ddc9b7e2452084e.tar.bz2
xamarin-forms-c0d4d3afe313964343df9c476ddc9b7e2452084e.zip
Merge "Revert "[ListView] Add IsPullToRefresh functionality:"" into devel/dotnet
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs98
-rw-r--r--samples/Demo/IndexPage.cs57
2 files changed, 7 insertions, 148 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
index 15a550d8..5179d7e0 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
@@ -37,11 +37,9 @@ namespace Xamarin.Forms.Platform.Tizen
/// needs information only when an item has been taped, native handlers need to be agreagated
/// and NotifyRowTapped has to be realized with this.
/// </summary>
+
GenListItem _lastSelectedItem = null;
int _selectedItemChanging = 0;
- bool _isPullToRefreshEnabled = false;
- bool _isPullToRefreshGestureStarted = false;
- EProgressBar _activityIndicator = null;
/// <summary>
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.ListViewRenderer"/> class.
@@ -63,8 +61,6 @@ namespace Xamarin.Forms.Platform.Tizen
RegisterPropertyHandler(ListView.ItemsSourceProperty, UpdateSource);
RegisterPropertyHandler(ListView.FooterTemplateProperty, UpdateFooter);
RegisterPropertyHandler(ListView.HeaderTemplateProperty, UpdateHeader);
- RegisterPropertyHandler(ListView.IsPullToRefreshEnabledProperty, UpdateIsPullToRefreshEnabled);
- RegisterPropertyHandler(ListView.IsRefreshingProperty, UpdateRefreshingEnabled);
}
/// <summary>
@@ -77,12 +73,6 @@ namespace Xamarin.Forms.Platform.Tizen
if (Control == null)
{
SetNativeControl(new Native.ListView(Forms.Context.MainWindow));
- _activityIndicator = new EProgressBar(Forms.Context.MainWindow)
- {
- Style = "process_medium",
- };
- _activityIndicator.Hide();
- _activityIndicator.StopPluse();
}
if (e.OldElement != null)
@@ -95,9 +85,6 @@ namespace Xamarin.Forms.Platform.Tizen
e.OldElement.TemplatedItems.CollectionChanged -= _collectionChanged;
Control.ItemSelected -= ListViewItemSelectedHandler;
Control.ItemUnselected -= ListViewItemUnselectedHandler;
- Control.ScrollAnimationStarted -= ScrollAnimationStartedHandler;
- Control.ScrollAnimationStopped -= ScrollAnimationStoppedHandler;
- Control.Changed -= ListViewChangedHandler;
}
if (e.NewElement != null)
@@ -106,9 +93,6 @@ namespace Xamarin.Forms.Platform.Tizen
Element.TemplatedItems.CollectionChanged += _collectionChanged;
Control.ItemSelected += ListViewItemSelectedHandler;
Control.ItemUnselected += ListViewItemUnselectedHandler;
- Control.ScrollAnimationStarted += ScrollAnimationStartedHandler;
- Control.ScrollAnimationStopped += ScrollAnimationStoppedHandler;
- Control.Changed += ListViewChangedHandler;
}
base.OnElementChanged(e);
@@ -125,8 +109,6 @@ namespace Xamarin.Forms.Platform.Tizen
Element.ScrollToRequested -= _scrollToRequested;
Element.TemplatedItems.CollectionChanged -= _collectionChanged;
Element.TemplatedItems.GroupedCollectionChanged -= _groupedCollectionChanged;
- _activityIndicator.Unrealize();
- _activityIndicator = null;
base.Dispose(disposing);
}
@@ -451,83 +433,5 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
}
-
- void UpdateIsPullToRefreshEnabled()
- {
- _isPullToRefreshEnabled = Element.IsPullToRefreshEnabled && (Element as IListViewController).RefreshAllowed;
- }
-
- void UpdateRefreshingEnabled()
- {
- if (_isPullToRefreshEnabled == false)
- return;
- if (EcoreMainloop.IsMainThread == false)
- {
- //throw exception if UI changed outside main thread
- Log.Error("Changed UI outside UI-thread! Use eg. BeginInvokeOnMainThread for running on UI-thread");
- throw new Exception("Changed UI outside UI-thread! Use eg. BeginInvokeOnMainThread for running on UI-thread");
- }
- if (Element.IsRefreshing == true)
- {
- ERect listGeometry = Control.Geometry;
- _activityIndicator.Geometry = new ERect(listGeometry.X + listGeometry.Width / 2 - _activityIndicator.MinimumWidth / 2,
- listGeometry.Y + listGeometry.Height / 6 - _activityIndicator.MinimumHeight / 2,
- _activityIndicator.MinimumWidth,
- _activityIndicator.MinimumHeight);
- _activityIndicator.IsPulseMode = true;
- _activityIndicator.PlayPulse();
- _activityIndicator.Show();
- }
- else
- {
- _activityIndicator.StopPluse();
- _activityIndicator.IsPulseMode = false;
- _activityIndicator.Hide();
- }
- }
-
- void ScrollAnimationStartedHandler(object sender, EventArgs ee)
- {
- //when IsPullToRefresh activated - start scroll analysis
- if (_isPullToRefreshEnabled == true && Element.IsRefreshing == false)
- {
- _isPullToRefreshGestureStarted = true;
- }
- }
-
- void ScrollAnimationStoppedHandler(object sender, EventArgs ee)
- {
- //when IsPullToRefresh activated and the list stacks on top element
- if (_isPullToRefreshEnabled == true && _isPullToRefreshGestureStarted == true)
- {
- _isPullToRefreshGestureStarted = false;
- //Detected pull-to-refresh gesture. Activates the user
- //commands and starts the TIZEN-specific refresh animation.
- SendRefreshingHandler();
- }
- }
-
- void ListViewChangedHandler(object sender, EventArgs ee)
- {
- //This is not a pull-to-refresh gesture
- //if a list is already being scrolled in any direction.
- //Pull-to-refresh gesture is done at the top of list and it
- //is not possible to move it up that is why this callback
- //should not occur during pull-to-refresh gesture.
- if (_isPullToRefreshEnabled == true && _isPullToRefreshGestureStarted == true)
- {
- _isPullToRefreshGestureStarted = false;
- }
- }
-
- void SendRefreshingHandler()
- {
- //starts is pull to refresh
- IListViewController lvc = Element as IListViewController;
- if (lvc != null)
- {
- lvc.SendRefreshing();
- }
- }
}
}
diff --git a/samples/Demo/IndexPage.cs b/samples/Demo/IndexPage.cs
index 5dbbaf9a..fba02521 100644
--- a/samples/Demo/IndexPage.cs
+++ b/samples/Demo/IndexPage.cs
@@ -100,7 +100,7 @@ namespace Demo
Title = "Xamarin Demo";
// for some reason, the ListView does not work on PC
- if (System.IO.File.Exists("/etc/tizen-release"))
+ if (System.IO.File.Exists ("/etc/tizen-release"))
Content = CreateListView();
else
Content = CreateButtons();
@@ -121,17 +121,11 @@ namespace Demo
// the bindingContext will be one of the DemoPages element
}
);
- ListView listView = new ListView()
- {
- ItemsSource = DemoPages,
- ItemTemplate = template,
- };
- listView.IsPullToRefreshEnabled = true;
- listView.RefreshCommand = new UserCommand(listView);
- listView.Refreshing += (object sender, EventArgs e) => {
- Console.WriteLine("Refreshing EventHandler called!");
- };
- return listView;
+ return new ListView
+ {
+ ItemsSource = DemoPages,
+ ItemTemplate = template,
+ };
}
private View CreateButtons()
@@ -177,43 +171,4 @@ namespace Demo
};
}
}
-
- public class UserCommand : System.Windows.Input.ICommand
- {
- ListView _listView;
-
- public UserCommand(ListView list)
- {
- _listView = list;
- }
-
- public void Execute(object parameter)
- {
- Console.WriteLine("ICommand provided by the user");
- System.Timers.Timer aTimer = new System.Timers.Timer();
- aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
- aTimer.Interval = 1000;
- aTimer.Enabled = true;
- }
-
- public bool CanExecute(object parameter)
- {
- return true;
- }
-
- public event EventHandler CanExecuteChanged;
-
- // Specify what you want to happen when the Elapsed event is raised.
- private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
- {
- Console.WriteLine("End Of Task (EOT)");
- (source as System.Timers.Timer).Stop();
- //Important to stop animation - as described on documentation
- Action action = () =>
- {
- _listView.EndRefresh();
- };
- Xamarin.Forms.Device.BeginInvokeOnMainThread(action);
- }
- }
}