|
|
|
@ -21,6 +21,7 @@ namespace Avalonia.Android |
|
|
|
private readonly ViewImpl _view; |
|
|
|
|
|
|
|
private IDisposable? _timerSubscription; |
|
|
|
private bool _surfaceCreated; |
|
|
|
|
|
|
|
public AvaloniaView(Context context) : base(context) |
|
|
|
{ |
|
|
|
@ -32,6 +33,18 @@ namespace Avalonia.Android |
|
|
|
|
|
|
|
this.SetBackgroundColor(global::Android.Graphics.Color.Transparent); |
|
|
|
OnConfigurationChanged(); |
|
|
|
|
|
|
|
_view.InternalView.SurfaceWindowCreated += InternalView_SurfaceWindowCreated; |
|
|
|
} |
|
|
|
|
|
|
|
private void InternalView_SurfaceWindowCreated(object? sender, EventArgs e) |
|
|
|
{ |
|
|
|
_surfaceCreated = true; |
|
|
|
|
|
|
|
if (Visibility == ViewStates.Visible) |
|
|
|
{ |
|
|
|
OnVisibilityChanged(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal TopLevelImpl TopLevelImpl => _view; |
|
|
|
@ -43,9 +56,10 @@ namespace Avalonia.Android |
|
|
|
set { _root.Content = value; } |
|
|
|
} |
|
|
|
|
|
|
|
protected override void Dispose(bool disposing) |
|
|
|
internal new void Dispose() |
|
|
|
{ |
|
|
|
base.Dispose(disposing); |
|
|
|
OnVisibilityChanged(false); |
|
|
|
_surfaceCreated = false; |
|
|
|
_root?.Dispose(); |
|
|
|
_root = null!; |
|
|
|
} |
|
|
|
@ -70,6 +84,8 @@ namespace Avalonia.Android |
|
|
|
|
|
|
|
internal void OnVisibilityChanged(bool isVisible) |
|
|
|
{ |
|
|
|
if (_root == null || !_surfaceCreated) |
|
|
|
return; |
|
|
|
if (isVisible && _timerSubscription == null) |
|
|
|
{ |
|
|
|
if (AvaloniaLocator.Current.GetService<IRenderTimer>() is ChoreographerTimer timer) |
|
|
|
|