Ejemplo n.º 1
0
        private void AddPodcast(string groupId, Podcast podcast)
        {
            PodcastGroup group = GetGroup(groupId);

            if (group != null)
            {
                if (!group.Podcasts.Contains(podcast))
                {
                    group.Podcasts.Add(podcast);
                }
            }
        }
Ejemplo n.º 2
0
        public static PodcastGroup FromData(IServiceContext serviceContext, PodcastGroupData data)
        {
            PodcastGroup group = new PodcastGroup(serviceContext)
            {
                Id = data.Id
            };

            group.Podcasts = new ConcurrentObservableCollection <Podcast>(null, true);
            foreach (RoamingPodcastData podcastData in data.RoamingPodcastsData)
            {
                group.Podcasts.Add(Podcast.FromRoamingData(serviceContext, podcastData));
            }
            group.Podcasts.HoldNotifications = false;
            return(group);
        }
Ejemplo n.º 3
0
        public static Podcast FromRoamingData(IServiceContext serviceContext, RoamingPodcastData data)
        {
            Podcast podcast = new Podcast(serviceContext);

            podcast.Title      = data.Title;
            podcast.PodcastUri = data.Uri;
            ConcurrentObservableCollection <Episode> episodes = new ConcurrentObservableCollection <Episode>(s_EpisodeOrdering, true);

            podcast.Episodes = episodes;
            foreach (RoamingEpisodeData episodeData in data.RoamingEpisodesData)
            {
                episodes.Add(Episode.FromRoamingData(serviceContext, podcast.FileName, episodeData));
            }
            podcast.Episodes.HoldNotifications = false;
            return(podcast);
        }
Ejemplo n.º 4
0
        private async Task <bool> LoadPodcast(Podcast podcast)
        {
            try
            {
                await podcast.Load();

                await podcast.Store();

                return(true);
            }
            catch (Exception e)
            {
                Tracer.TraceInformation("Error loading {0}. {1}", podcast, e);
                return(false);
            }
        }
Ejemplo n.º 5
0
        public static Podcast FromData(IServiceContext serviceContext, PodcastData data)
        {
            Podcast podcast = new Podcast(serviceContext);

            podcast.Title                = data.Title;
            podcast.Description          = data.Description;
            podcast.Image                = data.Image;
            podcast.LastRefreshTimeTicks = data.LastRefreshTimeTicks;
            podcast.Episodes             = new ConcurrentObservableCollection <Episode>(s_EpisodeOrdering, true);
            foreach (EpisodeData episodeData in data.Episodes)
            {
                Episode episode = Episode.FromData(serviceContext, podcast.FileName, episodeData);
                podcast.Episodes.Add(episode);
            }
            podcast.Episodes.HoldNotifications = false;
            return(podcast);
        }
Ejemplo n.º 6
0
        public async Task <IEnumerable <Podcast> > Search(string searchTerm)
        {
            // this is the search term
            if (string.IsNullOrEmpty(searchTerm))
            {
                return(null);
            }

            IEnumerable <Podcast> matches;
            List <Podcast>        filtered;

            // RSS feed URL
            Uri validUri;

            if (Uri.TryCreate(searchTerm, UriKind.Absolute, out validUri) &&
                (validUri.Scheme == "http" || validUri.Scheme == "https"))
            {
                Podcast newItem = new Podcast(ServiceContext)
                {
                    PodcastUri = searchTerm
                };
                matches = new List <Podcast>()
                {
                    newItem
                };
            }
            else
            {
                // Search term
                matches = await m_Search.FindAsync(searchTerm, 50);
            }

            filtered = new List <Podcast>();
            foreach (Podcast podcast in matches)
            {
                if (!IsPodcastInFavorites(podcast))
                {
                    filtered.Add(podcast);
                }
            }

            return(filtered);
        }
Ejemplo n.º 7
0
        public Task Load(bool force)
        {
            Podcast podcast = new Podcast(ServiceContext)
            {
                Title       = "Podcast Title",
                Description = "Podcast Descirption"
            };
            PodcastGroup group = new PodcastGroup(ServiceContext)
            {
                Podcasts = new ConcurrentObservableCollection <Podcast>()
                {
                    podcast
                },
                Id        = "Favorites",
                TitleText = "Favorites"
            };

            m_Groups.Add(group);
            return(VoidTask.Completed);
        }
Ejemplo n.º 8
0
        public async Task <bool> AddToFavorites(Podcast podcast)
        {
            PodcastGroup favorites = GetGroup(Constants.FavoritesGroupId);

            if (favorites.Podcasts.Contains(podcast))
            {
                return(false);
            }

            PodcastGroup search = GetGroup(Constants.SearchGroupId);

            if (search.Podcasts.Contains(podcast))
            {
                search.Podcasts.Remove(podcast);
            }

            favorites.Podcasts.Add(podcast);
            await Store();

            return(await LoadPodcast(podcast));
        }
Ejemplo n.º 9
0
        public async Task Load()
        {
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;

            Tracer.TraceInformation("Podcast.Load(): {0} from {1}", Title, localFolder.Path);
            try
            {
                StorageFile file = null;
                try
                {
                    file = await localFolder.GetFileAsync(CacheFileName);
                }
                catch (FileNotFoundException)
                {
                    Tracer.TraceInformation("Can't find cache file {0} for podcast {1}", CacheFileName, Id);
                }
                if (file != null)
                {
                    TouchedFiles.Instance.Add(file.Path);
                    using (Stream stream = await file.OpenStreamForReadAsync())
                    {
                        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(PodcastData));
                        Podcast readPodcast = Podcast.FromData(ServiceContext, (PodcastData)serializer.ReadObject(stream));

                        await UpdateFields(readPodcast);
                    }
                }
                await RefreshFromRss(true);

                PruneEmptyEpisodes();
            }
            catch (Exception e)
            {
                Tracer.TraceInformation("Podcast.Load(): error loading {0}. {1}", CacheFileName, e);
            }
        }
Ejemplo n.º 10
0
 public bool IsPodcastInFavorites(Podcast podcast)
 {
     return(true);
 }
Ejemplo n.º 11
0
 public Task RemoveFromFavorites(Podcast podcast)
 {
     GetGroup("Favorites").Podcasts.Remove(podcast);
     return(Task.FromResult(true));
 }
Ejemplo n.º 12
0
 public Task <bool> AddToFavorites(Podcast podcast)
 {
     GetGroup("Favorites").Podcasts.Add(podcast);
     return(Task.FromResult(true));
 }
Ejemplo n.º 13
0
        public bool IsPodcastInFavorites(Podcast podcast)
        {
            PodcastGroup favorites = GetGroup(Constants.FavoritesGroupId);

            return(favorites.Podcasts.Contains(podcast));
        }