From 4b2f7db012f461f8d0165677402cc9931f323e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Sua=CC=81rez?= Date: Mon, 14 Nov 2022 16:48:09 +0100 Subject: [PATCH 1/2] Fix crash disconnecting the IndicatorView on Android --- .../IndicatorView/IndicatorViewHandler.Android.cs | 8 ++++++-- .../IndicatorView/IndicatorViewHandler.Windows.cs | 4 +++- .../Handlers/IndicatorView/IndicatorViewHandler.iOS.cs | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Android.cs b/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Android.cs index e72dcfad9185..5ceabd462967 100644 --- a/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Android.cs +++ b/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Android.cs @@ -12,13 +12,17 @@ protected override MauiPageControl CreatePlatformView() private protected override void OnConnectHandler(AView platformView) { base.OnConnectHandler(platformView); - PlatformView.SetIndicatorView(VirtualView); + + if(platformView is MauiPageControl pageControl) + pageControl.SetIndicatorView(VirtualView); } private protected override void OnDisconnectHandler(AView platformView) { base.OnDisconnectHandler(platformView); - PlatformView.SetIndicatorView(null); + + if (platformView is MauiPageControl pageControl) + pageControl.SetIndicatorView(null); } public static void MapCount(IIndicatorViewHandler handler, IIndicatorView indicator) diff --git a/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Windows.cs b/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Windows.cs index 617564cc3491..b5a9c3244cf1 100644 --- a/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Windows.cs +++ b/src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Windows.cs @@ -12,7 +12,9 @@ public partial class IndicatorViewHandler : ViewHandler Date: Thu, 24 Nov 2022 12:35:15 +0100 Subject: [PATCH 2/2] Added IndicatorViewStub --- .../IndicatorViewHandlerTests.Android.cs | 7 +++++++ .../IndicatorViewHandlerTests.Windows.cs | 7 +++++++ .../IndicatorViewHandlerTests.cs | 10 +++++++++ .../IndicatorViewHandlerTests.iOS.cs | 7 +++++++ .../DeviceTests/Stubs/IndicatorViewStub.cs | 21 +++++++++++++++++++ src/Core/tests/DeviceTests/TestCategory.cs | 1 + 6 files changed, 53 insertions(+) create mode 100644 src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Android.cs create mode 100644 src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Windows.cs create mode 100644 src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.cs create mode 100644 src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.iOS.cs create mode 100644 src/Core/tests/DeviceTests/Stubs/IndicatorViewStub.cs diff --git a/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Android.cs new file mode 100644 index 000000000000..ea548d91a908 --- /dev/null +++ b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Android.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.DeviceTests +{ + public partial class IndicatorViewHandlerTests + { + + } +} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Windows.cs new file mode 100644 index 000000000000..ea548d91a908 --- /dev/null +++ b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Windows.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.DeviceTests +{ + public partial class IndicatorViewHandlerTests + { + + } +} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.cs new file mode 100644 index 000000000000..fc12ba9cde72 --- /dev/null +++ b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.cs @@ -0,0 +1,10 @@ +using Microsoft.Maui.DeviceTests.Stubs; + +namespace Microsoft.Maui.DeviceTests +{ + [Category(TestCategory.IndicatorView)] + public partial class IndicatorViewHandlerTests : CoreHandlerTestBase + { + + } +} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.iOS.cs new file mode 100644 index 000000000000..ea548d91a908 --- /dev/null +++ b/src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.iOS.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Maui.DeviceTests +{ + public partial class IndicatorViewHandlerTests + { + + } +} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Stubs/IndicatorViewStub.cs b/src/Core/tests/DeviceTests/Stubs/IndicatorViewStub.cs new file mode 100644 index 000000000000..1767208ffb71 --- /dev/null +++ b/src/Core/tests/DeviceTests/Stubs/IndicatorViewStub.cs @@ -0,0 +1,21 @@ +namespace Microsoft.Maui.DeviceTests.Stubs +{ + public class IndicatorViewStub : StubBase, IIndicatorView + { + public int Count { get; set; } + + public int Position { get; set; } + + public double IndicatorSize { get; set; } = 6.0d; + + public int MaximumVisible { get; set; } = int.MaxValue; + + public bool HideSingle { get; set; } + + public Paint IndicatorColor { get; set; } = new SolidPaint(Colors.Black); + + public Paint SelectedIndicatorColor { get; set; } = new SolidPaint(Colors.Grey); + + public IShape IndicatorsShape { get; set; } + } +} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/TestCategory.cs b/src/Core/tests/DeviceTests/TestCategory.cs index 686611d52697..515f0dd057e5 100644 --- a/src/Core/tests/DeviceTests/TestCategory.cs +++ b/src/Core/tests/DeviceTests/TestCategory.cs @@ -22,6 +22,7 @@ public static class TestCategory public const string Image = "Image"; public const string ImageButton = "ImageButton"; public const string ImageSource = "ImageSource"; + public const string IndicatorView = "IndicatorView"; public const string Label = "Label"; public const string Layout = "Layout"; public const string NavigationView = "NavigationView";