예제 #1
0
        private async void MainPage_OnLoaded(object sender, RoutedEventArgs e)
        {
            ProgressRing.IsActive   = true;
            ProgressRing.Visibility = Visibility.Visible;

            for (int i = 15; i >= 1; i--)
            {
                await Task.Delay(1000);
            }

            ProgressRing.IsActive   = false;
            ProgressRing.Visibility = Visibility.Collapsed;

            try
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    List <string> contentList            = new List <string>();
                    List <NewsEntity.RootObject> newList = await ApiHandle.GetNews();

                    for (int i = 0; i < newList.Count; i++)
                    {
                        string removeHtml   = RemoveHtmlTag(newList[i].content.rendered);
                        var    splitContent = removeHtml.Split('.');
                        var    shortConent  = splitContent[0] + "." + splitContent[1] + "." + splitContent[2] + "." + splitContent[3];
                        newList[i].content.rendered = shortConent;
                        collection.Add(newList[i]);
                    }
                    NewsGridView.ItemsSource = collection;
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }