예제 #1
0
        private async void sChanged(object sender, ScrollViewerViewChangedEventArgs sve)
        {
            await Task.Run(async() =>
            {
                ScrollViewer sv = (ScrollViewer)sender;
                //Debug.WriteLine(sv.ScrollableHeight + " , " + sv.VerticalOffset);

                if (sv.VerticalOffset >= sv.ScrollableHeight - 2000 && !loading)
                {
                    loading = true;
                    /*App.Progress.IsActive = true;
                    App.Progress.Visibility = Windows.UI.Xaml.Visibility.Visible;*/

                    FacebookClient _fb = new FacebookClient(session.accessToken);
                    dynamic parameters = new ExpandoObject();
                    parameters.access_token = session.accessToken;
                    dynamic result = null;

                    try
                    {
                        result = await _fb.GetTaskAsync(nextPage, parameters);
                    }
                    catch (FacebookOAuthException e)
                    {
                        Debug.WriteLine("Problem: " + e.StackTrace);
                        /*App.Progress.IsActive = false;
                        App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;*/
                        loading = false;
                        return;
                    }

                    var friendResult = (IDictionary<string, object>)result;
                    var data = (IEnumerable<object>)friendResult["data"];

                    foreach (var item in data)
                    {
                        var posts = (IDictionary<string, object>)item;
                        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            FacebookPost post = new FacebookPost(posts, session.userSession);
                            feedStack.Children.Add(post);
                        });

                    }

                    Debug.WriteLine(friendResult + "\n\n" + nextPage);

                    nextPage = (String)((IDictionary<string, object>)friendResult["paging"])["next"];

                    /*App.Progress.IsActive = false;
                    App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;*/
                    loading = false;
                }
            });
        }
예제 #2
0
        public async void FbFeed(ListItemTemplate session)
        {
            FacebookClient _fb = new FacebookClient(session.accessToken);
            dynamic parameters = new ExpandoObject();
            parameters.access_token = session.accessToken;

            dynamic result = null;

            try{
                result = await _fb.GetTaskAsync("me/home", parameters);
            }
            catch (FacebookOAuthException e)
            {
                Debug.WriteLine("Problem: \n" + e.Message);
                App.Progress.IsActive = false;
                App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                return;
            }

            var friendResult = (IDictionary<string, object>)result;
            var data = (IEnumerable<object>)friendResult["data"];

            FacebookFeed fbFeed = new FacebookFeed(session);

            foreach (var item in data)
            {
                var posts = (IDictionary<string, object>)item;

                FacebookPost post = new FacebookPost(posts, session.userSession);

                fbFeed.feedStack.Children.Add(post);
            }

            fbFeed.nextPage = (String)((IDictionary<string, object>)friendResult["paging"])["next"];
            fbFeed.previousPage = (String)((IDictionary<string, object>)friendResult["paging"])["previous"];

            await Task.Run(() => { fbFeed.realtimeUpdate(); });
            await Task.Run(() => { fbFeed.timeUpdate(); });

            rightPane.Children.Add(fbFeed);
            App.Progress.IsActive = false;
            App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            
        }
예제 #3
0
        internal async void realtimeUpdate()
        {
            while (App.running)
            {
                await Task.Delay(TimeSpan.FromSeconds(5));

                try
                {
                    dynamic parameters = new ExpandoObject();
                    parameters.access_token = session.accessToken;

                    dynamic result = null;

                    try
                    {
                        result = await session.userSession._fb.GetTaskAsync(previousPage, parameters);
                    }
                    catch (FacebookOAuthException e)
                    {
                        Debug.WriteLine("Problem: \n" + e.Message);
                        App.Progress.IsActive = false;
                        App.Progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                        return;
                    }


                    var friendResult = (IDictionary<string, object>)result;
                    var data = (IEnumerable<object>)friendResult["data"];

                    int i = 0;
                    foreach (var item in data)
                    {
                       var posts = (IDictionary<string, object>)item;
                        FacebookPost post = null;
                        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => 
                        { post = new FacebookPost(posts, session.userSession);
                        this.feedStack.Children.Insert(i, post);
                        });
                        i++;
                    }

                    previousPage = (String)((IDictionary<string, object>)friendResult["paging"])["previous"];
                }
                catch (Exception e)
                {
                }
            }
        }