--- /dev/null
+using System.Runtime.CompilerServices;
+
+namespace Xamarin.Forms.Platform.Tizen.Native
+{
+ internal static class BatchableExtensions
+ {
+ static readonly ConditionalWeakTable<IBatchable, BatchCount> s_counters = new ConditionalWeakTable<IBatchable, BatchCount>();
+
+ public static void BatchBegin(this IBatchable target)
+ {
+ BatchCount value = null;
+
+ if (s_counters.TryGetValue(target, out value))
+ {
+ value.Count++;
+ }
+ else
+ {
+ s_counters.Add(target, new BatchCount());
+ }
+ }
+
+ public static void BatchCommit(this IBatchable target)
+ {
+ BatchCount value = null;
+ if (s_counters.TryGetValue(target, out value))
+ {
+ value.Count--;
+ if (value.Count == 0)
+ {
+ target.OnBatchCommitted();
+ }
+ else if (value.Count < 0)
+ {
+ Log.Error("Called BatchCommit() without BatchBegin().");
+ value.Count = 0;
+ }
+ }
+ else
+ {
+ Log.Error("Called BatchCommit() without BatchBegin().");
+ }
+ }
+
+ public static bool IsBatched(this IBatchable target)
+ {
+ BatchCount value = null;
+
+ if (s_counters.TryGetValue(target, out value))
+ {
+ return value.Count != 0;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ class BatchCount
+ {
+ public int Count = 1;
+ }
+ }
+}
--- /dev/null
+namespace Xamarin.Forms.Platform.Tizen.Native
+{
+ internal interface IBatchable
+ {
+ void OnBatchCommitted();
+ }
+}
/// The Label class extends <c>ElmSharp.Label</c> to be better suited for Xamarin renderers.
/// Mainly the formatted text support.
/// </summary>
- public class Label : ELabel, ITextable, IMeasurable
+ public class Label : ELabel, ITextable, IMeasurable, IBatchable
{
/// <summary>
/// The _span holds the content of the label.
return formattedSize;
}
+ void IBatchable.OnBatchCommitted()
+ {
+ ApplyTextAndStyle();
+ }
+
void ApplyTextAndStyle()
{
- SetInternalTextAndStyle(_span.GetDecoratedText(), _span.GetStyle());
+ if (!this.IsBatched())
+ {
+ SetInternalTextAndStyle(_span.GetDecoratedText(), _span.GetStyle());
+ }
}
void SetInternalTextAndStyle(string formattedText, string textStyle)
+using Xamarin.Forms.Platform.Tizen.Native;
using EColor = ElmSharp.Color;
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Label;
if (e.NewElement != null)
{
+ Control.BatchBegin();
}
base.OnElementChanged(e);
return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
+ protected override void OnElementReady()
+ {
+ Control?.BatchCommit();
+ }
+
Native.FormattedString ConvertFormattedText(FormattedString formattedString)
{
if (formattedString == null)
void UpdateFontProperties()
{
+ Control.BatchBegin();
+
Control.FontSize = Element.FontSize;
Control.FontAttributes = Element.FontAttributes;
Control.FontFamily = Element.FontFamily;
+
+ Control.BatchCommit();
}
void UpdateLineBreakMode()