Beispiel #1
0
                public override void OnClick(Android.App.Fragment source, int buttonId, object context = null)
                {
                    // only handle input if the springboard is closed
                    if (NavbarFragment.ShouldTaskAllowInput( ))
                    {
                        // if the main page had a VALID news item clicked, go to it
                        if (source == MainPage && buttonId < News.Count)
                        {
                            // mark that they tapped this item.
                            NewsAnalytic.Instance.Trigger(NewsAnalytic.Read, MainPage.News[buttonId].News.Title);

                            // either take them to the details page, or skip it and go straight to Learn More.
                            if (MainPage.News[buttonId].News.SkipDetailsPage == true && string.IsNullOrEmpty(MainPage.News[buttonId].News.ReferenceURL) == false)
                            {
                                if (Springboard.IsAppURL(MainPage.News[buttonId].News.ReferenceURL) == true)
                                {
                                    NavbarFragment.HandleAppURL(MainPage.News[buttonId].News.ReferenceURL);
                                }
                                else
                                {
                                    // copy the news item's relevant members. That way, if we're running in debug,
                                    // and they want to override the news item, we can do that below.
                                    string newsUrl             = MainPage.News[buttonId].News.ReferenceURL;
                                    bool   newsImpersonation   = MainPage.News[buttonId].News.IncludeImpersonationToken;
                                    bool   newsExternalBrowser = MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser;

                                    // If we're running a debug build, see if we should override the news
                                    #if DEBUG
                                    if (DebugConfig.News_Override_Item == true)
                                    {
                                        newsUrl             = DebugConfig.News_Override_ReferenceURL;
                                        newsImpersonation   = DebugConfig.News_Override_IncludeImpersonationToken;
                                        newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser;
                                    }
                                    #endif

                                    TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment);
                                }
                            }
                            else
                            {
                                // store the news index they chose so we can manage the 'tap details' page.
                                DetailsPage.SetNewsInfo(MainPage.News[buttonId].News.Title,
                                                        MainPage.News[buttonId].News.Description,
                                                        MainPage.News[buttonId].News.GetDeveloperInfo( ),
                                                        MainPage.News[buttonId].News.ReferenceURL,
                                                        MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser,
                                                        MainPage.News[buttonId].News.IncludeImpersonationToken,
                                                        MainPage.News[buttonId].News.ImageName,
                                                        MainPage.News[buttonId].News.ImageURL);

                                PresentFragment(DetailsPage, true);
                            }
                        }
                        else if (source == DetailsPage)
                        {
                            // otherwise visit the reference URL
                            if (buttonId == Resource.Id.news_details_launch_url || buttonId == Resource.Id.news_details_header_image_button)
                            {
                                // if this is an app url, handle it internally
                                if (Springboard.IsAppURL(DetailsPage.ReferenceURL) == true)
                                {
                                    NavbarFragment.HandleAppURL(DetailsPage.ReferenceURL);
                                }
                                else
                                {
                                    // copy the news item's relevant members. That way, if we're running in debug,
                                    // and they want to override the news item, we can do that below.
                                    string newsUrl             = DetailsPage.ReferenceURL;
                                    bool   newsImpersonation   = DetailsPage.IncludeImpersonationToken;
                                    bool   newsExternalBrowser = DetailsPage.ReferenceURLLaunchesBrowser;

                                    // If we're running a debug build, see if we should override the news
                                    #if DEBUG
                                    if (DebugConfig.News_Override_Item == true)
                                    {
                                        newsUrl             = DebugConfig.News_Override_ReferenceURL;
                                        newsImpersonation   = DebugConfig.News_Override_IncludeImpersonationToken;
                                        newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser;
                                    }
                                    #endif

                                    TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment);
                                }
                            }
                        }
                    }
                }