コード例 #1
0
        public void listViewControllerHandleObject(ListViewController lvc, object obj)
        {
            // Make sure that we are getting the right object
            if (obj.GetType() != typeof(RSSChannel))
                return;

            channel = obj as RSSChannel;

            this.NavigationItem.Title = "Channel Info";

            this.TableView.ReloadData();
        }
コード例 #2
0
ファイル: BNRFeedStore.cs プロジェクト: yingfangdu/BNR
		// Top Songs Cache
//		public static DateTime topSongsCacheDate {
//			get {
//				return (DateTime)NSUserDefaults.StandardUserDefaults.ValueForKey(new NSString("topSongsCacheDate"));
//			}
//			set {
//				topSongsCacheDate = value;
//				NSUserDefaults.StandardUserDefaults.SetValueForKey(value, new NSString("topSongsCacheDate"));
//			}
//		}
			
		public static void FetchRSSFeed(Block completionBlock) // UITableViewController tvc)
		{
			channel = new RSSChannel();
			channel.type = "posts";
			items.Clear();

			string dbPath = GetDBPath();
			SQLiteConnection db;
			if (!File.Exists(dbPath)) {
				db = new SQLiteConnection(dbPath);
				db.CreateTable<RSSItem>();
				db.Close();
				db = null;
			}
			db = new SQLiteConnection(dbPath);
			items = db.Query<RSSItem>("SELECT * FROM RSSItems WHERE type='post' ORDER BY ID DESC");
			db.Close();
			db = null;

			FetchRSSAsync(completionBlock);
		}
コード例 #3
0
ファイル: BNRFeedStore.cs プロジェクト: vijeshrpillai/BNR
        // Top Songs Cache
//		public static DateTime topSongsCacheDate {
//			get {
//				return (DateTime)NSUserDefaults.StandardUserDefaults.ValueForKey(new NSString("topSongsCacheDate"));
//			}
//			set {
//				topSongsCacheDate = value;
//				NSUserDefaults.StandardUserDefaults.SetValueForKey(value, new NSString("topSongsCacheDate"));
//			}
//		}

        public static void FetchRSSFeed(Block completionBlock)         // UITableViewController tvc)
        {
            channel      = new RSSChannel();
            channel.type = "posts";
            items.Clear();

            string           dbPath = GetDBPath();
            SQLiteConnection db;

            if (!File.Exists(dbPath))
            {
                db = new SQLiteConnection(dbPath);
                db.CreateTable <RSSItem>();
                db.Close();
                db = null;
            }
            db    = new SQLiteConnection(dbPath);
            items = db.Query <RSSItem>("SELECT * FROM RSSItems WHERE type='post' ORDER BY ID DESC");
            db.Close();
            db = null;

            FetchRSSAsync(completionBlock);
        }
コード例 #4
0
ファイル: BNRFeedStore.cs プロジェクト: yingfangdu/BNR
		// Get Apple JSON rss feed
		public static async void FetchRSSFeedTopSongs(int count, Block completionBlock) // UITableViewController tvc)
		{
			using (var wc = new WebClient()) {
				string url = String.Format("http://itunes.apple.com/us/rss/topsongs/limit={0}/json", count);
				channel = new RSSChannel();
				channel.type = "songs";
				items.Clear();

				// Top Songs Cache
//				string dbPath = GetDBPath();
//				SQLiteConnection db;
//				if (!File.Exists(dbPath)) {
//					db = new SQLiteConnection(dbPath);
//					db.CreateTable<RSSItem>();
//					db.Close();
//					db = null;
//				}
//				//db = new SQLiteConnection(dbPath);
//				//items = db.Query<RSSItem>("SELECT * FROM RSSItems WHERE type='song'");
//
//				NSDate tscDate = topSongsCacheDate;
//				if (tscDate != null) {
//					NSTimeInterval cacheAge = tscDate.SecondsSinceReferenceDate;
//				}
//
				// End Top Songs Cache

				try {
					string JSONData = await wc.DownloadStringTaskAsync(new Uri(url));
					JObject parsedJSONData = JObject.Parse (JSONData);

					channel.parseJSON(parsedJSONData);

					var entries = parsedJSONData["feed"]["entry"];

					foreach (var entry in entries) {
						RSSItem item = new RSSItem();

						item.parseJSON(entry);
						item.type = "song";

						items.Add(item);
					}

					completionBlock("success");
				}
				catch (WebException ex) {
					completionBlock(ex.Message);
				}
			}
		}
コード例 #5
0
ファイル: BNRFeedStore.cs プロジェクト: vijeshrpillai/BNR
        // Get Apple JSON rss feed
        public static async void FetchRSSFeedTopSongs(int count, Block completionBlock)         // UITableViewController tvc)
        {
            using (var wc = new WebClient()) {
                string url = String.Format("http://itunes.apple.com/us/rss/topsongs/limit={0}/json", count);
                channel      = new RSSChannel();
                channel.type = "songs";
                items.Clear();

                // Top Songs Cache
//				string dbPath = GetDBPath();
//				SQLiteConnection db;
//				if (!File.Exists(dbPath)) {
//					db = new SQLiteConnection(dbPath);
//					db.CreateTable<RSSItem>();
//					db.Close();
//					db = null;
//				}
//				//db = new SQLiteConnection(dbPath);
//				//items = db.Query<RSSItem>("SELECT * FROM RSSItems WHERE type='song'");
//
//				NSDate tscDate = topSongsCacheDate;
//				if (tscDate != null) {
//					NSTimeInterval cacheAge = tscDate.SecondsSinceReferenceDate;
//				}
//
                // End Top Songs Cache

                try {
                    string JSONData = await wc.DownloadStringTaskAsync(new Uri(url));

                    JObject parsedJSONData = JObject.Parse(JSONData);

                    channel.parseJSON(parsedJSONData);

                    var entries = parsedJSONData["feed"]["entry"];

                    foreach (var entry in entries)
                    {
                        RSSItem item = new RSSItem();

                        try
                        {
                            item.parseJSON(entry);
                            item.type = "song";
                            items.Add(item);
                        }
                        catch (Exception ex) {
                            Console.WriteLine("Exception: {0}", ex);
                            if (ex.Message == "Accessed JObject values with invalid key value: 1. Object property name expected.")
                            {
                                Console.WriteLine("iTunes song does not have preview link. Not showing it in list.");
                            }
                        }
                    }

                    completionBlock("success");
                }
                catch (WebException ex) {
                    completionBlock(ex.Message);
                }
            }
        }