summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungkeun Lee <sngn.lee@samsung.com>2017-06-29 04:07:21 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 04:34:37 (GMT)
commite26fd78c87c92e68abc6ca842290c4d11002a7b6 (patch)
tree5fd59f5215af35a3e4ff1dbef01c608cbdc34584
parent95b7bd0521c2c0a01f2efe77a18a7782db9bd008 (diff)
downloadxamarin-forms-e26fd78c87c92e68abc6ca842290c4d11002a7b6.zip
xamarin-forms-e26fd78c87c92e68abc6ca842290c4d11002a7b6.tar.gz
xamarin-forms-e26fd78c87c92e68abc6ca842290c4d11002a7b6.tar.bz2
Refactoring Renderers
- Apply Dispose pattern - Handle IBatchable interface on VisualElementRenderer - Make pair Event subscribe/unsubscribe Change-Id: I65018652132494722d52b1d62798f1cf1f6fc6fd
-rw-r--r--Xamarin.Forms.Platform.Tizen/FormsApplication.cs9
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs14
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs53
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/CarouselPageRenderer.cs21
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs15
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs37
-rw-r--r--[-rwxr-xr-x]Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs37
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs35
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs20
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs18
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs17
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs68
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs9
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs56
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/PickerRenderer.cs39
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs9
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs26
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs45
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs27
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs28
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs27
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs26
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs22
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs38
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs44
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/WebViewRenderer.cs15
29 files changed, 354 insertions, 421 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
index 1ea64b6..b9bbe0e 100644
--- a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
+++ b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
@@ -13,6 +13,7 @@ using System.IO;
namespace Xamarin.Forms.Platform.Tizen
{
+
public class FormsApplication : CoreUIApplication
{
Platform _platform;
@@ -102,11 +103,9 @@ namespace Xamarin.Forms.Platform.Tizen
{
throw new NullReferenceException("MainWindow is not prepared. This method should be called in OnCreated().");
}
- if (null == application)
- {
- throw new ArgumentNullException("application");
- }
- _application = application;
+
+ _application = application ?? throw new ArgumentNullException("application");
+
Application.Current = application;
application.SendStart();
application.PropertyChanged += new PropertyChangedEventHandler(this.AppOnPropertyChanged);
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
index 25e891c..fdad3c7 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
@@ -17,22 +17,12 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var ac = new EProgressBar(Forms.Context.MainWindow)
+ SetNativeControl(new EProgressBar(Forms.Context.MainWindow)
{
Style = "process_medium",
IsPulseMode = true,
- };
- SetNativeControl(ac);
+ });
}
-
- if (e.OldElement != null)
- {
- }
-
- if (e.NewElement != null)
- {
- }
-
base.OnElementChanged(e);
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
index ff23d67..cc29f27 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/BoxViewRenderer.cs
@@ -10,14 +10,10 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var rectangle = new ERectangle(Forms.Context.MainWindow);
- SetNativeControl(rectangle);
+ SetNativeControl(new ERectangle(Forms.Context.MainWindow));
}
- if (e.NewElement != null)
- {
- UpdateColor();
- }
+ UpdateColor();
base.OnElementChanged(e);
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
index 483fceb..0125cfe 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
@@ -23,23 +23,11 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var button = new Native.Button(Forms.Context.MainWindow)
+ SetNativeControl(new Native.Button(Forms.Context.MainWindow)
{
PropagateEvents = false,
- };
- SetNativeControl(button);
- }
-
- if (e.OldElement != null)
- {
- Control.Clicked -= ButtonClickedHandler;
- }
-
- if (e.NewElement != null)
- {
- Control.Clicked += ButtonClickedHandler;
-
- Control.BatchBegin();
+ });
+ Control.Clicked += OnButtonClicked;
}
base.OnElementChanged(e);
}
@@ -49,18 +37,31 @@ namespace Xamarin.Forms.Platform.Tizen
return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
- protected override void OnElementReady()
+ protected override void UpdateThemeStyle()
{
- Control?.BatchCommit();
+ var style = Specific.GetStyle(Element);
+ if (!string.IsNullOrEmpty(style))
+ {
+ Control.UpdateStyle(style);
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
}
- void ButtonClickedHandler(object sender, EventArgs e)
+ protected override void Dispose(bool disposing)
{
- IButtonController btn = Element as IButtonController;
- if (btn != null)
+ if (disposing)
{
- btn.SendClicked();
+ if (Control != null)
+ {
+ Control.Clicked -= OnButtonClicked;
+ }
}
+ base.Dispose(disposing);
+ }
+
+ void OnButtonClicked(object sender, EventArgs e)
+ {
+ (Element as IButtonController)?.SendClicked();
}
void UpdateText()
@@ -101,16 +102,6 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
- protected override void UpdateThemeStyle()
- {
- var style = Specific.GetStyle(Element);
- if (!string.IsNullOrEmpty(style))
- {
- Control.UpdateStyle(style);
- ((IVisualElementController)Element).NativeSizeChanged();
- }
- }
-
void UpdateBorder()
{
/* The simpler way is to create some specialized theme for button in
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/CarouselPageRenderer.cs
index c89fae0..469d1a9 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/CarouselPageRenderer.cs
@@ -87,7 +87,7 @@ namespace Xamarin.Forms.Platform.Tizen
if (e.OldElement != null)
{
- Element.CurrentPageChanged -= OnCurrentPageChanged;
+ e.OldElement.CurrentPageChanged -= OnCurrentPageChanged;
}
if (e.NewElement != null)
@@ -111,15 +111,20 @@ namespace Xamarin.Forms.Platform.Tizen
/// <param name="disposing">True if the memory release was requested on demand.</param>
protected override void Dispose(bool disposing)
{
- if (_box != null)
+ if (disposing)
{
- Element.CurrentPageChanged -= OnCurrentPageChanged;
-
- // Unpacks the page from the box to prevent it from being disposed of prematurely:
- _box.UnPack(_page);
+ if (Element != null)
+ {
+ Element.CurrentPageChanged -= OnCurrentPageChanged;
+ }
+ if (_box != null)
+ {
+ // Unpacks the page from the box to prevent it from being disposed of prematurely:
+ _box.UnPack(_page);
- _box.Unrealize();
- _box = null;
+ _box.Unrealize();
+ _box = null;
+ }
}
base.Dispose(disposing);
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs
index 974cf38..714f41b 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs
@@ -27,13 +27,24 @@ namespace Xamarin.Forms.Platform.Tizen
if (null == _page)
{
_page = new Native.ContentPage(Forms.Context.MainWindow);
- _page.LayoutUpdated += new EventHandler<Native.LayoutEventArgs>(OnLayoutUpdated);
+ _page.LayoutUpdated += OnLayoutUpdated;
SetNativeControl(_page);
}
-
base.OnElementChanged(e);
}
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (_page != null)
+ {
+ _page.LayoutUpdated -= OnLayoutUpdated;
+ }
+ }
+ base.Dispose(disposing);
+ }
+
protected override void UpdateBackgroundColor(bool initialize)
{
if (initialize && Element.BackgroundColor.IsDefault)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
index 2fa86a5..39a2529 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
@@ -25,19 +25,10 @@ namespace Xamarin.Forms.Platform.Tizen
};
entry.SetVerticalTextAlignment("elm.text", 0.5);
entry.AllowFocus(false);
+ entry.Clicked += OnEntryClicked;
SetNativeControl(entry);
}
- if (e.OldElement != null)
- {
- Control.Clicked -= ClickedHandler;
- }
-
- if (e.NewElement != null)
- {
- Control.Clicked += ClickedHandler;
- }
-
base.OnElementChanged(e);
}
@@ -46,7 +37,19 @@ namespace Xamarin.Forms.Platform.Tizen
return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
- void ClickedHandler(object sender, EventArgs e)
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (Control != null)
+ {
+ Control.Clicked -= OnEntryClicked;
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ void OnEntryClicked(object sender, EventArgs e)
{
Native.DateTimePickerDialog dialog = new Native.DateTimePickerDialog(Forms.Context.MainWindow)
{
@@ -54,22 +57,22 @@ namespace Xamarin.Forms.Platform.Tizen
};
dialog.InitializeDatePicker(Element.Date, Element.MinimumDate, Element.MaximumDate);
- dialog.DateTimeChanged += DialogDateTimeChangedHandler;
- dialog.Dismissed += DialogDismissedHandler;
+ dialog.DateTimeChanged += OnDateTimeChanged;
+ dialog.Dismissed += OnDialogDismissed;
dialog.Show();
}
- void DialogDateTimeChangedHandler(object sender, Native.DateChangedEventArgs dcea)
+ void OnDateTimeChanged(object sender, Native.DateChangedEventArgs dcea)
{
Element.Date = dcea.NewDate;
Control.Text = dcea.NewDate.ToString(Element.Format);
}
- void DialogDismissedHandler(object sender, EventArgs e)
+ void OnDialogDismissed(object sender, EventArgs e)
{
var dialog = sender as Native.DateTimePickerDialog;
- dialog.DateTimeChanged -= DialogDateTimeChangedHandler;
- dialog.Dismissed -= DialogDismissedHandler;
+ dialog.DateTimeChanged -= OnDateTimeChanged;
+ dialog.Dismissed -= OnDialogDismissed;
}
void UpdateDate()
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
index 7209eae..d5ca750 100755..100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
@@ -25,47 +25,32 @@ namespace Xamarin.Forms.Platform.Tizen
IsSingleLine = false,
PropagateEvents = false,
};
- SetNativeControl(entry);
- }
-
- if (e.OldElement != null)
- {
- Control.TextChanged -= TextChanged;
- Control.Unfocused -= Completed;
- }
-
- if (e.NewElement != null)
- {
- Control.TextChanged += TextChanged;
- Control.Unfocused += Completed;
+ entry.TextChanged += OnTextChanged;
+ entry.Unfocused += OnCompleted;
- Control.BatchBegin();
+ SetNativeControl(entry);
}
-
base.OnElementChanged(e);
}
protected override void Dispose(bool disposing)
{
- if (null != Control)
+ if (disposing)
{
- Control.TextChanged -= TextChanged;
- Control.Activated -= Completed;
+ if (null != Control)
+ {
+ Control.TextChanged -= OnTextChanged;
+ Control.Activated -= OnCompleted;
+ }
}
-
base.Dispose(disposing);
}
- protected override void OnElementReady()
- {
- Control?.BatchCommit();
- }
-
- void TextChanged(object sender, EventArgs e)
+ void OnTextChanged(object sender, EventArgs e)
{
Element.Text = ((Native.Entry)sender).Text;
}
- void Completed(object sender, EventArgs e)
+ void OnCompleted(object sender, EventArgs e)
{
Element.SendCompleted();
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
index e54e739..23ffca5 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
@@ -35,48 +35,33 @@ namespace Xamarin.Forms.Platform.Tizen
};
entry.SetVerticalTextAlignment("elm.text", 0.5);
entry.SetVerticalTextAlignment("elm.guide", 0.5);
+ entry.TextChanged += OnTextChanged;
+ entry.Activated += OnCompleted;
SetNativeControl(entry);
}
-
- if (e.OldElement != null)
- {
- Control.TextChanged -= EntryChangedHandler;
- Control.Activated -= EntryCompletedHandler;
- }
-
- if (e.NewElement != null)
- {
- Control.TextChanged += EntryChangedHandler;
- Control.Activated += EntryCompletedHandler;
-
- Control.BatchBegin();
- }
-
base.OnElementChanged(e);
}
protected override void Dispose(bool disposing)
{
- if (null != Control)
+ if (disposing)
{
- Control.TextChanged -= EntryChangedHandler;
- Control.Activated -= EntryCompletedHandler;
+ if (null != Control)
+ {
+ Control.TextChanged -= OnTextChanged;
+ Control.Activated -= OnCompleted;
+ }
}
base.Dispose(disposing);
}
- protected override void OnElementReady()
- {
- Control?.BatchCommit();
- }
-
- void EntryChangedHandler(object sender, EventArgs e)
+ void OnTextChanged(object sender, EventArgs e)
{
Element.Text = Control.Text;
}
- void EntryCompletedHandler(object sender, EventArgs e)
+ void OnCompleted(object sender, EventArgs e)
{
//TODO Consider if any other object should overtake focus
Control.SetFocus(false);
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs
index 4e11c27..e6e56cd 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/EvasObjectWrapperRenderer.cs
@@ -6,11 +6,7 @@ namespace Xamarin.Forms.Platform.Tizen
{
protected override void OnElementChanged(ElementChangedEventArgs<EvasObjectWrapper> e)
{
- if (NativeView == null)
- {
- SetNativeControl(Element.EvasObject);
- }
-
+ SetNativeControl(Element.EvasObject);
base.OnElementChanged(e);
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs
index 0c81577..47bc703 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs
@@ -34,19 +34,21 @@ namespace Xamarin.Forms.Platform.Tizen
_frame = new Polygon(NativeView);
_frame.Show();
Control.Children.Add(_frame);
+ Control.LayoutUpdated += OnLayoutUpdated;
}
+ base.OnElementChanged(e);
+ }
- if (e.OldElement != null)
- {
- Control.LayoutUpdated -= OnLayoutUpdated;
- }
-
- if (e.NewElement != null)
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- Control.LayoutUpdated += OnLayoutUpdated;
+ if (Control != null)
+ {
+ Control.LayoutUpdated -= OnLayoutUpdated;
+ }
}
-
- base.OnElementChanged(e);
+ base.Dispose(disposing);
}
static void DrawFrame(Polygon frame, int left, int top, int right, int bottom, int thickness)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
index ac4d82c..882c423 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
@@ -16,11 +16,7 @@ namespace Xamarin.Forms.Platform.Tizen
SetNativeControl(image);
}
- if (e.NewElement != null)
- {
- UpdateAll();
- }
-
+ UpdateAll();
base.OnElementChanged(e);
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
index 08547c9..42e8a15 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
@@ -28,19 +28,8 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var label = new Native.Label(Forms.Context.MainWindow);
- base.SetNativeControl(label);
+ base.SetNativeControl(new Native.Label(Forms.Context.MainWindow));
}
-
- if (e.OldElement != null)
- {
- }
-
- if (e.NewElement != null)
- {
- Control.BatchBegin();
- }
-
base.OnElementChanged(e);
}
@@ -49,11 +38,6 @@ namespace Xamarin.Forms.Platform.Tizen
return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
- protected override void OnElementReady()
- {
- Control?.BatchCommit();
- }
-
Native.FormattedString ConvertFormattedText(FormattedString formattedString)
{
if (formattedString == null)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs
index c2df806..226afbb 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs
@@ -7,14 +7,14 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
public class LayoutRenderer : ViewRenderer<Layout, Native.Canvas>
{
- bool _isLayoutUpdatedRegistered = false;
+ bool _layoutUpdatedRegistered = false;
public void RegisterOnLayoutUpdated()
{
- if (!_isLayoutUpdatedRegistered)
+ if (!_layoutUpdatedRegistered)
{
Control.LayoutUpdated += OnLayoutUpdated;
- _isLayoutUpdatedRegistered = true;
+ _layoutUpdatedRegistered = true;
}
}
@@ -22,8 +22,7 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (null == Control)
{
- var canvas = new Native.Canvas(Forms.Context.MainWindow);
- SetNativeControl(canvas);
+ SetNativeControl(new Native.Canvas(Forms.Context.MainWindow));
}
base.OnElementChanged(e);
@@ -31,9 +30,13 @@ namespace Xamarin.Forms.Platform.Tizen
protected override void Dispose(bool disposing)
{
- if (_isLayoutUpdatedRegistered)
+ if (disposing)
{
- Control.LayoutUpdated -= OnLayoutUpdated;
+ if (_layoutUpdatedRegistered)
+ {
+ Control.LayoutUpdated -= OnLayoutUpdated;
+ _layoutUpdatedRegistered = false;
+ }
}
base.Dispose(disposing);
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
index a602ae0..1141afb 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
@@ -22,21 +22,6 @@ namespace Xamarin.Forms.Platform.Tizen
ITemplatedItemsView<Cell> TemplatedItemsView => Element;
/// <summary>
- /// Event handler for ScrollToRequested.
- /// </summary>
- readonly EventHandler<ScrollToRequestedEventArgs> _scrollToRequested;
-
- /// <summary>
- /// Event handler for collection changed.
- /// </summary>
- readonly NotifyCollectionChangedEventHandler _collectionChanged;
-
- /// <summary>
- /// Event handler for grouped collection changed.
- /// </summary>
- readonly NotifyCollectionChangedEventHandler _groupedCollectionChanged;
-
- /// <summary>
/// The _lastSelectedItem and _selectedItemChanging are used for realizing ItemTapped event. Since Xamarin
/// needs information only when an item has been taped, native handlers need to be agreagated
/// and NotifyRowTapped has to be realized with this.
@@ -52,10 +37,6 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
public ListViewRenderer()
{
- _scrollToRequested = OnScrollToRequested;
- _collectionChanged = OnCollectionChanged;
- _groupedCollectionChanged = OnGroupedCollectionChanged;
-
RegisterPropertyHandler(ListView.IsGroupingEnabledProperty, UpdateIsGroupingEnabled);
RegisterPropertyHandler(ListView.HasUnevenRowsProperty, UpdateHasUnevenRows);
RegisterPropertyHandler(ListView.RowHeightProperty, UpdateRowHeight);
@@ -75,26 +56,22 @@ namespace Xamarin.Forms.Platform.Tizen
if (Control == null)
{
SetNativeControl(new Native.ListView(Forms.Context.MainWindow));
+ Control.ItemSelected += OnListViewItemSelected;
+ Control.ItemUnselected += OnListViewItemUnselected;
}
if (e.OldElement != null)
{
- e.OldElement.ScrollToRequested -= _scrollToRequested;
- if (Element.IsGroupingEnabled)
- {
- e.OldElement.TemplatedItems.GroupedCollectionChanged -= _groupedCollectionChanged;
- }
- e.OldElement.TemplatedItems.CollectionChanged -= _collectionChanged;
- Control.ItemSelected -= ListViewItemSelectedHandler;
- Control.ItemUnselected -= ListViewItemUnselectedHandler;
+ e.OldElement.ScrollToRequested -= OnScrollToRequested;
+ e.OldElement.TemplatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged;
+ e.OldElement.TemplatedItems.CollectionChanged -= OnCollectionChanged;
}
if (e.NewElement != null)
{
- e.NewElement.ScrollToRequested += _scrollToRequested;
- Element.TemplatedItems.CollectionChanged += _collectionChanged;
- Control.ItemSelected += ListViewItemSelectedHandler;
- Control.ItemUnselected += ListViewItemUnselectedHandler;
+ Element.ScrollToRequested += OnScrollToRequested;
+ Element.TemplatedItems.GroupedCollectionChanged += OnGroupedCollectionChanged;
+ Element.TemplatedItems.CollectionChanged += OnCollectionChanged;
}
base.OnElementChanged(e);
@@ -108,10 +85,21 @@ namespace Xamarin.Forms.Platform.Tizen
/// <c>True</c> if the memory release was requested on demand.</param>
protected override void Dispose(bool disposing)
{
- Element.ScrollToRequested -= _scrollToRequested;
- Element.TemplatedItems.CollectionChanged -= _collectionChanged;
- Element.TemplatedItems.GroupedCollectionChanged -= _groupedCollectionChanged;
+ if (disposing)
+ {
+ if (Element != null)
+ {
+ Element.ScrollToRequested -= OnScrollToRequested;
+ Element.TemplatedItems.CollectionChanged -= OnCollectionChanged;
+ Element.TemplatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged;
+ }
+ if (Control != null)
+ {
+ Control.ItemSelected -= OnListViewItemSelected;
+ Control.ItemUnselected -= OnListViewItemUnselected;
+ }
+ }
base.Dispose(disposing);
}
@@ -121,7 +109,7 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="sender">A native list instance from which the event has originated.</param>
/// <param name="e">Argument associated with handler, it holds native item for which event was raised</param>
- void ListViewItemSelectedHandler(object sender, GenListItemEventArgs e)
+ void OnListViewItemSelected(object sender, GenListItemEventArgs e)
{
GenListItem item = e.Item;
@@ -166,7 +154,7 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="sender">A native list instance from which the event has originated.</param>
/// <param name="e">Argument associated with handler, it holds native item for which event was raised</param>
- void ListViewItemUnselectedHandler(object sender, GenListItemEventArgs e)
+ void OnListViewItemUnselected(object sender, GenListItemEventArgs e)
{
if (_selectedItemChanging == 0)
{
@@ -363,14 +351,6 @@ namespace Xamarin.Forms.Platform.Tizen
void UpdateIsGroupingEnabled(bool initialize)
{
Control.IsGroupingEnabled = Element.IsGroupingEnabled;
- if (Element.IsGroupingEnabled)
- {
- Element.TemplatedItems.GroupedCollectionChanged += _groupedCollectionChanged;
- }
- else
- {
- Element.TemplatedItems.GroupedCollectionChanged -= _groupedCollectionChanged;
- }
}
/// <summary>
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs
index f6c8763..0608039 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs
@@ -36,25 +36,24 @@ namespace Xamarin.Forms.Platform.Tizen
{
Element.IsPresented = _mdpage.IsPresented;
};
+ SetNativeControl(_mdpage);
}
if (e.OldElement != null)
{
- (e.OldElement as IMasterDetailPageController).BackButtonPressed -= BackButtonPressedHandler;
+ (e.OldElement as IMasterDetailPageController).BackButtonPressed -= OnBackButtonPressed;
}
if (e.NewElement != null)
{
- (e.NewElement as IMasterDetailPageController).BackButtonPressed += BackButtonPressedHandler;
+ (e.NewElement as IMasterDetailPageController).BackButtonPressed += OnBackButtonPressed;
}
UpdateMasterBehavior();
- SetNativeControl(_mdpage);
-
base.OnElementChanged(e);
}
- void BackButtonPressedHandler(object sender, BackButtonPressedEventArgs e)
+ void OnBackButtonPressed(object sender, BackButtonPressedEventArgs e)
{
if ((Element != null) && Element.IsPresented)
{
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
index 36f199d..7a2f732 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
@@ -43,7 +43,17 @@ namespace Xamarin.Forms.Platform.Tizen
protected override void Dispose(bool disposing)
{
- _naviFrame.AnimationFinished -= AnimationFinishedHandler;
+ if (disposing)
+ {
+ if (_naviFrame != null)
+ {
+ _naviFrame.AnimationFinished -= OnAnimationFinished;
+ }
+ if (_toolbarTracker != null)
+ {
+ _toolbarTracker.CollectionChanged -= OnToolbarCollectionChanged;
+ }
+ }
base.Dispose(disposing);
}
@@ -54,7 +64,7 @@ namespace Xamarin.Forms.Platform.Tizen
_naviFrame = new Naviframe(Forms.Context.MainWindow);
_naviFrame.PreserveContentOnPop = true;
_naviFrame.DefaultBackButtonEnabled = true;
- _naviFrame.AnimationFinished += AnimationFinishedHandler;
+ _naviFrame.AnimationFinished += OnAnimationFinished;
SetNativeControl(_naviFrame);
}
@@ -62,33 +72,33 @@ namespace Xamarin.Forms.Platform.Tizen
if (_toolbarTracker == null)
{
_toolbarTracker = new ToolbarTracker();
- _toolbarTracker.CollectionChanged += ToolbarTrackerOnCollectionChanged;
+ _toolbarTracker.CollectionChanged += OnToolbarCollectionChanged;
}
if (e.OldElement != null)
{
var navigation = e.OldElement as INavigationPageController;
- navigation.PopRequested -= PopRequestedHandler;
- navigation.PopToRootRequested -= PopToRootRequestedHandler;
- navigation.PushRequested -= PushRequestedHandler;
- navigation.RemovePageRequested -= RemovePageRequestedHandler;
- navigation.InsertPageBeforeRequested -= InsertPageBeforeRequestedHandler;
+ navigation.PopRequested -= OnPopRequested;
+ navigation.PopToRootRequested -= OnPopToRootRequested;
+ navigation.PushRequested -= OnPushRequested;
+ navigation.RemovePageRequested -= OnRemovePageRequested;
+ navigation.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
var pageController = e.OldElement as IPageController;
- pageController.InternalChildren.CollectionChanged -= PageCollectionChangedHandler;
+ pageController.InternalChildren.CollectionChanged -= OnPageCollectionChanged;
}
if (e.NewElement != null)
{
var navigation = e.NewElement as INavigationPageController;
- navigation.PopRequested += PopRequestedHandler;
- navigation.PopToRootRequested += PopToRootRequestedHandler;
- navigation.PushRequested += PushRequestedHandler;
- navigation.RemovePageRequested += RemovePageRequestedHandler;
- navigation.InsertPageBeforeRequested += InsertPageBeforeRequestedHandler;
+ navigation.PopRequested += OnPopRequested;
+ navigation.PopToRootRequested += OnPopToRootRequested;
+ navigation.PushRequested += OnPushRequested;
+ navigation.RemovePageRequested += OnRemovePageRequested;
+ navigation.InsertPageBeforeRequested += OnInsertPageBeforeRequested;
var pageController = e.NewElement as IPageController;
- pageController.InternalChildren.CollectionChanged += PageCollectionChangedHandler;
+ pageController.InternalChildren.CollectionChanged += OnPageCollectionChanged;
foreach (Page page in pageController.InternalChildren)
{
@@ -128,7 +138,7 @@ namespace Xamarin.Forms.Platform.Tizen
}
- void PageCollectionChangedHandler(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+ void OnPageCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (Page page in e.OldItems)
@@ -138,7 +148,7 @@ namespace Xamarin.Forms.Platform.Tizen
page.PropertyChanged += NavigationBarPropertyChangedHandler;
}
- void ToolbarTrackerOnCollectionChanged(object sender, EventArgs eventArgs)
+ void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
{
UpdateToolbarItem(Element.CurrentPage);
}
@@ -375,7 +385,7 @@ namespace Xamarin.Forms.Platform.Tizen
return toolbar;
}
- void PopRequestedHandler(object sender, NavigationRequestedEventArgs nre)
+ void OnPopRequested(object sender, NavigationRequestedEventArgs nre)
{
if ((Element as IPageController).InternalChildren.Count == _naviFrame.NavigationStack.Count)
{
@@ -397,7 +407,7 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
- void PopToRootRequestedHandler(object sender, NavigationRequestedEventArgs nre)
+ void OnPopToRootRequested(object sender, NavigationRequestedEventArgs nre)
{
List<NaviItem> copyOfStack = new List<NaviItem>(_naviFrame.NavigationStack);
copyOfStack.Reverse();
@@ -423,7 +433,7 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
- void PushRequestedHandler(object sender, NavigationRequestedEventArgs nre)
+ void OnPushRequested(object sender, NavigationRequestedEventArgs nre)
{
if (nre.Animated || _naviFrame.NavigationStack.Count == 0)
{
@@ -441,12 +451,12 @@ namespace Xamarin.Forms.Platform.Tizen
UpdateHasNavigationBar(nre.Page);
}
- void RemovePageRequestedHandler(object sender, NavigationRequestedEventArgs nre)
+ void OnRemovePageRequested(object sender, NavigationRequestedEventArgs nre)
{
GetNaviItemForPage(nre.Page).Delete();
}
- void InsertPageBeforeRequestedHandler(object sender, NavigationRequestedEventArgs nre)
+ void OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs nre)
{
if (nre.BeforePage == null)
throw new ArgumentNullException("before");
@@ -458,7 +468,7 @@ namespace Xamarin.Forms.Platform.Tizen
UpdateHasNavigationBar(nre.Page);
}
- void AnimationFinishedHandler(object sender, EventArgs e)
+ void OnAnimationFinished(object sender, EventArgs e)
{
CompleteCurrentNavigationTask();
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/PickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/PickerRenderer.cs
index a8356ba..65f95ff 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/PickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/PickerRenderer.cs
@@ -12,26 +12,29 @@ namespace Xamarin.Forms.Platform.Tizen
internal Native.Dialog _dialog;
Dictionary<ListItem, int> _itemToItemNumber = new Dictionary<ListItem, int>();
- protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
+ protected override void Dispose(bool disposing)
{
- if (Control == null)
- {
- var button = new Native.Button(Forms.Context.MainWindow);
- SetNativeControl (button);
- }
-
- if (e.OldElement != null)
+ if (disposing)
{
- Control.Clicked -= OnClick;
+ if (Control != null)
+ {
+ Control.Clicked -= OnClicked;
+ CleanView();
+ }
}
+ base.Dispose(disposing);
+ }
- if (e.NewElement != null)
+ protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
+ {
+ if (Control == null)
{
- UpdateSelectedIndex();
- UpdateTextColor();
- Control.Clicked += OnClick;
+ SetNativeControl (new Native.Button(Forms.Context.MainWindow));
+ Control.Clicked += OnClicked;
}
+ UpdateSelectedIndex();
+ UpdateTextColor();
base.OnElementChanged(e);
}
@@ -60,7 +63,7 @@ namespace Xamarin.Forms.Platform.Tizen
Control.TextColor = Element.TextColor.ToNative();
}
- void OnClick(object sender, EventArgs e)
+ void OnClicked(object sender, EventArgs e)
{
int i = 0;
_dialog = new Native.Dialog(Forms.Context.MainWindow);
@@ -69,7 +72,7 @@ namespace Xamarin.Forms.Platform.Tizen
_dialog.AlignmentY = -1;
_dialog.Title = Element.Title;
- _dialog.Dismissed += DialogDismissed;
+ _dialog.Dismissed += OnDialogDismissed;
_dialog.BackButtonPressed += (object senders, EventArgs es) =>
{
_dialog.Dismiss();
@@ -81,20 +84,20 @@ namespace Xamarin.Forms.Platform.Tizen
_itemToItemNumber[item] = i;
i++;
}
- _list.ItemSelected += ItemSelected;
+ _list.ItemSelected += OnItemSelected;
_dialog.Content = _list;
_dialog.Show();
_list.Show();
}
- void ItemSelected(object senderObject, EventArgs ev)
+ void OnItemSelected(object senderObject, EventArgs ev)
{
Element.SelectedIndex = _itemToItemNumber[(senderObject as List).SelectedItem];
_dialog.Dismiss();
}
- void DialogDismissed(object sender, EventArgs e)
+ void OnDialogDismissed(object sender, EventArgs e)
{
CleanView();
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs
index 8fe97a7..cd2f45d 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ProgressBarRenderer.cs
@@ -10,14 +10,9 @@ namespace Xamarin.Forms.Platform.Tizen
{
protected override void OnElementChanged(ElementChangedEventArgs<ProgressBar> e)
{
- if (base.Control == null)
- {
- var progressBar = new EProgressBar(Forms.Context.MainWindow);
- SetNativeControl(progressBar);
- }
-
- if (e.OldElement != null)
+ if (Control == null)
{
+ SetNativeControl(new EProgressBar(Forms.Context.MainWindow));
}
if (e.NewElement != null)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
index 76ce555..0168d2d 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
@@ -27,20 +27,18 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var scrollView = new Scroller(Forms.Context.MainWindow);
- SetNativeControl(scrollView);
+ SetNativeControl(new Scroller(Forms.Context.MainWindow));
+ Control.Scrolled += OnScrolled;
}
if (e.OldElement != null)
{
- Control.Scrolled -= ScrollViewScrolledHandler;
- (e.OldElement as IScrollViewController).ScrollToRequested -= ScrollRequestHandler;
+ (e.OldElement as IScrollViewController).ScrollToRequested -= OnScrollRequested;
}
if (e.NewElement != null)
{
- Control.Scrolled += ScrollViewScrolledHandler;
- (e.NewElement as IScrollViewController).ScrollToRequested += ScrollRequestHandler;
+ (e.NewElement as IScrollViewController).ScrollToRequested += OnScrollRequested;
}
UpdateAll();
@@ -50,9 +48,17 @@ namespace Xamarin.Forms.Platform.Tizen
protected override void Dispose(bool disposing)
{
- if (null != Element)
+ if (disposing)
{
- (Element as IScrollViewController).ScrollToRequested -= ScrollRequestHandler;
+ if (null != Element)
+ {
+ (Element as IScrollViewController).ScrollToRequested -= OnScrollRequested;
+ }
+
+ if (Control != null)
+ {
+ Control.Scrolled -= OnScrolled;
+ }
}
base.Dispose(disposing);
@@ -129,13 +135,13 @@ namespace Xamarin.Forms.Platform.Tizen
base.OnElementPropertyChanged(sender, e);
}
- void ScrollViewScrolledHandler(object sender, EventArgs e)
+ void OnScrolled(object sender, EventArgs e)
{
var region = Control.CurrentRegion;
((IScrollViewController)Element).SetScrolledPosition(region.X, region.Y);
}
- void ScrollRequestHandler(object sender, ScrollToRequestedEventArgs e)
+ void OnScrollRequested(object sender, ScrollToRequestedEventArgs e)
{
var x = e.ScrollX;
var y = e.ScrollY;
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
index 30a2546..3e3344f 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
@@ -30,6 +30,20 @@ namespace Xamarin.Forms.Platform.Tizen
RegisterPropertyHandler(SearchBar.TextColorProperty, TextColorPropertyHandler);
}
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (Control != null)
+ {
+ Control.TextChanged -= OnTextChanged;
+ Control.SearchButtonPressed -= OnButtonPressed;
+ }
+ }
+ base.Dispose(disposing);
+ }
+
/// <summary>
/// A method called whenever the associated element has changed.
/// </summary>
@@ -37,25 +51,13 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var searchBar = new Native.SearchBar(Forms.Context.MainWindow);
- SetNativeControl(searchBar);
- }
-
- if (e.OldElement != null)
- {
- Control.TextChanged -= SearchBarTextChangedHandler;
- Control.SearchButtonPressed -= SearchButtonPressedHandler;
+ SetNativeControl(new Native.SearchBar(Forms.Context.MainWindow));
+ Control.TextChanged += OnTextChanged;
+ Control.SearchButtonPressed += OnButtonPressed;
}
-
- if (e.NewElement != null)
- {
- Control.TextChanged += SearchBarTextChangedHandler;
- Control.SearchButtonPressed += SearchButtonPressedHandler;
-
- Control.BatchBegin();
- }
-
+ Control.BatchBegin();
base.OnElementChanged(e);
+ Control.BatchCommit();
}
protected override Size MinimumSize()
@@ -63,11 +65,6 @@ namespace Xamarin.Forms.Platform.Tizen
return new Size(136, 65);
}
- protected override void OnElementReady()
- {
- Control?.BatchCommit();
- }
-
/// <summary>
/// Called upon changing of Xamarin widget's cancel button color property.
/// Converts current Color to ElmSharp.Color instance and sets it in the underlying Xamarin.Forms.Platform.Tizen.Native widget.
@@ -138,7 +135,7 @@ namespace Xamarin.Forms.Platform.Tizen
/// Rewrites current underlying Xamarin.Forms.Platform.Tizen.Native.SearchBar's Text contents to its Xamarin counterpart.
/// </summary>
/// <param name="sender">Sender.</param>
- void SearchBarTextChangedHandler(object sender, EventArgs e)
+ void OnTextChanged(object sender, EventArgs e)
{
Element.Text = Control.Text;
}
@@ -148,7 +145,7 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">Event arguments.</param>
- void SearchButtonPressedHandler(object sender, EventArgs e)
+ void OnButtonPressed(object sender, EventArgs e)
{
(Element as ISearchBarController).OnSearchButtonPressed();
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs
index b275464..db72583 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs
@@ -18,24 +18,25 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var slider = new ESlider(Forms.Context.MainWindow)
+ SetNativeControl(new ESlider(Forms.Context.MainWindow)
{
PropagateEvents = false,
- };
- SetNativeControl(slider);
- }
-
- if (e.OldElement != null)
- {
- Control.ValueChanged -= SliderValueChangedHandler;
+ });
+ Control.ValueChanged += OnValueChanged;
}
+ base.OnElementChanged(e);
+ }
- if (e.NewElement != null)
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- Control.ValueChanged += SliderValueChangedHandler;
+ if (Control != null)
+ {
+ Control.ValueChanged -= OnValueChanged;
+ }
}
-
- base.OnElementChanged(e);
+ base.Dispose(disposing);
}
protected override ESize Measure(int availableWidth, int availableHeight)
@@ -43,7 +44,7 @@ namespace Xamarin.Forms.Platform.Tizen
return new ESize(Math.Min(200, availableWidth), 50);
}
- void SliderValueChangedHandler(object sender, EventArgs e)
+ void OnValueChanged(object sender, EventArgs e)
{
Element.Value = Control.Value;
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs
index e5e4c58..a1cf311 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs
@@ -18,28 +18,28 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var stepper = new Spinner(Forms.Context.MainWindow)
+ SetNativeControl(new Spinner(Forms.Context.MainWindow)
{
IsEditable = false,
- };
-
- SetNativeControl(stepper);
- }
-
- if (e.OldElement != null)
- {
- Control.ValueChanged -= StepperValueChangedHandler;
+ });
+ Control.ValueChanged += OnValueChanged;
}
+ base.OnElementChanged(e);
+ }
- if (e.NewElement != null)
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- Control.ValueChanged += StepperValueChangedHandler;
+ if (Control != null)
+ {
+ Control.ValueChanged -= OnValueChanged;
+ }
}
-
- base.OnElementChanged(e);
+ base.Dispose(disposing);
}
- void StepperValueChangedHandler(object sender, EventArgs e)
+ void OnValueChanged(object sender, EventArgs e)
{
double newValue = Control.Value;
((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, newValue);
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
index e0b54d5..5c6814a 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
@@ -17,25 +17,26 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var _switch = new Check(Forms.Context.MainWindow)
+ SetNativeControl(new Check(Forms.Context.MainWindow)
{
PropagateEvents = false,
Style = SwitchStyle.Toggle
- };
- SetNativeControl(_switch);
- }
-
- if (e.OldElement != null)
- {
- Control.StateChanged -= CheckChangedHandler;
+ });
+ Control.StateChanged += OnStateChanged;
}
+ base.OnElementChanged(e);
+ }
- if (e.NewElement != null)
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- Control.StateChanged += CheckChangedHandler;
+ if (Control != null)
+ {
+ Control.StateChanged -= OnStateChanged;
+ }
}
-
- base.OnElementChanged(e);
+ base.Dispose(disposing);
}
protected override void UpdateThemeStyle()
@@ -59,7 +60,7 @@ namespace Xamarin.Forms.Platform.Tizen
((IVisualElementController)Element).NativeSizeChanged();
}
- void CheckChangedHandler(object sender, EventArgs e)
+ void OnStateChanged(object sender, EventArgs e)
{
Element.SetValue(Switch.IsToggledProperty, Control.IsChecked);
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
index 683f323..3af1b34 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
@@ -20,9 +20,7 @@ namespace Xamarin.Forms.Platform.Tizen
public TabbedPageRenderer()
{
- //Register for title change property
RegisterPropertyHandler(TabbedPage.TitleProperty, UpdateTitle);
- //Register for current page change property
RegisterPropertyHandler("CurrentPage", CurrentPageChanged);
RegisterPropertyHandler(TabbedPage.BarBackgroundColorProperty, UpdateBarBackgroundColor);
}
@@ -104,18 +102,20 @@ namespace Xamarin.Forms.Platform.Tizen
protected override void Dispose(bool disposing)
{
- if (_outterLayout != null)
+ if (disposing)
{
- _outterLayout.Unrealize();
- _outterLayout = null;
- }
- if (_toolbar != null)
- {
- _toolbar.Selected -= OnToolbarItemSelected;
- _scroller.PageScrolled -= OnItemPageScrolled;
-
- _toolbar.Unrealize();
- _toolbar = null;
+ if (_outterLayout != null)
+ {
+ _outterLayout.Unrealize();
+ _outterLayout = null;
+ }
+ if (_toolbar != null)
+ {
+ _toolbar.Selected -= OnToolbarItemSelected;
+ _scroller.PageScrolled -= OnItemPageScrolled;
+ _toolbar.Unrealize();
+ _toolbar = null;
+ }
}
base.Dispose(disposing);
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs
index c1a3791..58b17a4 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs
@@ -17,20 +17,18 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Control == null)
{
- var _tableView = new Native.TableView(Forms.Context.MainWindow);
- SetNativeControl(_tableView);
+ SetNativeControl(new Native.TableView(Forms.Context.MainWindow));
+ Control.ItemSelected += OnSelected;
}
if (e.OldElement != null)
{
- Control.ItemSelected -= ListViewItemSelectedHandler;
e.OldElement.ModelChanged -= OnRootPropertyChanged;
}
if (e.NewElement != null)
{
e.NewElement.ModelChanged += OnRootPropertyChanged;
- Control.ItemSelected += ListViewItemSelectedHandler;
Control.ApplyTableRoot(e.NewElement.Root);
}
@@ -39,11 +37,23 @@ namespace Xamarin.Forms.Platform.Tizen
protected override void Dispose(bool disposing)
{
- Element.ModelChanged -= OnRootPropertyChanged;
+ if (disposing)
+ {
+ if (Element != null)
+ {
+ Element.ModelChanged -= OnRootPropertyChanged;
+ }
+
+ if (Control != null)
+ {
+ Control.ItemSelected -= OnSelected;
+ }
+ }
+
base.Dispose(disposing);
}
- void ListViewItemSelectedHandler(object sender, GenListItemEventArgs e)
+ void OnSelected(object sender, GenListItemEventArgs e)
{
var item = e.Item as GenListItem;
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
index 6c517c9..211ccf3 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
@@ -10,7 +10,7 @@ namespace Xamarin.Forms.Platform.Tizen
static readonly string s_defaultFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
- TimeSpan _time;
+ TimeSpan _time = DateTime.Now.TimeOfDay;
public TimePickerRenderer()
{
@@ -31,22 +31,22 @@ namespace Xamarin.Forms.Platform.Tizen
entry.SetVerticalTextAlignment("elm.text", 0.5);
entry.AllowFocus(false);
SetNativeControl(entry);
+ Control.Clicked += OnClicked;
}
+ base.OnElementChanged(e);
+ }
- if (e.OldElement != null)
- {
- Control.Clicked -= ClickedHandler;
- }
-
- if (e.NewElement != null)
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- _time = DateTime.Now.TimeOfDay;
- UpdateTimeAndFormat();
-
- Control.Clicked += ClickedHandler;
+ if (Control != null)
+ {
+ Control.Clicked -= OnClicked;
+ }
}
- base.OnElementChanged(e);
+ base.Dispose(disposing);
}
protected override Size MinimumSize()
@@ -54,7 +54,7 @@ namespace Xamarin.Forms.Platform.Tizen
return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
- void ClickedHandler(object o, EventArgs e)
+ void OnClicked(object o, EventArgs e)
{
Native.DateTimePickerDialog dialog = new Native.DateTimePickerDialog(Forms.Context.MainWindow)
{
@@ -62,22 +62,22 @@ namespace Xamarin.Forms.Platform.Tizen
};
dialog.InitializeTimePicker(_time, null);
- dialog.DateTimeChanged += DialogDateTimeChangedHandler;
- dialog.Dismissed += DialogDismissedHandler;
+ dialog.DateTimeChanged += OnDialogTimeChanged;
+ dialog.Dismissed += OnDialogDismissed;
dialog.Show();
}
- void DialogDateTimeChangedHandler(object sender, Native.DateChangedEventArgs dcea)
+ void OnDialogTimeChanged(object sender, Native.DateChangedEventArgs dcea)
{
Element.Time = dcea.NewDate.TimeOfDay;
UpdateTime();
}
- void DialogDismissedHandler(object sender, EventArgs e)
+ void OnDialogDismissed(object sender, EventArgs e)
{
var dialog = sender as Native.DateTimePickerDialog;
- dialog.DateTimeChanged -= DialogDateTimeChangedHandler;
- dialog.Dismissed -= DialogDismissedHandler;
+ dialog.DateTimeChanged -= OnDialogTimeChanged;
+ dialog.Dismissed -= OnDialogDismissed;
}
void UpdateFormat()
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
index 0e76298..4a409f0 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
@@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
-using Xamarin.Forms.Internals;
using System.Linq;
using ElmSharp;
using ESize = ElmSharp.Size;
using ERect = ElmSharp.Rect;
using EFocusDirection = ElmSharp.FocusDirection;
+using Xamarin.Forms.Internals;
+using Xamarin.Forms.Platform.Tizen.Native;
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
using XFocusDirection = Xamarin.Forms.PlatformConfiguration.TizenSpecific.FocusDirection;
@@ -23,13 +24,6 @@ namespace Xamarin.Forms.Platform.Tizen
readonly List<EventHandler<VisualElementChangedEventArgs>> _elementChangedHandlers = new List<EventHandler<VisualElementChangedEventArgs>>();
/// <summary>
- /// Handler for property changed events.
- /// </summary>
- PropertyChangedEventHandler _propertyChangedHandler;
-
- EventHandler<EventArg<VisualElement>> _batchCommittedHandler;
-
- /// <summary>
/// Flags which control status of renderer.
/// </summary>
VisualElementRendererFlags _flags = VisualElementRendererFlags.None;
@@ -112,7 +106,7 @@ namespace Xamarin.Forms.Platform.Tizen
{
get
{
- return this.Element;
+ return Element;
}
}
@@ -183,20 +177,12 @@ namespace Xamarin.Forms.Platform.Tizen
}
TElement oldElement = Element;
- if (oldElement != null)
- {
- throw new InvalidOperationException("oldElement");
- }
Element = newElement;
- if (_propertyChangedHandler == null)
- {
- _propertyChangedHandler = new PropertyChangedEventHandler(OnElementPropertyChanged);
- }
- if (_batchCommittedHandler == null)
+ if (oldElement != null)
{
- _batchCommittedHandler = OnBatchCommitted;
+ Platform.SetRenderer(oldElement, null);
}
// send notification
@@ -283,8 +269,8 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (Element != null)
{
- Element.PropertyChanged -= _propertyChangedHandler;
- Element.BatchCommitted -= _batchCommittedHandler;
+ Element.PropertyChanged -= OnElementPropertyChanged;
+ Element.BatchCommitted -= OnBatchCommitted;
Element.ChildAdded -= OnChildAdded;
Element.ChildRemoved -= OnChildRemoved;
@@ -292,8 +278,6 @@ namespace Xamarin.Forms.Platform.Tizen
Element.FocusChangeRequested -= OnFocusChangeRequested;
- Element.Layout(new Rectangle(0, 0, -1, -1));
-
var logicalChildren = (Element as IElementController).LogicalChildren;
foreach (var child in logicalChildren)
{
@@ -302,7 +286,7 @@ namespace Xamarin.Forms.Platform.Tizen
if (Platform.GetRenderer(Element) == this)
{
- Platform.SetRenderer(Element, (IVisualElementRenderer)null);
+ Platform.SetRenderer(Element, null);
}
Element = default(TElement);
}
@@ -324,8 +308,8 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (null != e.OldElement)
{
- e.OldElement.PropertyChanged -= _propertyChangedHandler;
- e.OldElement.BatchCommitted -= _batchCommittedHandler;
+ e.OldElement.PropertyChanged -= OnElementPropertyChanged;
+ e.OldElement.BatchCommitted -= OnBatchCommitted;
e.OldElement.ChildAdded -= OnChildAdded;
e.OldElement.ChildRemoved -= OnChildRemoved;
@@ -333,8 +317,6 @@ namespace Xamarin.Forms.Platform.Tizen
e.OldElement.FocusChangeRequested -= OnFocusChangeRequested;
- Element.Layout(new Rectangle(0, 0, -1, -1));
-
var controller = e.OldElement as IElementController;
if (controller != null && controller.EffectControlProvider == this)
{
@@ -344,8 +326,8 @@ namespace Xamarin.Forms.Platform.Tizen
if (null != e.NewElement)
{
- e.NewElement.PropertyChanged += _propertyChangedHandler;
- e.NewElement.BatchCommitted += _batchCommittedHandler;
+ e.NewElement.PropertyChanged += OnElementPropertyChanged;
+ e.NewElement.BatchCommitted += OnBatchCommitted;
e.NewElement.ChildAdded += OnChildAdded;
e.NewElement.ChildRemoved += OnChildRemoved;
@@ -353,7 +335,9 @@ namespace Xamarin.Forms.Platform.Tizen
e.NewElement.FocusChangeRequested += OnFocusChangeRequested;
+ (NativeView as IBatchable)?.BatchBegin();
UpdateAllProperties(true);
+ (NativeView as IBatchable)?.BatchCommit();
var controller = e.NewElement as IElementController;
if (controller != null)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/WebViewRenderer.cs
index cb61aa5..6543fe1 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/WebViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/WebViewRenderer.cs
@@ -31,15 +31,16 @@ namespace Xamarin.Forms.Platform.Tizen
{
if (disposing)
{
+ if (_control != null)
+ {
+ _control.StopLoading();
+ _control.LoadStarted -= OnLoadStarted;
+ _control.LoadFinished -= OnLoadFinished;
+ _control.LoadError -= OnLoadError;
+ }
+
if (Element != null)
{
- if (_control != null)
- {
- _control.StopLoading();
- _control.LoadStarted -= OnLoadStarted;
- _control.LoadFinished -= OnLoadFinished;
- _control.LoadError -= OnLoadError;
- }
Element.EvalRequested -= OnEvalRequested;
Element.GoBackRequested -= OnGoBackRequested;
Element.GoForwardRequested -= OnGoForwardRequested;