Exemple #1
0
        private void RemoveButton_Pressed(object sender, EventArgs e)
        {
            if (HeaderPicker.SelectedItem == null)
            {
                return;
            }

            var selectedItem = HeaderPicker.SelectedItem.ToString();

            SuggestionItems.Remove(selectedItem);
        }
Exemple #2
0
        private void AddItem()
        {
            string promptStr = string.Empty;

            switch (BoxType)
            {
            case SuggestionTypes.ActivityNames:
                promptStr = "Enter a new activity name";
                break;

            case SuggestionTypes.Emotions:
                promptStr = "Enter a new emotion";
                break;

            case SuggestionTypes.Locations:
                promptStr = "Enter a new location";
                break;

            case SuggestionTypes.MealNames:
                promptStr = "Enter a meal name";
                break;

            case SuggestionTypes.MealSizes:
                promptStr = "Enter a new meal size";
                break;

            case SuggestionTypes.MealTypes:
                promptStr = "Enter a new type of meal";
                break;

            case SuggestionTypes.SubstanceConsumptionMethods:
                promptStr = "Enter a new consumption method";
                break;

            case SuggestionTypes.SubstanceNames:
                promptStr = "Enter a new substance name";
                break;

            case SuggestionTypes.Units:
                promptStr = "Enter a new unit";
                break;

            case SuggestionTypes.SocializationTypes:
                promptStr = "How did you socialize?";
                break;
            }

            var userInput = "";

            SuggestionItems.Add(userInput);
            HeaderPicker.SelectedIndex = SuggestionItems.IndexOf(userInput);
        }
Exemple #3
0
        private void ScrollViewChanging2(object sender, ScrollViewerViewChangingEventArgs e)
        {
            try
            {
                if (SuggestionItems == null)
                {
                    return;
                }
                if (!SuggestionItems.Any())
                {
                    return;
                }
                ScrollViewer view = sender as ScrollViewer;

                double progress = view.VerticalOffset / view.ScrollableHeight;
                if (progress > 0.95 && IsLoading2 == false && !FirstRun2)
                {
                    IsLoading2 = true;
                    RunLoadMore2();
                }
            }
            catch (Exception ex) { ex.PrintException("ScrollViewChanging2"); }
        }
Exemple #4
0
        async Task LoadMoreItemsAsync2(bool refresh = false)
        {
            if (!HasMoreItems2 && !refresh)
            {
                IsLoading2 = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    Pagination2 = PaginationParameters.MaxPagesToLoad(1);
                    CloseFriendsView.Current?.ShowTopLoadingSuggestion();
                }
                else
                {
                    CloseFriendsView.Current?.ShowBottomLoadingSuggestion();
                }
                var result = await Helper.InstaApi.UserProcessor.GetBestFriendsSuggestionsAsync(Pagination);

                FirstRun2 = false;
                if (!result.Succeeded)
                {
                    IsLoading2 = false;
                    if (result.Value == null || result.Value?.Count == 0)
                    {
                        if (refresh)
                        {
                            CloseFriendsView.Current?.HideTopLoadingSuggestion();
                        }
                        else
                        {
                            CloseFriendsView.Current?.HideBottomLoadingSuggestion();
                        }
                        return;
                    }
                }

                if (string.IsNullOrEmpty(result.Value.NextMaxId))
                {
                    HasMoreItems2 = false;
                }

                Pagination2.NextMaxId = result.Value.NextMaxId;
                if (refresh)
                {
                    SuggestionItems.Clear();
                }
                var userIds = new List <long>();
                if (result.Value?.Count > 0)
                {
                    result.Value.ForEach(x =>
                    {
                        userIds.Add(x.Pk);
                        SuggestionItems.Add(x.ToUserShortFriendship());
                    });
                }
                await Task.Delay(1000);

                IsLoading2 = false;
            }
            catch (Exception ex)
            {
                FirstRun2      =
                    IsLoading2 = false;
                ex.PrintException("CloseFriendsViewModel.LoadMoreItemsAsync2");
            }

            if (refresh)
            {
                CloseFriendsView.Current?.HideTopLoadingSuggestion();
            }
            else
            {
                CloseFriendsView.Current?.HideBottomLoadingSuggestion();
            }
        }