示例#1
0
        public async void GetRecentSearches()
        {
            try
            {
                RecentSearchesAdded = false;
                Views.Searches.SearchView.Current?.ShowTopLoadingTop();
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    var result = await InstaApi.DiscoverProcessor.GetRecentSearchesAsync();
                    if (result.Succeeded)
                    {
                        AccountSearchesPrivate.Clear();
                        HashtagSearchesPrivate.Clear();
                        AccountSearches.Clear();
                        RecentSearches.Clear();
                        RecentSearches.AddRange(result.Value.Recent);
                        if (TopItems.Count > 0)
                        {
                            AddRecentSearches();
                            if (result.Value.Recent.Count > 0)
                            {
                                var xxx = result.Value.Recent.Where(a => !a.IsHashtag).Select(b => b.User).ToList();
                                xxx.ForEach(tx => AccountSearchesPrivate.Add(tx.ToUser()));
                                AccountSearches.AddRange(AccountSearchesPrivate);
                            }
                            if (result.Value.Recent.Count > 0)
                            {
                                var xxx = result.Value.Recent.Where(a => a.IsHashtag).Select(b => b.Hashtag.ToHashtag()).ToList();
                                xxx.ForEach(tx => HashtagSearchesPrivate.Add(tx));
                                HashtagSearches.AddRange(HashtagSearchesPrivate);
                            }
                        }
                    }

                    Views.Searches.SearchView.Current?.HideTopLoadingTop();
                });
            }
            catch { Views.Searches.SearchView.Current?.HideTopLoadingTop(); }
        }
示例#2
0
        private void HashtagScrollViewerViewChanging(object sender, ScrollViewerViewChangingEventArgs e)
        {
            try
            {
                if (HashtagSearches == null)
                {
                    return;
                }
                if (!HashtagSearches.Any())
                {
                    return;
                }
                ScrollViewer view = sender as ScrollViewer;

                double progress = view.VerticalOffset / view.ScrollableHeight;
                if (progress > 0.95 && IsHashtagLoading == false)
                {
                    IsHashtagLoading = true;
                    SearchTags(TagSearch);
                }
            }
            catch (Exception ex) { ex.PrintException("HashtagScrollViewerViewChanging"); }
        }
示例#3
0
        public async void SearchTags(string text = null)
        {
            var has = ExcludeTagsList.Any();

            try
            {
                if (text.Contains("@"))
                {
                    text = text.Replace("@", "");
                }
                if (text.Contains("#"))
                {
                    text = text.Replace("#", "");
                }
                text = text.ToLower();
                if (TagSearch != text)
                {
                    MoreTagAvailable = true;
                    ExcludeTagsList.Clear();
                }
                TagSearch = text;
                if (!MoreTagAvailable)
                {
                    return;
                }
                has = ExcludeTagsList.Any();
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    HashtagSearches.Clear();
                    if (!has)
                    {
                        Views.Searches.SearchView.Current?.ShowTopLoadingTag();
                    }
                    else
                    {
                        Views.Searches.SearchView.Current?.ShowBottomLoadingTag();
                    }
                    var result = await InstaApi.HashtagProcessor.SearchHashtagAsync(text, ExcludeTagsList);
                    if (result.Succeeded)
                    {
                        if (result.Value.Count > 0)
                        {
                            HashtagSearches.AddRange(result.Value);
                            result.Value.ForEach(x => ExcludeTagsList.Add(x.Id));
                        }
                        MoreTagAvailable = result.Value.MoreAvailable;
                    }
                    if (!has)
                    {
                        Views.Searches.SearchView.Current?.HideTopLoadingTag();
                    }
                    else
                    {
                        Views.Searches.SearchView.Current?.HideBottomLoadingTag();
                    }
                });
            }
            catch
            {
                if (!has)
                {
                    Views.Searches.SearchView.Current?.HideTopLoadingTag();
                }
                else
                {
                    Views.Searches.SearchView.Current?.HideBottomLoadingTag();
                }
            }
            IsHashtagLoading = false;
        }