Last active
December 27, 2015 21:19
-
-
Save webmonger/7390834 to your computer and use it in GitHub Desktop.
MvvmCross LegacyBar implementation. I had to build the library from GitHub rather than using the Component from the Xamarin make sure you switch to the eventmenu branch or this will not work
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
using System; | |
using Android.App; | |
using Android.Content; | |
using Android.Views; | |
using Cirrious.MvvmCross.Droid.Views; | |
using LegacyBar.Library.BarBase; | |
namespace BarcodeWars.Droid.Controls | |
{ | |
public class MvxLegacyBarActivity : MvxActivity | |
{ | |
public MvxLegacyBarActivity () | |
{ | |
} | |
public LegacyBar.Library.Bar.LegacyBar LegacyBar { get; set; } | |
public int MenuId { get; set; } | |
public override bool OnPrepareOptionsMenu(IMenu menu) | |
{ | |
if (LegacyBar == null) | |
return base.OnPrepareOptionsMenu(menu); | |
menu.Clear(); | |
MenuInflater.Inflate(MenuId, menu); | |
for (var i = 0; i < menu.Size(); i++) | |
{ | |
var menuItem = menu.GetItem(i); | |
menuItem.SetVisible(!LegacyBar.MenuItemsToHide.Contains(menuItem.ItemId)); | |
} | |
return base.OnPrepareOptionsMenu(menu); | |
} | |
public override bool OnCreateOptionsMenu(IMenu menu) | |
{ | |
if (MenuId > 0) | |
MenuInflater.Inflate(MenuId, menu); | |
return base.OnCreateOptionsMenu(menu); | |
} | |
public void AddHomeAction(Type activity, int resId) | |
{ | |
LegacyBarActivityUtils.AddHomeAction(LegacyBar, this, activity, resId); | |
} | |
public void AddHomeAction(Action action, int resId, bool isHomeAsUpEnabled = true) | |
{ | |
LegacyBarActivityUtils.AddHomeAction(LegacyBar, action, resId, isHomeAsUpEnabled); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment