-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend logging of page lifecycle events to better analyse behaviour o…
…n iOS and Android.
- Loading branch information
1 parent
85d8425
commit a91842b
Showing
7 changed files
with
48 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using Xamarin.Forms; | ||
|
||
namespace DemoApp | ||
{ | ||
public static class PageExtensions | ||
{ | ||
public static T AddPageLog<T>(this T page) where T : Page | ||
{ | ||
page.Appearing += OnAppearing; | ||
page.Disappearing += OnDisappearing; | ||
return page; | ||
} | ||
|
||
static void OnAppearing(object sender, EventArgs e) | ||
{ | ||
var page = sender as Page; | ||
var logMessage = $"A({GetLogName(page)})"; | ||
App.PageLog += $"{logMessage} "; | ||
Console.WriteLine(logMessage); | ||
} | ||
|
||
static void OnDisappearing(object sender, EventArgs e) | ||
{ | ||
var page = sender as Page; | ||
var logMessage = $"D({GetLogName(page)})"; | ||
App.PageLog += $"{logMessage} "; | ||
Console.WriteLine(logMessage); | ||
} | ||
|
||
static string GetLogName(Page page) => page.Title ?? page.GetType().Name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters