本文整理汇总了C#中WebView.LoadDataWithBaseURL方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.LoadDataWithBaseURL方法的具体用法?C# WebView.LoadDataWithBaseURL怎么用?C# WebView.LoadDataWithBaseURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView.LoadDataWithBaseURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView(Resource.Layout.MySkool_AnnounceDetailsLayout);
toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.app_bar);
toolbar.SetBackgroundColor (Color.ParseColor ("#F8A015"));
//toolbar.SetNavigationIcon (Resource.Drawable.ic_arrow_up);
SetSupportActionBar (toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
string getArticleTitle = Intent.GetStringExtra ("ArticleTitle");
string getArticleContent = Intent.GetStringExtra ("ArticleContent");
mainTitle = FindViewById<TextView> (Resource.Id.tvMSADLMainTitle);
mainTitle.Text = getArticleTitle.ToString();
infoDetails = FindViewById<WebView> (Resource.Id.wvMSADLDetails);
infoDetails.Settings.JavaScriptEnabled = true;
infoDetails.LoadDataWithBaseURL ("",
getArticleContent.ToString(),
"text/html",
"UTF-8", "");
}
示例2: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView (Resource.Layout.MySoal_MessageDetailsLayout);
toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.app_bar);
toolbar.SetBackgroundColor (Color.ParseColor ("#F44336"));
//toolbar.SetNavigationIcon (Resource.Drawable.ic_next);
//toolbar.
//toolbar.SetNavigationOnClickListener ();
mainTitle = FindViewById<TextView> (Resource.Id.tvMSMDLMainTitle);
mainTitle.Text = Intent.GetStringExtra ("PMDTitle");
infoDetails = FindViewById<WebView> (Resource.Id.wvMSMDLDetails);
infoDetails.Settings.JavaScriptEnabled = true;
infoDetails.LoadDataWithBaseURL ("",
Intent.GetStringExtra ("PMDContent"),
"text/html",
"UTF-8", "");
infoDetails.Settings.BuiltInZoomControls = true;
SetSupportActionBar (toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
}
示例3: collectDevice
public static void collectDevice()
{
string SessionId = Conekta.DeviceFingerPrint ();
string PublicKey = Conekta.PublicKey;
string html = "<!DOCTYPE html><html><head></head><body style=\"background: blue;\">";
html += "<script type=\"text/javascript\" src=\"https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js\" data-conekta-public-key=\"" + PublicKey + "\" data-conekta-session-id=\"" + SessionId + "\"></script>";
html += "</body></html>";
string contentPath = Environment.CurrentDirectory;
#if __IOS__
UIWebView web = new UIWebView(new RectangleF(new PointF(0,0), new SizeF(0, 0)));
web.ScalesPageToFit = true;
web.LoadHtmlString(html, new NSUrl("https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"));
Conekta._delegate.View.AddSubview(web);
#endif
#if __ANDROID__
WebView web_view = new WebView(Android.App.Application.Context);
web_view.Settings.JavaScriptEnabled = true;
web_view.Settings.AllowContentAccess = true;
web_view.Settings.DomStorageEnabled = true;
web_view.LoadDataWithBaseURL(Conekta.UriConektaJs, html, "text/html", "UTF-8", null);
#endif
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.WebviewActivity);
_webview = FindViewById<WebView> (Resource.Id.WebviewActivity_webview);
var html = Intent.GetStringExtra (Constants.WebviewUriKey);
_webview.LoadDataWithBaseURL (null, html, "text/html", "utf-8", null);
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.webview);
string res = base.Intent.GetStringExtra("content");
#if DEBUG
Console.WriteLine("passed over length = {0}", res.Length);
#endif
if (res.Length > 0)
{
web_view = FindViewById<WebView>(Resource.Id.webviewer);
web_view.Settings.JavaScriptEnabled = true;
web_view.LoadDataWithBaseURL(null, convertStringToHTML(res, true), "text/html", null, null);
}
else
return;
}
示例6: GetViewImpl
protected override View GetViewImpl(Context context, View convertView, ViewGroup parent)
{
var webView = new WebView(context);
string textColor = ";color:#FFFFFF";
string backgroundColor = "background:#000000;";
if (Url == null)
{
string body = "<html><head><meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\"/></head><body style=\"-webkit-text-size-adjust:none;{0}margin:10px 15px 15px;font-family:helvetica,arial,sans-serif;font-size:16{1}\">{2}</body></html>";
webView.LoadDataWithBaseURL(string.Empty, string.Format(body, backgroundColor, textColor, WebContent), "text/html", "utf-8", null);
}
else
{
webView.LoadUrl(Url.ToString());
}
webView.SetVerticalScrollbarOverlay(true);
webView.SetMinimumHeight(10);
return webView;
}
示例7: OnViewModelSet
protected override void OnViewModelSet()
{
Window.RequestFeature(WindowFeatures.Progress);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
SupportActionBar.SetBackgroundDrawable(Resources.GetDrawable(Resource.Color.s_main_green));
SupportActionBar.SetLogo(Resource.Drawable.logo_white);
base.OnViewModelSet();
SetContentView(Resource.Layout.page_localwebview);
var set = this.CreateBindingSet<LocalHtmlWebView, LocalHtmlWebViewModel>();
set.Bind(SupportActionBar).For(v => v.Title).To(vm => vm.Title).Mode(MvxBindingMode.OneWay);
set.Apply();
_webView = FindViewById<WebView>(Resource.Id.webView);
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.SetSupportZoom(true);
var progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);
var webChromeClient = new ProgressUpdatingWebChromeClient(progressBar);
var webViewClient = new ProgressHandlingWebViewClient(progressBar);
_webView.SetWebViewClient(webViewClient);
_webView.SetWebChromeClient(webChromeClient);
if (!string.IsNullOrEmpty(ViewModel.Url))
{
_webView.LoadUrl(ViewModel.Url);
}
else if (!string.IsNullOrEmpty(ViewModel.Html))
{
_webView.LoadDataWithBaseURL(null, ViewModel.Html, "text/html", "UTF-8", null);
}
}
示例8: LoadPublicationReader
private void LoadPublicationReader()
{
webview = View.FindViewById<WebView>(Resource.Id.readerWebView);
webview2 = View.FindViewById<WebView>(Resource.Id.readerWebView2);
webview.SetWebViewClient(client);
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
//webview.Settings.DisplayZoomControls = true;
webview.Settings.BuiltInZoomControls = true;
webview.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview.AddJavascriptInterface(new VerseSelection(Activity, webview, webview2), "VerseSelection");
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
if (ThisApp.preferences.GetBoolean("dualWebviews", false))
{
string lang = ThisApp.preferences.GetString("listSecondLanguage", ThisApp.Language);
XDocument doc2 = ThisApp.GetNWTFile(lang, ThisApp.selectedPublication.Image);
List<PublicationArticle> collection2 = doc2.Descendants("article")
.Select(article => new PublicationArticle
{
ArticleTitle = article.Element("title").Value,
Content = article.Element("content").Value,
DocumentLocation = article.Element("documentLocation").Value,
PublicationTitle = ThisApp.selectedPublication.Image
}).ToList();
string html2 = collection2.ElementAt(int.Parse(chapter) - 1).Content;
ThisApp.selectedPublicationArticle = ThisApp.GetAllPublicationArticles().ElementAt(int.Parse(chapter) - 1);
webview2.SetWebViewClient(new NWTBibleWebView(Activity, lang, ThisApp.doHighlight, null, ThisApp.selectedPublicationArticle.ArticleTitle));
webview2.Settings.JavaScriptEnabled = true;
webview2.Settings.PluginsEnabled = true;
//webview2.Settings.DisplayZoomControls = true;
webview2.Settings.BuiltInZoomControls = true;
webview2.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview2.AddJavascriptInterface(new VerseSelection(Activity, webview, webview2), "VerseSelection");
webview2.LoadDataWithBaseURL("file:///android_asset/", html2, "text/html", "utf-8", null);
}
}
示例9: PrepareViews
//.........这里部分代码省略.........
});
}
break;
case MessageStep.StepTypes.SoundFX:
if (packItem != null)
{
RunOnUiThread(delegate
{
using (ImageView preview = new ImageView (context))
{
preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
preview.SetScaleType(ImageView.ScaleType.FitXy);
preview.SetImageResource(Resource.Drawable.audiofile);
linView.AddView(preview);
byte[] audio = packItem.ContentPackData;
System.IO.File.WriteAllBytes(path, audio);
AudioPlayer csfx = new AudioPlayer(context);
t.Interval = csfx.findDuration(path) + 1000;
csfx.playFromFile(path);
this.stepViews [eachMessageStep.StepNumber] = preview;
}
});
}
break;
case MessageStep.StepTypes.Emoticon:
if (packItem != null)
{
//RunOnUiThread (delegate {
t.Interval = 5000;
string base64String = System.Convert.ToBase64String(packItem.ContentPackData, 0, packItem.ContentPackData.Length);
using (WebView wv = new WebView (context))
{
string url = "<img src=\"data:image/gif;base64," + base64String + "\" width=\"" + ((int)newSizes [0]).ToString() + "\" height=\"" + ((int)newSizes [1]).ToString() + "\" />";
wv.LoadDataWithBaseURL(null, url, "text/html", "UTF-8", null);
wv.VerticalScrollBarEnabled = false;
wv.HorizontalScrollBarEnabled = false;
wv.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(200f, context), (int)ImageHelper.convertDpToPixel(200f, context));
wv.SetBackgroundColor(Color.Transparent);
RunOnUiThread(() => linView.AddView(wv));
}
//});
}
break;
case MessageStep.StepTypes.Voice:
if (MessagePlaybackUtil.voiceRecordings != null)
{
RunOnUiThread(delegate
{
using (ImageView preview = new ImageView (context))
{
preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
preview.SetScaleType(ImageView.ScaleType.FitXy);
preview.SetImageResource(Resource.Drawable.microphone);
linView.AddView(preview);
this.stepViews [eachMessageStep.StepNumber] = preview;
}
//byte[] audio = getLocalVoiceRecording (MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]);
AudioPlayer voice = new AudioPlayer(context);
#if DEBUG
System.Diagnostics.Debug.WriteLine("audio file filename = {0}, stepNumber = {1}", MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber], eachMessageStep.StepNumber);
#endif
t.Interval = voice.findDuration(MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]) + 1000;
string audioPath = MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber];
if (!File.Exists(audioPath))
{
#if DEBUG
示例10: LoadPublicationReader
private void LoadPublicationReader(int chapter = 0)
{
content = new List<ChapterItem>();
int chapterNum = 0;
if (chapter != 0)
{
// Number of chapters in the selected book
chapterNum = chapter;
}
else
{
chapterNum = ThisApp.selectedPublication.CurrentPage;
}
// Load xml document of the book
XDocument doc = ThisApp.GetNWTFile(ThisApp.Language, ThisApp.selectedPublication.Image);
// Load each chapter
var query = from node in doc.Descendants("article")
select new
{
Title = node.Element("title").Value,
DocumentLocation = node.Element("documentLocation").Value,
Content = node.Element("content").Value
};
foreach (var chap in query)
{
content.Add(new ChapterItem
{
Title = chap.Title,
DocumentLocation = chap.DocumentLocation,
Content = chap.Content,
});
}
numOfChapters = content.Count();
// Get the CDATA of the selected chapter
html = content.ElementAt(ThisApp.selectedPublication.CurrentPage).Content;
ThisApp.selectedPublication.ShortTitle = query.ElementAt(ThisApp.selectedPublication.CurrentPage).Title;
webview = FindViewById<WebView>(Resource.Id.readerWebView);
webview2 = FindViewById<WebView>(Resource.Id.readerWebView2);
webview.SetWebViewClient(new NWTBibleWebView(this, ThisApp.Language));
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
webview.Settings.DisplayZoomControls = true;
webview.Settings.BuiltInZoomControls = true;
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
}
示例11: LoadBibleReader
private void LoadBibleReader()
{
// Number of chapters in the selected book
int chapterNum = int.Parse(ThisApp.selectedChapter.ChapterNumber);
offset = chapterNum;
// Load xml document of the book
XDocument doc = ThisApp.GetNWTFile(ThisApp.Language, ThisApp.selectedBook.Name.ToUpper());
// Load each chapter
var query = from node in doc.Descendants("c")
select new
{
Data = node.Value
};
numOfChapters = query.Count();
// Get the CDATA of the selected chapter
html = query.ElementAt(chapterNum - 1).Data;
webview = FindViewById<WebView>(Resource.Id.readerWebView);
webview2 = FindViewById<WebView>(Resource.Id.readerWebView2);
webview.SetWebViewClient(new NWTBibleWebView(this, ThisApp.Language, ThisApp.doHighlight));
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
//webview.Settings.DisplayZoomControls = true;
webview.Settings.BuiltInZoomControls = true;
webview.AddJavascriptInterface(new ReaderMenu.VerseSelection(this, webview, webview2), "VerseSelection");
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
if (ThisApp.preferences.GetBoolean("dualWebviews", false))
{
XDocument doc2 = ThisApp.GetNWTFile(ThisApp.preferences.GetString("listSecondLanguage", ThisApp.Language), ThisApp.selectedBook.Name.ToUpper());
string html2 = "<html><body><h1>" + offset.ToString() + "</h1></body></html>";
html2 += doc2.Descendants("c").ElementAt(offset - 1);
webview2 = FindViewById<WebView>(Resource.Id.readerWebView);
webview2.SetWebViewClient(new NWTBibleWebView(this, ThisApp.Language, ThisApp.doHighlight));
webview2.Settings.JavaScriptEnabled = true;
webview2.Settings.PluginsEnabled = true;
//webview2.Settings.DisplayZoomControls = true;
webview2.Settings.BuiltInZoomControls = true;
webview2.AddJavascriptInterface(new ReaderMenu.VerseSelection(this, webview, webview2), "VerseSelection");
webview2.LoadDataWithBaseURL("file:///android_asset/", html2, "text/html", "utf-8", null);
}
}
示例12: LoadWOLDailyText
private void LoadWOLDailyText(int offset)
{
string[] date = FormatWOLDateTime(DateTime.Now.AddDays(offset)).Split('-');
string url = "http://wol.jw.org/en/wol/dt/r" + ThisApp.GetLanguageR(ThisApp.Language) + "/lp-" + ThisApp.GetLanguageCode(ThisApp.Language).ToLower() + "/" + date[0] + "/" + date[1] + "/" + date[2];
webview = View.FindViewById<WebView>(Resource.Id.readerWebView);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 8000; //if it's an aspx give it a few to warm up
try
{
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
html = reader.ReadToEnd();
Console.WriteLine(html);
string[] beginning1 = Regex.Split(html, "<title>");
string removedBeginning1 = beginning1[beginning1.Length - 1];
html = removedBeginning1;
string[] end1 = Regex.Split(html, "</title>");
string pagetitle = end1[end1.Length - 2];
pagetitle = pagetitle.Replace("—", "—");
string[] beginning = Regex.Split(html, "<div class=\"results\">");
string removedBeginning = beginning[beginning.Length - 1];
html = "<div id=\"content\" >" + removedBeginning;
string[] end = Regex.Split(html, "<div id=\"contentFooter\">");
string content = end[end.Length - 2];
html = "<html><meta name=\"viewport\" content=\"width=320\" />\n" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n" +
"<link href=\"ui/web/dt.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
"<body class=\"calibre\">\n" +
"<div class=\"body\">" + content + "</div>\n" +
"<script src=\"http://m.wol.jw.org/js/jquery.min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/underscore-min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/wol.modernizr.min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/startup.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/wol.mobile.min.js\"></script>\n" + "</body></html>";
html = html.Replace("/en", "http://m.wol.jw.org/en");
client = new NWTBibleWebView(Activity, ThisApp.Language);
webview.SetWebViewClient(client);
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
webview.Settings.BuiltInZoomControls = true;
webview.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Toast.MakeText(Activity, "Please check connections.", ToastLength.Long).Show();
return;
}
}
示例13: LoadBibleReader
private void LoadBibleReader()
{
// Load xml document of the book
XDocument doc = ThisApp.GetNWTFile(ThisApp.Language, ThisApp.selectedBook.Name.ToUpper());
int chapterNum = int.Parse(ThisApp.selectedChapter.ChapterNumber);
List<string> collection = doc.Descendants("c").Select((element) => element.Value).ToList();
ThisApp.allBookChapters = collection;
numOfChapters = collection.Count();
// Get the CDATA of the selected chapter
html = "<html><body><h1>" + chapterNum + "</h1></body></html>";
html += collection.ElementAt(chapterNum - 1);
// References
if (ThisApp.preferences.GetBoolean("bibleReferences", true))
{
html = html.Replace("display: none", "display: inline");
}
// Add highlight nodes
html = Regex.Replace(html, @"(\d+.)(</a></span>|</span>)(.*?)((?=<span)|(?=\d+.</a></span>)|(?=</p>))", delegate(Match match)
{
string m = "";
if (match.Groups[2].Value == "</a></span>")
{
m = match.Groups[1].Value + "</a>" + match.Groups[3].Value + "</span>";
}
else if (match.Groups[2].Value == "</span>")
{
m = match.Groups[1].Value + match.Groups[3].Value + "</span>";
}
return m;
});
html = Regex.Replace(html, @"dcv_\d+_", "");
webview = View.FindViewById<WebView>(Resource.Id.readerWebView);
webview2 = View.FindViewById<WebView>(Resource.Id.readerWebView2);
client = new NWTBibleWebView(Activity, ThisApp.Language, ThisApp.doHighlight, null, ThisApp.selectedChapter.ChapterNumber);
webview.SetWebViewClient(client);
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
webview.Settings.BuiltInZoomControls = true;
webview.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview.AddJavascriptInterface(new VerseSelection(Activity, webview, webview2), "VerseSelection");
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
if (ThisApp.preferences.GetBoolean("dualWebviews", false))
{
string lang = ThisApp.preferences.GetString("listSecondLanguage", ThisApp.Language);
string html2 = "<html><body><h1>" + chapterNum + "</h1></body></html>";
XDocument doc2 = ThisApp.GetNWTFile(lang, ThisApp.selectedBook.Name.ToUpper());
html2 += doc2.Descendants("c").ElementAt(chapterNum - 1);
// References
if (ThisApp.preferences.GetBoolean("bibleReferences", true))
{
html2 = html2.Replace("display: none", "display: inline");
}
// Add highlight nodes
html2 = Regex.Replace(html2, @"(\d+.)(</a></span>|</span>)(.*?)((?=<span)|(?=\d+.</a></span>)|(?=</p>))", delegate(Match match)
{
string m = "";
if (match.Groups[2].Value == "</a></span>")
{
m = match.Groups[1].Value + "</a>" + match.Groups[3].Value + "</span>";
}
else if (match.Groups[2].Value == "</span>")
{
m = match.Groups[1].Value + match.Groups[3].Value + "</span>";
}
return m;
});
html2 = Regex.Replace(html2, @"dcv_\d+_", "");
webview2.SetWebViewClient(new NWTBibleWebView(Activity, lang, ThisApp.doHighlight, null, ThisApp.selectedChapter.ChapterNumber));
webview2.Settings.JavaScriptEnabled = true;
webview2.Settings.PluginsEnabled = true;
webview2.Settings.BuiltInZoomControls = true;
webview2.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview2.AddJavascriptInterface(new VerseSelection(Activity, webview, webview2), "VerseSelection");
webview2.LoadDataWithBaseURL("file:///android_asset/", html2, "text/html", "utf-8", null);
}
}
示例14: LoadPublicationReader
public void LoadPublicationReader(int chapter = 1)
{
ThisApp.allPublicationArticles = ThisApp.GetAllPublicationArticles();
ThisApp.selectedPublicationArticle = ThisApp.allPublicationArticles.ElementAt(chapter - 1);
numOfChapters = ThisApp.allPublicationArticles.Count();
// Get the CDATA of the selected chapter
html = "<html><body><h1>" + ThisApp.selectedPublicationArticle.ArticleTitle + "</h1></body></html>";
html += ThisApp.allPublicationArticles.ElementAt(chapter - 1).Content.Replace("PageOnLoad", "PubOnLoad");
webview = View.FindViewById<WebView>(Resource.Id.readerWebView);
webview2 = View.FindViewById<WebView>(Resource.Id.readerWebView2);
client = new NWTBibleWebView(Activity, ThisApp.Language, ThisApp.doHighlight, null, ThisApp.selectedPublicationArticle.ArticleTitle);
webview.SetWebViewClient(client);
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
webview.Settings.BuiltInZoomControls = true;
webview.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview.AddJavascriptInterface(new VerseSelection(Activity, webview, webview2), "VerseSelection");
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
if (ThisApp.preferences.GetBoolean("dualWebviews", false))
{
string lang = ThisApp.preferences.GetString("listSecondLanguage", ThisApp.Language);
XDocument doc2;
if (ThisApp.GetAllPublications(lang).Any(p => p.Image == ThisApp.selectedPublication.Image))
{
doc2 = ThisApp.GetNWTFile(lang, ThisApp.selectedPublication.Image);
}
else
{
doc2 = ThisApp.GetNWTFile(ThisApp.Language, ThisApp.selectedPublication.Image);
ThisApp.AlertBox(Activity, "REMINDER", "This document does not exist in " + lang + ".");
}
List<PublicationArticle> collection2 = doc2.Descendants("article")
.Select(article => new PublicationArticle
{
ArticleTitle = article.Element("title").Value,
Content = article.Element("content").Value,
DocumentLocation = article.Element("documentLocation").Value,
PublicationTitle = ThisApp.selectedPublication.Image
}).ToList();
string html2 = "<html><body><h1>" + collection2.ElementAt(chapter - 1).ArticleTitle + "</h1></body></html>";
html2 += collection2.ElementAt(chapter - 1).Content.Replace("PageOnLoad", "PubOnLoad");
webview2.SetWebViewClient(new NWTBibleWebView(Activity, lang, ThisApp.doHighlight, null, ThisApp.selectedPublicationArticle.ArticleTitle));
webview2.Settings.JavaScriptEnabled = true;
webview2.Settings.PluginsEnabled = true;
webview2.Settings.BuiltInZoomControls = true;
webview2.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview2.AddJavascriptInterface(new VerseSelection(Activity, webview, webview2), "VerseSelection");
webview2.LoadDataWithBaseURL("file:///android_asset/", html2, "text/html", "utf-8", null);
}
// Highlighting a publication paragraph.
//webview.SetOnLongClickListener(new PublicationLongClickListener(this));
}
示例15: LoadDailyTextReaderFromActionBar
public void LoadDailyTextReaderFromActionBar(int position)
{
// Either this
//LoadWOLDailyText(position);
//return;
// Or this
var dtDate = View.FindViewById<TextView>(Resource.Id.dtDate);
var dtScripture = View.FindViewById<TextView>(Resource.Id.dtScripture);
var dtContent = View.FindViewById<TextView>(Resource.Id.dtContent);
dailyText = ThisApp.GetDailyTextByPosition(position);
ThisApp.selectedDailyText = dailyText;
if (ThisApp.Language == "Chinese Simplified Pinyin")
{
html = dailyText.Content;
}
else
{
html = "<html><meta name=\"viewport\" content=\"width=320\" />\n" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n" +
"<link href=\"ui/web/dt.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
"<body class=\"calibre\">\n" +
"<div class=\"body\">" + dailyText.Content + "</div>\n" +
"<script src=\"http://m.wol.jw.org/js/jquery.min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/underscore-min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/wol.modernizr.min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/startup.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/wol.mobile.min.js\"></script>\n" + "</body></html>";
}
client = new NWTBibleWebView(Activity, ThisApp.Language);
webview = View.FindViewById<WebView>(Resource.Id.readerWebView);
webview.SetWebViewClient(client);
webview.Settings.JavaScriptEnabled = true;
webview.Settings.PluginsEnabled = true;
webview.Settings.BuiltInZoomControls = true;
webview.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
if (ThisApp.preferences.GetBoolean("dualWebviews", false))
{
string lang = ThisApp.preferences.GetString("listSecondLanguage", ThisApp.Language);
dailyText = ThisApp.GetSecondLanguageDailyText(lang, FormatDateTime(DateTime.Now.AddDays(position)), position);
if (lang == "Chinese Simplified Pinyin")
{
html = dailyText.Content;
}
else
{
html = "<html><meta name=\"viewport\" content=\"width=320\" />\n" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n" +
"<link href=\"ui/web/dt.css\" type=\"text/css\" rel=\"stylesheet\"/>\n" +
"<body class=\"calibre\">\n" +
"<div class=\"body\">" + dailyText.Content + "</div>\n" +
"<script src=\"http://m.wol.jw.org/js/jquery.min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/underscore-min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/wol.modernizr.min.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/startup.js\"></script>\n" +
"<script src=\"http://m.wol.jw.org/js/wol.mobile.min.js\"></script>\n" + "</body></html>";
}
client = new NWTBibleWebView(Activity, lang);
webview2 = View.FindViewById<WebView>(Resource.Id.readerWebView2);
webview2.SetWebViewClient(client);
webview2.Settings.JavaScriptEnabled = true;
webview2.Settings.PluginsEnabled = true;
webview2.Settings.BuiltInZoomControls = true;
webview2.Settings.DefaultFontSize = ThisApp.UserFontSize(Activity);
webview2.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
}
//dtDate.SetTypeface(ThisApp.Font(Activity, "ionbold"), Android.Graphics.TypefaceStyle.Normal);
//dtDate.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)ThisApp.UserFontSize(Activity));
//dtScripture.SetTypeface(ThisApp.Font(Activity, "ionitalic"), Android.Graphics.TypefaceStyle.Normal);
//dtScripture.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)ThisApp.UserFontSize(Activity));
//dtContent.SetTypeface(ThisApp.Font(Activity, "ionbook"), Android.Graphics.TypefaceStyle.Normal);
//dtContent.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)ThisApp.UserFontSize(Activity));
//dtDate.Text = dailyText.Date;
//dtScripture.Text = dailyText.Scripture;
//dtContent.Text = dailyText.Content;
}