Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions BTProgressHUD/ProgressHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
}

public UIWindow HudWindow { get; private set; }
public UIWindow? HudWindow { get; private set; }

public static CGRect KeyboardSize { get; private set; } = CGRect.Empty;

Expand Down Expand Up @@ -187,10 +187,10 @@

if (OperatingSystem.IsMacCatalystVersionAtLeast(15) || OperatingSystem.IsIOSVersionAtLeast(15))
{
foreach (var scene in UIApplication.SharedApplication.ConnectedScenes)

Check warning on line 190 in BTProgressHUD/ProgressHUD.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on: 'iOS' 12.2 and later, 'maccatalyst' 15.0 and later. 'UIApplication.ConnectedScenes' is only supported on: 'ios' 13.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{
if (scene is not UIWindowScene windowScene) continue;
window = windowScene.KeyWindow ?? windowScene.Windows?.LastOrDefault();

Check warning on line 193 in BTProgressHUD/ProgressHUD.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on: 'iOS' 12.2 and later, 'maccatalyst' 15.0 and later. 'UIWindowScene.Windows' is only supported on: 'ios' 13.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 193 in BTProgressHUD/ProgressHUD.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on: 'iOS' 12.2 and later, 'maccatalyst' 15.0 and later. 'UIWindowScene.Windows' is only supported on: 'ios' 13.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
}
}
else if (OperatingSystem.IsMacCatalystVersionAtLeast(13) || OperatingSystem.IsIOSVersionAtLeast(13))
Expand Down Expand Up @@ -367,7 +367,7 @@
{
_spinnerView ??= new UIActivityIndicatorView(
OperatingSystem.IsMacCatalystVersionAtLeast(13, 1) || OperatingSystem.IsIOSVersionAtLeast(13) ?
UIActivityIndicatorViewStyle.Large :

Check warning on line 370 in BTProgressHUD/ProgressHUD.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on: 'iOS' 12.2 and later, 'maccatalyst' 13.0 and later. 'UIActivityIndicatorViewStyle.Large' is only supported on: 'ios' 13.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
UIActivityIndicatorViewStyle.WhiteLarge)
{
HidesWhenStopped = true,
Expand Down Expand Up @@ -698,18 +698,20 @@
{
CATransaction.Begin();
CATransaction.DisableActions = true;
HudView.Layer.RemoveAllAnimations();
_hudView?.Layer.RemoveAllAnimations();

RingLayer.StrokeEnd = 0;
if (RingLayer.SuperLayer != null)
if (_ringLayer != null)
_ringLayer.StrokeEnd = 0;

if (_ringLayer?.SuperLayer != null)
{
RingLayer.RemoveFromSuperLayer();
_ringLayer.RemoveFromSuperLayer();
}
_ringLayer = null;

if (BackgroundRingLayer?.SuperLayer != null)
if (_backgroundRingLayer?.SuperLayer != null)
{
BackgroundRingLayer.RemoveFromSuperLayer();
_backgroundRingLayer.RemoveFromSuperLayer();
}
_backgroundRingLayer = null;

Expand Down Expand Up @@ -745,32 +747,34 @@
private void RemoveHud()
{
Alpha = 0f;
HudView.Alpha = 0f;
if (_hudView != null)
_hudView.Alpha = 0f;

//Removing observers
UnRegisterNotifications();
NSNotificationCenter.DefaultCenter.RemoveObserver(this);

CancelRingLayerAnimation();
StringLabel.RemoveFromSuperview();
SpinnerView.RemoveFromSuperview();
ImageView.RemoveFromSuperview();
_stringLabel?.RemoveFromSuperview();
_spinnerView?.RemoveFromSuperview();
_imageView?.RemoveFromSuperview();
_cancelHud?.RemoveFromSuperview();

_stringLabel = null;
_spinnerView = null;
_imageView = null;
_cancelHud = null;

HudView.RemoveFromSuperview();
_hudView?.RemoveFromSuperview();
_hudView = null;
OverlayView.RemoveFromSuperview();
_overlayView?.RemoveFromSuperview();
_overlayView = null;
RemoveFromSuperview();

try
{
HudWindow?.RootViewController?.SetNeedsStatusBarAppearanceUpdate();
HudWindow = null!;
}
catch (ObjectDisposedException)
{
Expand Down
Loading