Example #1
0
        private void GetItemSource()
        {
            UserDialogs.Instance.ShowLoading();
            AppModel.Instance.CurrentUser.FavoriteEvents.ClearData();
            DynamicListData <EventData> allEvents = new DynamicListData <EventData>();

            if (!(AppModel.Instance.PayedEvents.Items.Count > 0) || !(AppModel.Instance.FreeEvents.Items.Count > 0))
            {
                var task1 = new DownloadEventsDataBackgroundTask(true, AppModel.Instance.FreeEvents);
                var task2 = new DownloadEventsDataBackgroundTask(false, AppModel.Instance.PayedEvents);
                task1.Execute();
                task2.Execute();
            }


            allEvents.UpdateData(AppModel.Instance.PayedEvents.Items);
            allEvents.UpdateData(AppModel.Instance.FreeEvents.Items);

            foreach (FavouriteEventData fed in AppModel.Instance.CurrentUser.FavouriteActions.Items)
            {
                EventData ed = null;

                ed = allEvents.Find(fed.EventId);
                if (ed != null)
                {
                }
                AppModel.Instance.CurrentUser.FavoriteEvents.AddOne(ed);
            }
            UserDialogs.Instance.HideLoading();
            FavEventListWrapper = new EventsDataWrapper(AppModel.Instance.CurrentUser.FavoriteEvents);
        }
Example #2
0
        public void DownloadEventsData(bool isFree, Action onFinish)
        {
            DynamicListData <EventData> events = isFree ? AppModel.Instance.FreeEvents :
                                                 AppModel.Instance.PayedEvents;

            var task = new DownloadEventsDataBackgroundTask(isFree, events);

            task.ContinueWith((ttask, tresult) => Device.BeginInvokeOnMainThread(onFinish));
            if (isFree)
            {
                _backgroundWorkers[AppBackgroundWorkerType.DownloadFreeEvents].Add(task);
            }
            else
            {
                _backgroundWorkers[AppBackgroundWorkerType.DownloadPayedEvents].Add(task);
            }
        }