Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Title = ((EventsViewModel)DataContext).GroupName;

            SetActivityContentView(Resource.Layout.Events, Resource.Id.events_layout);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SetUpProgressDialog(this, "Loading Events...");

            allEvents        = Settings.ShowAllEvents;
            ViewModel        = (EventsViewModel)DataContext;
            ListView         = FindViewById <ListView>(Resource.Id.eventsList);
            SearchView       = FindViewById <SearchView>(Resource.Id.events_searchview);
            EventAdapter     = new EventAdapter(this, ViewModel.Events);
            ListView.Adapter = EventAdapter;

            #region Events

            ListView.ItemClick += GoToEvent;

            SearchView.QueryTextChange += (s, e) => EventAdapter.Filter(e.NewText);
            SearchView.QueryTextSubmit += (s, e) => EventAdapter.Filter(e.Query);

            ViewModel.Events.CollectionChanged += (s, e) => EventAdapter.UpdateListView();


            ViewModel.FinishedFirstLoad += (index) =>
            {
                if (ViewModel.Events.Count == 0)
                {
                    return;
                }

                Timer timer = new Timer();
                timer.Interval = 1000;
                timer.Elapsed += (s, e) => RunOnUiThread(() => ListView.SetSelection(index));
            };

            #endregion
        }