コード例 #1
0
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();

                HybridView         = null !;
                SwipeRefreshLayout = null !;
                DataObject         = null !;
                MAdView            = null !;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #2
0
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();

                HybridView         = null;
                SwipeRefreshLayout = null;
                DataObject         = null;
                MAdView            = null;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #3
0
        private void SetWebView()
        {
            try
            {
                //Set WebView and Load url to be rendered on WebView
                if (!Methods.CheckConnectivity())
                {
                    SwipeRefreshLayout.Refreshing = false;
                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                }
                else
                {
                    DataObject = JsonConvert.DeserializeObject <GamesDataObject>(Intent?.GetStringExtra("ItemObject"));
                    if (DataObject != null)
                    {
                        string url;
                        if (DataObject.GameLink.Contains("www.miniclip.com"))
                        {
                            url = DataObject.GameLink;
                        }
                        else if (DataObject.GameLink.Contains("http"))
                        {
                            url = DataObject.GameLink;
                        }
                        else
                        {
                            url = "https://www.miniclip.com/games/" + DataObject.GameLink + "/en/webgame.php";
                        }

                        var frame = "<iframe src='" + url + "' id='iframe-game' name='iframe-game' class='loader-game-frame' width='100%' height='100%' border='0' frameborder='0' scrolling='no' allow='autoplay; fullscreen' allowfullscreen='true' style='border: none; height: -webkit-fill-available; min-height: 600px;'></iframe>";

                        string responsive = ".page-container{ display: -webkit-box; display: flex; -webkit-box-orient: vertical; flex-direction: column; padding: 20px; box-sizing: border-box;} .page-container.notification-opened { -webkit-box-orient: horizontal; flex-direction: row; }  .page-container.notification-opened > .notification-arrow { margin-right: 20px; } ";

                        string style = AppSettings.SetTabDarkTheme ? "<style type='text/css'>body{color: #fff; background-color: #444;}" + responsive + "</style>" :
                                       "<style type='text/css'>body{color: #444; background-color: #fff;}" + responsive + "</style>";

                        string data = "<!DOCTYPE html>";
                        data += "<head><title></title>" + style +
                                "<script type='text/javascript' src ='https://static.miniclipcdn.com/js/game-embed.js'></script>" +
                                "<script type='text/javascript' src ='https://static.miniclipcdn.com/js/mc.js'></script>" +
                                "<script type='text/javascript' src ='https://static.miniclipcdn.com/js/currency.js'></script>" +
                                "<script type='text/javascript' src ='https://static.miniclipcdn.com/js/currency/miniclip.js'></script>" +
                                "</head>";
                        data += "<body>" + frame + "</body>";
                        data += "</html>";

                        WebSettings webSettings = HybridView.Settings;
                        webSettings.JavaScriptEnabled = true;

                        HybridView.HorizontalScrollBarEnabled = false;
                        HybridView.VerticalScrollBarEnabled   = false;
                        HybridView.ScrollbarFadingEnabled     = false;
                        HybridView.SetScrollContainer(false);

                        webSettings.SetSupportZoom(true);
                        webSettings.BuiltInZoomControls = true;
                        webSettings.DisplayZoomControls = false;

                        HybridView.SetWebViewClient(new MyWebViewClient(this));
                        HybridView.SetWebChromeClient(new WebChromeClient());
                        HybridView.SetInitialScale(1);
                        webSettings.AllowFileAccess = true;
                        webSettings.SetPluginState(WebSettings.PluginState.On);
                        webSettings.SetPluginState(WebSettings.PluginState.OnDemand);
                        webSettings.LoadWithOverviewMode     = true;
                        webSettings.UseWideViewPort          = true;
                        webSettings.DomStorageEnabled        = true;
                        webSettings.LoadsImagesAutomatically = true;
                        webSettings.JavaScriptCanOpenWindowsAutomatically = true;
                        webSettings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.TextAutosizing);

                        HybridView.ScrollBarStyle = ScrollbarStyles.InsideOverlay;

                        //string desktopUserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36";
                        //string mobileUserAgent = "Mozilla/5.0 (Linux; U; Android 4.4; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";

                        //Choose Mobile/Desktop client.
                        webSettings.UserAgentString = HybridView.Settings.UserAgentString.Replace("Mobile", "eliboM").Replace("Android", "diordnA");

                        //Load url to be rendered on WebView
                        HybridView.LoadDataWithBaseURL(null, data, "text/html", "UTF-8", null);

                        if (DataObject.Active != "1")
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Games.AddToMyGamesAsync(DataObject.Id)
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }