Esempio n. 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);
        }
Esempio n. 2
0
        public WallPostLikersPage(WallPost postData)
        {
            Title           = AppResources.WallLikes;
            BackgroundColor = AppResources.WallPageBackgroundColor;

            var likes = new DynamicListData <WallPostLike>();

            likes.UpdateData(AppModel.Instance.GetWallPostLikes(postData));
            DataWrapper = new WallPostLikesWrapper(likes);

            var wrapper = new WallPostLikersWrapper(DataWrapper, postData);

            _likersListView = new ListView {
                HasUnevenRows       = false,
                RowHeight           = 60,
                ItemTemplate        = new DataTemplate(typeof(UserCell)),
                SeparatorVisibility = SeparatorVisibility.None,
                BackgroundColor     = Color.Transparent,
                ItemsSource         = DataWrapper,

                RefreshCommand         = wrapper.RefreshCommand,
                IsPullToRefreshEnabled = true,
                BindingContext         = wrapper
            };

            _likersListView.SetBinding <WallPostLikersWrapper> (ListView.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay);

            Content = new ContentView {
                Content = _likersListView,
                Padding = new Thickness(10, 10, 10, 0)
            };
        }
        protected void UpdateData(RootListData <T> data)
        {
            if (data != null)
            {
                Result.AddRange(data.Data);

                if (DynamicList != null)
                {
                    DynamicList.UpdateData(data.Data);
                }

                if (TaskParameters.IsSaveToDb)
                {
                    DbClient.Instance.SaveData <T> (data.Data).ConfigureAwait(false);
                }

                OnSaveData(data.Data);
            }
        }
Esempio n. 4
0
        protected override void OnResult(UserVoteData result)
        {
            if (result != null)
            {
                if (string.IsNullOrEmpty(result.Id))
                {
                    result.Id = UserVoteData.Id;
                }
                else if (string.IsNullOrEmpty(UserVoteData.Id))
                {
                    UserVoteData.Id = result.Id;
                }

                ListData.UpdateData(new List <UserVoteData> {
                    result
                });
                DbClient.Instance.SaveItemData <UserVoteData> (IsPostQuery ? result : UserVoteData).ConfigureAwait(false);
            }
        }