Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak on touchBehavior android #2113

Merged
merged 16 commits into from
Aug 16, 2024
Merged
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
inputs:
script: 'dotnet workload install maui'

- pwsh: |
- powershell: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
displayName: Install Tizen Workload
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
inputs:
script: dotnet workload install maui --skip-sign-check --source https://api.nuget.org/v3/index.json

- pwsh: |
- powershell: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
displayName: Install Tizen Workload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override void OnAttachedTo(VisualElement bindable, AView platformView)

Element = bindable;
view = platformView;
viewGroup = Microsoft.Maui.Platform.ViewExtensions.GetParentOfType<ViewGroup>(platformView);
viewGroup = platformView.GetParentOfType<ViewGroup>();

platformView.Touch += OnTouch;
UpdateClickHandler();
Expand Down Expand Up @@ -289,28 +289,34 @@ sealed class AccessibilityListener : Java.Lang.Object,
AccessibilityManager.IAccessibilityStateChangeListener,
AccessibilityManager.ITouchExplorationStateChangeListener
{
TouchBehavior? platformTouchBehavior;
readonly WeakReference<TouchBehavior?> platformTouchBehaviorReference;

internal AccessibilityListener(TouchBehavior platformTouchBehavior)
{
this.platformTouchBehavior = platformTouchBehavior;
platformTouchBehaviorReference = new(platformTouchBehavior);
}

public void OnAccessibilityStateChanged(bool enabled)
{
platformTouchBehavior?.UpdateClickHandler();
if (platformTouchBehaviorReference.TryGetTarget(out var platformTouchBehavior))
{
platformTouchBehavior.UpdateClickHandler();
}
}

public void OnTouchExplorationStateChanged(bool enabled)
{
platformTouchBehavior?.UpdateClickHandler();
if (platformTouchBehaviorReference.TryGetTarget(out var platformTouchBehavior))
{
platformTouchBehavior.UpdateClickHandler();
}
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
platformTouchBehavior = null;
platformTouchBehaviorReference.SetTarget(null);
}

base.Dispose(disposing);
Expand Down
Loading