// Because the viewModel needs time to be created,
 // this method is called from two points
 private void ConfigureOptionMenu()
 {
     if (ViewModel != null && AddNewMenuItem != null)
     {
         AddNewMenuItem.SetVisible(!ViewModel.IsTimeEntryRunning);
     }
 }
        public async override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            // init viewModel
            ViewModel = LogTimeEntriesViewModel.Init();

            collectionBinding = this.SetBinding(() => ViewModel.Collection).WhenSourceChanges(() => {
                logAdapter = new LogTimeEntriesAdapter(recyclerView, ViewModel);
                recyclerView.SetAdapter(logAdapter);
            });
            hasMoreBinging  = this.SetBinding(() => ViewModel.HasMoreItems).WhenSourceChanges(SetFooterState);
            hasErrorBinding = this.SetBinding(() => ViewModel.HasLoadErrors).WhenSourceChanges(SetFooterState);
            hasItemsBinding = this.SetBinding(() => ViewModel.HasItems).WhenSourceChanges(SetCollectionState);
            fabBinding      = this.SetBinding(() => ViewModel.IsTimeEntryRunning, () => StartStopBtn.ButtonAction)
                              .ConvertSourceToTarget(isRunning => isRunning ? FABButtonState.Stop : FABButtonState.Start);

            newMenuBinding = this.SetBinding(() => ViewModel.IsTimeEntryRunning)
                             .WhenSourceChanges(() => {
                if (AddNewMenuItem != null)
                {
                    AddNewMenuItem.SetVisible(!ViewModel.IsTimeEntryRunning);
                }
            });

            // Pass ViewModel to TimerComponent.
            timerComponent.SetViewModel(ViewModel);
            StartStopBtn.Click += StartStopClick;
            SetupRecyclerView(ViewModel);

            // TODO: Review this line.
            // Get data to fill the list. For the moment,
            // until a screenloader is added to the screen
            // is better to load the items after create
            // the viewModel and show the loader from RecyclerView
            await ViewModel.LoadMore();

            // Subscribe to sync messages
            var bus = ServiceContainer.Resolve <MessageBus> ();

            drawerSyncFinished = bus.Subscribe <SyncFinishedMessage> (SyncFinished);
        }