コード例 #1
0
ファイル: TvCore.cs プロジェクト: ldj-droid/FoxIPTV
        /// <summary>Load the favorite data from the user storage location</summary>
        private static void FavoritesLoad()
        {
            var favoriteChannelsFilePath = Path.Combine(UserStoragePath, ChannelFavoritesFilename);

            if (!File.Exists(favoriteChannelsFilePath))
            {
                return;
            }

            LogInfo($"[TVCore] FavoritesLoad(): Loading channelIndex favorites file: {favoriteChannelsFilePath}");

            var rawJson = File.ReadAllText(favoriteChannelsFilePath);

            if (string.IsNullOrWhiteSpace(rawJson))
            {
                return;
            }

            ChannelFavorites.Clear();

            try
            {
                ChannelFavorites.AddRange(JsonConvert.DeserializeObject <List <string> >(rawJson));
            }
            catch (Exception e)
            {
                LogError($"[TVCore] FavoritesLoad(): Error parsing channelIndex favorites file... {e.Message}");
                return;
            }

            LogDebug($"[TVCore] FavoritesLoad(): Loaded {ChannelFavorites.Count} channelIndex favorites");
        }
コード例 #2
0
ファイル: TvCore.cs プロジェクト: ldj-droid/FoxIPTV
        /*
         * public static void AddFavoriteChannels(IEnumerable<string> channelIds)
         * {
         *  LogDebug("[TVCore] AddFavoriteChannels()");
         *
         *  ChannelFavorites.Clear();
         *  ChannelFavorites.AddRange(channelIds);
         *
         *  FavoritesSave();
         * }
         */

        /// <summary>Remove a favorite channel using the channel string based ID</summary>
        /// <param name="channelId">A string based key for the channel to un-favorite</param>
        public static void RemoveFavoriteChannel(string channelId)
        {
            LogDebug($"[TVCore] RemoveFavoriteChannel({channelId})");

            if (ChannelFavorites.Contains(channelId))
            {
                ChannelFavorites.Remove(channelId);
            }

            FavoritesSave();
        }
コード例 #3
0
ファイル: TvCore.cs プロジェクト: ldj-droid/FoxIPTV
        /// <summary>Add a favorite channel using the channel string based ID</summary>
        /// <param name="channelId">A string based key for the channel to favorite</param>
        public static void AddFavoriteChannel(string channelId)
        {
            LogDebug($"[TVCore] AddFavoriteChannel({channelId})");

            if (!ChannelFavorites.Contains(channelId))
            {
                ChannelFavorites.Add(channelId);
            }

            FavoritesSave();
        }