Beispiel #1
0
        /// <summary>
        ///     The function to call when the twitter application is selected.
        /// </summary>
        /// <param name="name"> "Twitter app" </param>
        void ITvApp.ItemCallback(string name)
        {
            // Deactivate menu.
            menuFact.SetActiveMenu(null);

            Menu tweets = menuFact.CreateMenu(TvMenuFactory.Type.SOCIAL_MENU, "TwitterMenu");

            if (tweets != null)
            {
                // Show twitters
                TwitterInterface.GetTwitters(display.transform.parent.GetComponent <SmartTv>(), 20, (bool success, string response) => {
                    if (success)
                    {
                        TwitterResponse tresponse = JsonUtility.FromJson <TwitterResponse> (response);

                        // Print the tweets and their author.
                        for (int i = 0; i < tresponse.items.Length; ++i)
                        {
                            // display.transform.parent.GetComponent<SmartTv>().StartCoroutine(DownloadImage(tresponse.items[i].user.profile_background_image_url, image));

                            string [] fields   = { tresponse.items[i].user.name, tresponse.items[i].text };
                            Menu.MenuItem item = new Menu.MenuItem();
                            item.name          = "tweet" + i;
                            item.fields        = fields;
                            tweets.AddMenuItem(item, (string nm) => {});
                        }

                        menuFact.SetActiveMenu("TwitterMenu");
                    }
                    else
                    {
                        Debug.Log(response);
                    }
                });
            }
            else
            {
                menuFact.SetActiveMenu("TwitterMenu");
            }
        }