コード例 #1
0
        private async void Wv_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs e)
        {
            ProgressBox.Instance.HideProgress();

            //如果导航未成功,说明导航错误,网页加载出错。
            if (!e.IsSuccess)
            {
                this.Opacity = 0.0;
                WPToastBox.Instance.ShowWPToastNotice(AppNetworkMessageConst.IS_WEBVIEW_NAVIAGATION_ERROR);
            }
            else
            {
                //this.AnimationGrid.Children.Add(this.wv);

                this.wv.Opacity = 1.0;

                try
                {
                    //2、直接执行js代码
                    var replaceTarget = "var as = document.getElementsByTagName('div');" +
                                        "for(i = 0;i < as.length;i++){" +
                                        " if (as[i].id  == 'footer'){ as[i].style.display= 'none';break;}}";

                    this.wv.InvokeScriptAsync("eval", new[] { replaceTarget });

                    var replaceTarget1 = "var as = document.getElementsByTagName('div');" +
                                         "for(i = 0;i < as.length;i++){" +
                                         " if (as[i].className  == 'divider-h'){ as[i].style.display= 'none';break;}}";

                    this.wv.InvokeScriptAsync("eval", new[] { replaceTarget1 });

                    var replaceTarget2 = "var as = document.getElementsByTagName('div');" +
                                         "for(i = 0;i < as.length;i++){" +
                                         " if (as[i].id  == 'download-area'){ as[i].style.display= 'none';break;}}";

                    await this.wv.InvokeScriptAsync("eval", new[] { replaceTarget2 });

                    var replaceTarget3 = "var as = document.getElementsByTagName('div');" +
                                         "for(i = 0;i < as.length;i++){" +
                                         " if (as[i].id  == 'promotion-bar-container'){ as[i].style.display= 'none';break;}}";

                    this.wv.InvokeScriptAsync("eval", new[] { replaceTarget3 });
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }

                await AnimationGrid.AnimateAsync(new FadeInDownAnimation()
                {
                    Distance = 200
                });
            }
        }
コード例 #2
0
        private async void Wv_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            //故意放在这里先移除广告在显示动画显示wv
            RemoveBottomAD(wv);

            //InsertJS();

            newsViewModel.IsBusy = true;

            newsViewModel.IsBusy = false;

            if (args.IsSuccess)
            {
                //只有加载成功才可以记录已经看过,以便再次加载的时候能够及时更改颜色
                var model = DicStore.GetValueOrDefault <NewsModelPropertyBase>(AppCommonConst.CURRENT_NEWS_MODEL, null);
                if (model != null)
                {
                    model.NewsTitleForeground = AppCommonConst.NEWS_IS_ALREADY_READ_FOREGROUND;
                    SettingsStore.AddOrUpdateValue <bool>(model.id, true);
                }

                wv.Visibility = Visibility.Visible;

                if (AppEnvironment.IsPhone)
                {
                    await AnimationGrid.AnimateAsync(new FadeInDownAnimation()
                    {
                        Distance = 400, Duration = 0.25
                    });
                }
                else
                {
                    await AnimationGrid.AnimateAsync(new FadeInLeftAnimation()
                    {
                        Duration = 0.13, Distance = 600
                    });
                }
            }
            else
            {
                wv.Visibility = Visibility.Collapsed;

                if (AppEnvironment.IsInternetAccess)
                {
                    RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWORK_IS_OFFLINEL, typeof(MyCF.View.News.NewsDetailPage), "ReLoadUrlSource", null);
                }
                else
                {
                    RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWOTK_IS_ERROR, typeof(MyCF.View.News.NewsDetailPage), "ReLoadUrlSource", null);
                }
            }
        }