Exemplo n.º 1
0
 public static async Task AddChildren(SampleDataItem sditem, ObservableCollection <Comment> list)
 {
     foreach (var item in list)
     {
         sditem.aComments.Add(item);
         if (item.children != null && item.children.Count > 0)
         {
             await SampleDataSource.AddChildren(sditem, item.children);
         }
     }
     //sditem.Comments.Clear();
 }
Exemplo n.º 2
0
        public async Task ReadSRFromFileAsync(ProgressRing pr, StackPanel sp)
        {
            //subredditlistfile = await roamingFolder.CreateFileAsync("subreddits.txt", Windows.Storage.CreationCollisionOption.OpenIfExists);
            var    settings = Windows.Storage.ApplicationData.Current.RoamingSettings;
            string subs     = string.Empty;

            if (settings.Values.ContainsKey("localSubreddits"))
            {
                //settings.Values["localSubreddits"] = "";
                //settings.Values.Remove("localSubreddits");
                subs = (string)settings.Values["localSubreddits"];
            }
            else
            {
                settings.Values.Add("localSubreddits", "http://www.reddit.com/.json,http://www.reddit.com/r/Reddtro.json,http://www.reddit.com/r/wallpapers.json,http://www.reddit.com/r/Iama+askreddit.json,http://www.reddit.com/r/all.json");
                //subs = "reddtro,wallpapers,windows8";
                subs = "http://www.reddit.com/.json,http://www.reddit.com/r/Reddtro.json,http://www.reddit.com/r/wallpapers.json,http://www.reddit.com/r/Iama+askreddit.json,http://www.reddit.com/r/all.json";
            }

            string[] srs = subs.Split(',');


            foreach (var item in srs)
            {
                //await SampleDataSource.AddPage("http://www.reddit.com/r/"+item +".json");
                if (item == "http://www.reddit.com/.json")
                {
                    await SampleDataSource.AddHomePage();
                }
                else
                {
                    await SampleDataSource.AddPage(item);
                }
            }

            //login and fetch/add account-specific subreddits

            //await Data.SampleDataSource.accountManager.Login("juanpabl0", "onfire69");

            //JsonObject ps = await SampleDataSource.accountManager.makeJsonPageRequest("http://www.reddit.com/reddits/mine.json");
            //JsonArray ch = ps.GetNamedObject("data").GetNamedArray("children");
            //foreach (JsonObject item in ch)
            //{
            //    string baseUrl = "http://www.reddit.com";
            //    string sr = item.GetNamedObject("data").GetNamedString("url");
            //    string url = baseUrl + sr;
            //    await SampleDataSource.AddPage(url);
            //}

            pr.IsActive   = false;
            sp.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }