Beispiel #1
0
 public void Remove(MessageBusEventHandler handler)
 {
     lock (_collection)
     {
         if (_collection.Contains(handler))
         {
             _collection.Remove(handler);
         }
     }
 }
Beispiel #2
0
 public void Add(MessageBusEventHandler handler)
 {
     lock (_collection)
     {
         if (_collection.Contains(handler) == false)
         {
             _collection.Add(handler);
         }
     }
 }
        void RegisterForEvent(string eventId)
        {
            handler = new MessageBusEventHandler()
            {
                EventAction = (obj, message) =>
                {
                    lastSender = obj;
                    lastEvent  = message;
                },
                EventId = eventId
            };

            target.Register(handler);
        }
Beispiel #4
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your fragment here
            var masterDB = GlobalsAndroid.GetMasterDBInstance();

            if (masterDB != null)
            {
                outletList = masterDB.GetOutletList();

                foreach (var item in outletList)
                {
                    var viewModel = new vwOutletListViewModel(item);
                    outletListViewModels.Add(viewModel);
                }

                SelectedIndex = -1;
            }

            var newEventHandler = new MessageBusEventHandler()
            {
                EventId     = "OutletListSort",
                EventAction = SortOutletListEventHandler
            };

            MessageBus.Default.Register(newEventHandler);

            var outletItemViewEventHandler = new MessageBusEventHandler()
            {
                EventId     = "OutletListItemViewAppeared",
                EventAction = OutletListItemViewAppearedEventHandler
            };

            MessageBus.Default.Register(outletItemViewEventHandler);
        }
Beispiel #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);

            ChangeTheme(Resource.Color.palette_blue_primary, Resource.Color.palette_blue_primary_dark);

            this.Title = "Home";

            var newEventHandler = new MessageBusEventHandler()
            {
                EventId     = "SyncFinished",
                EventAction = SyncFinishedEventHandler
            };

            MessageBus.Default.Register(newEventHandler);

            mNavigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            mNavigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);

                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_home:
                    ChangeTheme(Resource.Color.palette_blue_primary, Resource.Color.palette_blue_primary_dark);
                    ListItemClicked(0);
                    break;

                case Resource.Id.nav_outletlist:
                    ChangeTheme(Resource.Color.palette_green_primary, Resource.Color.palette_green_primary_dark);
                    ListItemClicked(1);
                    break;

                case Resource.Id.nav_uom:
                    ChangeTheme(Resource.Color.palette_teal_primary, Resource.Color.palette_teal_primary_dark);
                    ListItemClicked(2);
                    break;

                case Resource.Id.nav_sync:
                    ChangeTheme(Resource.Color.palette_blue_light_primary, Resource.Color.palette_blue_light_primary_dark);
                    ListItemClicked(3);
                    break;

                case Resource.Id.nav_about:
                    ChangeTheme(Resource.Color.palette_orange_primary, Resource.Color.palette_orange_primary_dark);
                    ListItemClicked(4);
                    break;

                case Resource.Id.nav_logout:
                    ListItemClicked(5);
                    break;
                }

                mDrawerLayout.CloseDrawers();
            };

            //if first time you will want to go ahead and click first item.
            if (savedInstanceState == null)
            {
                mNavigationView.Menu.GetItem(0).SetChecked(true);
                ListItemClicked(0);
            }
        }