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

Error when hiding menu on back navigation Android #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion SlideOverKit.Droid/MenuContainerPageDroidRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public class MenuContainerPageDroidRenderer : PageRenderer, ISlideOverKitPageRe

public Action<bool, int,int,int,int> OnLayoutEvent { get; set; }

public Action<int,int,int,int> OnSizeChangedEvent { get; set; }
public Action<int,int,int,int> OnSizeChangedEvent { get; set; }

public bool IsDisposed { get; private set; }

public MenuContainerPageDroidRenderer ()
{
Expand All @@ -41,6 +43,12 @@ protected override void OnSizeChanged (int w, int h, int oldw, int oldh)
if (OnSizeChangedEvent != null)
OnSizeChangedEvent (w, h, oldw, oldh);
}

protected override void Dispose(bool disposing)
{
IsDisposed = true;
base.Dispose(disposing);
}
}
}

6 changes: 4 additions & 2 deletions SlideOverKit.Droid/SlideOverKitDroidHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ Rect LayoutPopup ()

void HideBackgroundOverlay ()
{
if (_backgroundOverlay != null) {
_pageRenderer.RemoveView (_backgroundOverlay);
if (_backgroundOverlay != null) {
var renderer = _pageRenderer as MenuContainerPageDroidRenderer;
if (renderer == null || !renderer.IsDisposed)
_pageRenderer.RemoveView(_backgroundOverlay);
_backgroundOverlay.Dispose ();
_backgroundOverlay = null;
}
Expand Down