protected override async void OnAppearing() { base.OnAppearing(); var content = await httpManager.Client.GetStringAsync(HttpManager.PageUrl + "/" + id); var post = JsonConvert.DeserializeObject <Post>(content); post.TitleString = WebUtility.HtmlDecode(post.Title.TitleText); post.ContentString = post.Content.ContentText; String finalString = post.ContentString.Replace("http://", "<a href='http://"); // Ad hoc solution... finalString = finalString.Replace("%B3na", "%B3na'>link</a>"); finalString = finalString.Replace("/Predmety/Sablony", "/Predmety/Sablony'>link</a>"); Browser.Source = httpManager.CreateHtmlView(finalString); Browser.Navigating += (s, e) => { if (e.Url.StartsWith("http")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception) { } e.Cancel = true; } }; }
protected override async void OnAppearing() { base.OnAppearing(); var content = await httpManager.Client.GetStringAsync(HttpManager.PageUrl + "/" + id); var post = JsonConvert.DeserializeObject <Post>(content); post.TitleString = WebUtility.HtmlDecode(post.Title.TitleText); post.ContentString = post.Content.ContentText; Browser.Source = httpManager.CreateHtmlView(post.ContentString); Browser.Navigating += (s, e) => { if (e.Url.StartsWith("http")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception) { } e.Cancel = true; } }; }
protected override async void OnAppearing() { base.OnAppearing(); var content = await httpManager.Client.GetStringAsync(HttpManager.PageUrl + "/" + id); var post = JsonConvert.DeserializeObject <Post>(content); post.TitleString = WebUtility.HtmlDecode(post.Title.TitleText); post.ContentString = post.Content.ContentText; Browser.Source = httpManager.CreateHtmlView(post.ContentString); }
protected override async void OnAppearing() { base.OnAppearing(); var content = await httpManager.Client.GetStringAsync(HttpManager.PostsUrl + "/" + id); //var post = JsonConvert.DeserializeObject<Post>(content); post.ContentString = post.Content.ContentText; var htmlSource = new HtmlWebViewSource(); var stream = Android.App.Application.Context.Assets.Open("styles.css"); using (var streamReader = new StreamReader(stream)) { String css = streamReader.ReadToEnd(); } title.Text = post.TitleString; Browser.Source = httpManager.CreateHtmlView(post.ContentString); }
protected override async void OnAppearing() { base.OnAppearing(); String finalString = ""; String contentString = ""; // Informatics // ================= var content = await httpManager.Client.GetStringAsync(HttpManager.PageUrl + "/" + idInformatics); var post = JsonConvert.DeserializeObject <Post>(content); post.TitleString = WebUtility.HtmlDecode(post.Title.TitleText); post.ContentString = post.Content.ContentText; contentString = "<h2>" + post.Title.TitleText + "</h2>" + post.ContentString.Replace("https://", "<a href='https://"); finalString = finalString + contentString; // Hardware // ================= content = await httpManager.Client.GetStringAsync(HttpManager.PageUrl + "/" + idHardware); post = JsonConvert.DeserializeObject <Post>(content); post.TitleString = WebUtility.HtmlDecode(post.Title.TitleText); post.ContentString = post.Content.ContentText; contentString = "<h2>" + post.Title.TitleText + "</h2>" + post.ContentString.Replace("https://", "<a href='https://"); finalString = finalString + contentString; // Electro // ================= content = await httpManager.Client.GetStringAsync(HttpManager.PageUrl + "/" + idElectro); post = JsonConvert.DeserializeObject <Post>(content); post.TitleString = WebUtility.HtmlDecode(post.Title.TitleText); post.ContentString = post.Content.ContentText; contentString = "<h2>" + post.Title.TitleText + "</h2>" + post.ContentString.Replace("https://", "<a href='https://"); finalString = finalString + contentString; // Ad hoc solution... finalString = finalString.Replace("http://", "<a href='http://"); finalString = finalString.Replace("<br />", "'>link</a><br />"); finalString = finalString.Replace("/</p>", "/'>link</a></p>"); Browser.Source = httpManager.CreateHtmlView(finalString); Browser.Navigating += (s, e) => { if (e.Url.StartsWith("http")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception) { } e.Cancel = true; } }; }