summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Extensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Extensions.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Extensions.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Extensions.cs b/Xamarin.Forms.Platform.Android/Extensions.cs
new file mode 100644
index 00000000..c326555a
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/Extensions.cs
@@ -0,0 +1,40 @@
+´╗┐using Android.Content.Res;
+using Android.Views;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ public static class Extensions
+ {
+ internal static IMenuItem FindMenuItemByNameOrIcon(this IMenu menu, string menuName, string iconName)
+ {
+ if (menu.Size() == 1)
+ return menu.GetItem(0);
+
+ for (var i = 0; i < menu.Size(); i++)
+ {
+ IMenuItem menuItem = menu.GetItem(i);
+ if (menuItem.TitleFormatted != null && menuName == menuItem.TitleFormatted.ToString())
+ return menuItem;
+
+ if (!string.IsNullOrEmpty(iconName))
+ {
+ // TODO : search by iconName
+ }
+ }
+ return null;
+ }
+
+ internal static DeviceOrientation ToDeviceOrientation(this Orientation orientation)
+ {
+ switch (orientation)
+ {
+ case Orientation.Landscape:
+ return DeviceOrientation.Landscape;
+ case Orientation.Portrait:
+ return DeviceOrientation.Portrait;
+ default:
+ return DeviceOrientation.Other;
+ }
+ }
+ }
+} \ No newline at end of file