Example #1
0
        private void WebViewNavigating(object sender, WebNavigatingEventArgs e)
        {
            WebView          webView          = (WebView)sender;
            UrlWebViewSource urlWebViewSource = (UrlWebViewSource)null;
            string           str1             = (string)null;

            if (webView.get_Source() is UrlWebViewSource)
            {
                urlWebViewSource = webView.get_Source() as UrlWebViewSource;
                str1             = urlWebViewSource.get_Url();
            }
            if (webView.get_Source() is HtmlWebViewSource)
            {
                webView.get_Source();
            }
            if (webView.get_Source() is UrlWebViewSource && (urlWebViewSource == null || string.IsNullOrEmpty(((WebNavigationEventArgs)e).get_Url())))
            {
                return;
            }
            string uriString = ((WebNavigationEventArgs)e).get_Url().TrimEnd('/');
            string str2;

            if (str1 == null)
            {
                str2 = (string)null;
            }
            else
            {
                str2 = str1.TrimEnd('/');
            }
            string str3 = str2;

            if (!(uriString != str3))
            {
                return;
            }
            if (!uriString.StartsWith("http"))
            {
                return;
            }
            try
            {
                Uri result = (Uri)null;
                if (!Uri.TryCreate(uriString, UriKind.Absolute, out result))
                {
                    return;
                }
                Device.OpenUri(result);
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, nameof(WebViewNavigating), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Behaviors/WebViewNavigationBehavior.cs", 68);
            }
            finally
            {
                e.set_Cancel(true);
            }
        }
Example #2
0
 private async void WebView_OnNavigating(object sender, WebNavigatingEventArgs e)
 {
     try
     {
         string url = ((WebNavigationEventArgs)e).get_Url();
         if (!url.StartsWith("http"))
         {
             return;
         }
         e.set_Cancel(true);
         await Launcher.OpenAsync(new Uri(url));
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
 }