Example #1
0
        public void OnWebPageLoaded(WebViewExt view, string url)
        {
            LogHelper.Debug("dbg", "OnWebPageLoaded url=" + url);
            webView.ClearHistory();
            if (onPageLoaded != null)
            {
                LogHelper.Debug("dbg", "call onPageLoaded");
                onPageLoaded();
            }

            /*
             * Task.Run(() =>
             * {
             *      Thread.Sleep(100);
             *      Application.SynchronizationContext.Post(_ =>
             *      {
             *              webView.ScrollTo(0, 0);
             *              LogHelper.Debug("dbg", "!!!Force: webView.ScrollTo(0, 0).");
             *      }, null);
             * });
             */
        }
Example #2
0
        public WebViewExt RequestWebView(
            Context context,
            Action onPageLoaded = null,
            Action <string, string, float, float, float, float> onGetSelectedText = null,
            Action <Hyperlink> onLoadUrl              = null,
            Action <int, float> onWebOverScroll       = null,
            Action <string> onScrollLoadPageCompleted = null,
            Action <string, string> onScrollToPage    = null)
        {
            if (webView == null)
            {
                webView = new WebViewExt(context);
                webView.SetLayerType(LayerType.Software, null);
                webView.LayoutParameters = new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                webView.Settings.JavaScriptEnabled = true;
                webView.SetWebViewClient(webViewClient);
                webView.Settings.TextZoom = WebContentFontSizeHelper.ParseZoom((int)SettingsUtil.Instance.GetFontSize());
                webView.AddJavascriptInterface(new RedController(this, webView), "RedController");
                webView.SetOverScrollHandler(OnWebOverScroll);
                webView.ScrollbarFadingEnabled = false;
            }

            if (parentView != null)
            {
                throw new InvalidOperationException("The WebView is loan out.");
            }

            this.onPageLoaded              = onPageLoaded;
            this.onGetSelectedText         = onGetSelectedText;
            this.onWebOverScroll           = onWebOverScroll;
            this.onScrollLoadPageCompleted = onScrollLoadPageCompleted;
            this.onScrollToPage            = onScrollToPage;
            this.onLoadUrl = onLoadUrl;

            return(webView);
        }
Example #3
0
 public RedController(WebViewKeeper keeper, WebViewExt webView)
 {
     this.keeper  = keeper;
     this.webView = webView;
 }