Пример #1
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try{
                var httpClient     = new HttpClient();
                var feed           = "http://feeds.hanselman.com/ScottHanselman";
                var responseString = await httpClient.GetStringAsync(feed);

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var item in items)
                {
                    FeedItems.Add(item);
                }
            } catch (Exception ex) {
                var page   = new ContentPage();
                var result = page.DisplayAlert("Error", "Unable to load blog.", "OK", null);
            }

            IsBusy = false;
        }
Пример #2
0
        /// <summary>
        ///     Adds an item to the feed
        /// </summary>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public void AddItem(Color color, string text)
        {
            var item = new MultiplayerFeedItem(color, text)
            {
                Parent    = this,
                Alignment = Alignment.BotLeft,
                X         = 10
            };

            FeedItems.Add(item);

            if (FeedItems.Count == 6)
            {
                var first = FeedItems.First();
                first.Destroy();
                FeedItems.Remove(first);
            }

            for (var i = FeedItems.Count - 1; i >= 0; i--)
            {
                var feedItem = FeedItems[i];

                feedItem.ClearAnimations();
                feedItem.MoveToY(-22 * (FeedItems.Count - i - 1) - 11, Easing.OutQuint, 200);
            }
        }
Пример #3
0
        public async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            var httpClient = new HttpClient();

            try
            {
                var feed           = "https://www.lebensmittelwarnung.de/bvl-lmw-de/opensaga/feed/alle/alle_bundeslaender.rss";
                var responseString = await httpClient.GetStringAsync(feed);

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var item in items)
                {
                    item.Image = item.ImageURL;
                    FeedItems.Add(item);
                }
            }
            catch (Exception e)
            {
            }



            IsBusy = false;
        }
Пример #4
0
        private async Task ExecuteLoadFilteredItemsCommand(string filter)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                FeedItems.Clear();

                var items = await _feedRepository.GetFilteredFeed(StaticData.RssFeed, filter);

                foreach (var item in items)
                {
                    FeedItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                var page   = new ContentPage();
                var result = page.DisplayAlert("Error", "Unable to load filtered podcast feed. " + ex.Message, "OK");

                Insights.Report(ex, new Dictionary <string, string> {
                    { "Error", "Unable to load filtered podcast feed." },
                    { "Message", ex.Message },
                    { "Result", result.ToString() }
                });
            }

            IsBusy = false;
        }
        public async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            var httpClient     = new HttpClient();
            var feed           = "http://planet.xamarin.com/feed/";
            var responseString = await httpClient.GetStringAsync(feed);

            FeedItems.Clear();
            var items = await ParseFeed(responseString);

            foreach (var item in items)
            {
                item.Image = Gravatar.GetUrl(item.Author);
                FeedItems.Add(item);
            }


            IsBusy = false;
        }
Пример #6
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            var error = false;

            try
            {
                var httpClient = new HttpClient();
                var feed       = string.Empty;

                switch (item.MenuType)
                {
                case MenuType.Hanselminutes:
                    feed = "http://feeds.podtrac.com/9dPm65vdpLL1";
                    break;

                case MenuType.Ratchet:
                    feed = "http://feeds.feedburner.com/RatchetAndTheGeek?format=xml";
                    break;

                case MenuType.DeveloperLife:
                    feed = "http://feeds.feedburner.com/ThisDevelopersLife?format=xml";
                    break;
                }
                var responseString = await httpClient.GetStringAsync(feed);

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var feedItem in items)
                {
                    FeedItems.Add(feedItem);
                }
            }
            catch
            {
                error = true;
            }

            if (error)
            {
                var page   = new ContentPage();
                var result = page.DisplayAlert("Error", "Unable to load podcast feed.", "OK");
            }


            IsBusy = false;
        }
        private async Task ExecuteLoadItemsCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            bool error = false;

            try
            {
                HttpClient httpClient = new HttpClient();
                string     feed       = string.Empty;
                switch (item)
                {
                case MenuType.Playlist:
                    feed = @"https://software-enginnering-daily-api.herokuapp.com/api/posts";
                    break;

                case MenuType.Podcast:
                    feed = @"https://software-enginnering-daily-api.herokuapp.com/api/posts";
                    break;

                case MenuType.Twitter:
                    feed = @"https://feeds.podtrac.com/9dPm65vdpLL1";
                    break;
                }

                string responseString = await httpClient.GetStringAsync(feed);

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var feedItem in items)
                {
                    FeedItems.Add(feedItem);
                }
            }
            catch (Exception e)
            {
                error = true;
                Debug.WriteLine(e.Message);
            }

            if (error)
            {
                ContentPage page   = new ContentPage();
                Task        result = page.DisplayAlert("Error", $"Unable to load podcast feed.", "OK");
            }

            IsBusy = false;
        }
Пример #8
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy    = true;
            IsNotBusy = false;

            try
            {
                FeedItems.Clear();

                var items = await _feedRepository.GetAll(StaticData.RssFeed);

                foreach (var item in items)
                {
                    FeedItems.Add(item);
                }

                LastFeedItem = FeedItems[0];

                PodcastTitle = LastFeedItem.Title;
                PodcastDate  = LastFeedItem.PublishDate;

                if (LastFeedItem.FileImage != null)
                {
                    FileImage = LastFeedItem.FileImage;
                }
                else
                {
                    FileImage = "empty_image.png";
                }
            }
            catch (Exception ex)
            {
                var page   = new ContentPage();
                var result = page.DisplayAlert("Error", "Unable to load podcast feed. " + ex.Message, "OK");

                Insights.Report(ex, new Dictionary <string, string> {
                    { "Error", "Unable to load podcast feed." },
                    { "Message", ex.Message },
                    { "Result", result.ToString() }
                });
            }

            IsBusy    = false;
            IsNotBusy = true;
        }
Пример #9
0
        private void LoadAction()
        {
            FeedItems?.Clear();
            SelectedFeedItem = null;

            using (XmlReader reader = XmlReader.Create(FeedURL))
            {
                SyndicationFeed feed = SyndicationFeed.Load(reader);

                //Next step, getting Images from Comic feeds/etc.
                foreach (SyndicationItem item in feed.Items)
                {
                    FeedItems.Add(FeedItemModel.FromSyndicationItem(item));
                }
            }

            OnPropertyChanged(nameof(FeedItems));
        }
Пример #10
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            var error = false;

            try
            {
                var responseString = string.Empty;
                //TODO: get feed and
                //using (var httpClient = new HttpClient())
                //{
                //	var feed = "http://feeds.hanselman.com/ScottHanselman";
                //	responseString = await httpClient.GetStringAsync(feed);
                //}

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var item in items)
                {
                    FeedItems.Add(item);
                }
            }
            catch
            {
                error = true;
            }

            if (error)
            {
                var page = new ContentPage();
                await page.DisplayAlert("Error", "Unable to load blog.", "OK");
            }

            IsBusy = false;
        }
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            var error = false;

            try
            {
                var responseString = string.Empty;
                using (var httpClient = new HttpClient())
                {
                    var feed = "http://lawebdelprogramador.cl/bloglawebdelprogramador/feed/";
                    responseString = await httpClient.GetStringAsync(feed);
                }

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var item in items)
                {
                    FeedItems.Add(item);
                }
            }
            catch
            {
                error = true;
            }

            if (error)
            {
                var page = new ContentPage();
                await page.DisplayAlert("Error", "No es posible cargar el blog en este momento", "OK");
            }

            IsBusy = false;
        }
Пример #12
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            var error = false;

            try
            {
                var responseString = string.Empty;
                using (var httpClient = new HttpClient())
                {
                    var feed = "https://bwired.ca/blog/feed";
                    responseString = await httpClient.GetStringAsync(feed);
                }

                FeedItems.Clear();
                var items = await ParseFeed(responseString);

                foreach (var item in items)
                {
                    FeedItems.Add(item);
                }
            }
            catch
            {
                error = true;
            }

            if (error)
            {
                var page = new ContentPage();
                await page.DisplayAlert("Error", "Unable to load blog.", "OK");
            }

            IsBusy = false;
        }
Пример #13
0
        /// <summary>
        /// Adds feedItems to the list of feedItems.
        /// All feedItems are inserted at the correct date (since the list is sorted by date)
        /// </summary>
        /// <param name="feedItems">List of feedItems to be added</param>
        private void AddFeedItems(List <EasyNewsFeedItem> feedItems)
        {
            var counter = 0;

            foreach (var article in feedItems)
            {
                // New Article is older than the oldest article in the list, append article to end
                if (counter >= FeedItems.Count)
                {
                    FeedItems.Add(article);
                }
                // Insert new Article somewhere in the middle of the array, we don't know where it is
                else
                {
                    // Iterate through Articles until we found the right date to insert our new article
                    while (counter < FeedItems.Count &&
                           FeedItems[counter].PublishingDate > article.PublishingDate)
                    {
                        counter++;
                    }
                    // All articles we searched were newer than our article => Append the article
                    if (counter == FeedItems.Count)
                    {
                        FeedItems.Add(article);
                    }
                    else
                    {
                        // Found the right date, insert the article, redo with the next one
                        FeedItems.Insert(counter, article);
                    }
                }
            }
            // ReSharper Disable All
            OnPropertyChanged("HasFeedItems");
            // ReSharper Restore All
        }
Пример #14
0
		private async Task _Refresh()
		{
			if (!IsNeedRefresh) { return; }

			Debug.WriteLine($"{Label} starting update feed.");

			var updateTime = DateTime.Now;
			var latestItems = new List<FeedItem>();
			foreach (var feedSource in _FeedSourceList)
			{
				var items = await feedSource.GetLatestItems(HohoemaApp);
				foreach (var item in items)
				{
					latestItems.Add(item);
				}
			}


			var latestOrderedItems = latestItems
				.OrderByDescending(x => x.SubmitDate)
				.Take(MaxFeedItemsCount)
				.ToList();

			foreach (var item in latestOrderedItems)
			{
				item.CheckedTime = updateTime;
			}

			var exceptItems = latestOrderedItems.Except(FeedItems, FeedItemComparer.Default).ToList();

			var addedItems = exceptItems.Where(x => x.CheckedTime == updateTime);

			var removedItems = FeedItems
				.Except(latestOrderedItems, FeedItemComparer.Default)
				.Where(x => x.CheckedTime != updateTime)
				.ToList();


			foreach (var addItem in addedItems)
			{
				addItem.IsUnread = true;

				// 投稿日時が初期化されていない場合はThumbnailInfoから拾ってくる

				// ユーザー動画取得の場合に投稿時刻が取れないことが原因
				// 追加されたアイテムだけのThumbnailを取得することで無駄な処理を減らす
				if (addItem.SubmitDate == default(DateTime))
				{
					try
					{
						var nicoVideo = await HohoemaApp.MediaManager.GetNicoVideoAsync(addItem.VideoId);
						
						addItem.SubmitDate = nicoVideo.PostedAt;
					}
					catch (Exception ex)
					{
						Debug.Fail("UserFeedItem 更新中、NicoVideoオブジェクトの取得に失敗しました。", ex.Message);
					}
				}
				

				FeedItems.Add(addItem);
			}

			foreach (var removedItem in removedItems)
			{
				var item = FeedItems.SingleOrDefault(x => x.VideoId == removedItem.VideoId);
				if (item != null)
				{
					item.IsDeleted = true;
					FeedItems.Remove(item);
				}

			}

			FeedItems.Sort(FeedItemComparer.Default);

			UpdateTime = updateTime;

			await FeedManager.SaveOne(this);

            Completed?.Invoke(this);

            IsNeedRefresh = false;

			Debug.WriteLine($"{Label} update feed done.");
		}
Пример #15
0
        // RSSフィードを取得します。(非同期メソッド)
        private async Task GetRSSAsync(String i_feedUrl)
        {
            Boolean result = false;

            try
            {
                var     client = new HttpClient();
                RssFeed latest;

                using (var reader = new StringReader(await client.GetStringAsync(i_feedUrl)))
                {
                    var desirializer = new XmlSerializer(typeof(RssFeed));
                    latest = desirializer.Deserialize(reader) as RssFeed;
                }

                IsProgress = false;

                if (latest == null)
                {
                    throw new Exception("取得したフィードがnull");
                }

                // RSSフィードの配信元情報を取得します。
                this.FeedTitle           = latest.Channel.Title;
                this.FeedDescription     = Regex.Replace(latest.Channel.Description, Define.PATTERN_STR, String.Empty, RegexOptions.Singleline);
                this.FeedLastUpdatedTime = latest.Channel.LastBuildDate;

                // RSSフィードのコンテンツを取得します。
                foreach (var item in latest.Channel.Items)
                {
                    // コンテンツ取得
                    RSSContent content = new RSSContent();
                    content.Title       = item.Title;
                    content.Description = Regex.Replace(item.Description, Define.PATTERN_STR, String.Empty, RegexOptions.Singleline);
                    content.PubDate     = item.PubDate;
                    content.Link        = item.Link;

                    // サムネイル画像取得
                    var imgMatch = Regex.Match(item.Description, Define.PATTERN_IMGTAG, RegexOptions.Singleline);
                    if (imgMatch.Success)
                    {
                        content.Thumbnail = ImageSource.FromUri(new Uri(imgMatch.Groups["uri"].Value));
                    }

                    Device.BeginInvokeOnMainThread(() => FeedItems.Add(content));

                    //FeedItems.Add(new RSSContent
                    //{
                    //    Title = item.Title,
                    //    Description = Regex.Replace(item.Description, Define.PATTERN_STR, String.Empty, RegexOptions.Singleline),
                    //    PubDate = item.PubDate,
                    //    Link = item.Link
                    //});
                }

                // RSSフィードの取得が完了したことをView側に通知します。
                // ※通知の引数にRSSフィード取得の結果を渡す
                GetRSSCompleted?.Invoke(this, new TaskResultEventArgs(result));
            }
            catch (Exception ex)
            {
                // RSSフィードの取得中に例外が発生したら、失敗フラグを立てます。
                result = false;
            }
        }
Пример #16
0
 public void addFeedItem(FeedItem newItem)
 {
     FeedItems.Add(newItem);
 }