Код: Выделить всё
@ReactProp(name = "message")
public void setWebviewHtml(LinearLayout view, String html) {
if(! this.cacheData) {
Toast.makeText(reactContext, "sfbsfbsfb: " + this.cacheData + " : " + messageId, Toast.LENGTH_SHORT).show();
String uniqueId = UUID.randomUUID().toString().replace("-", "");
uniqueId = "APPJS" + uniqueId;
// Toast.makeText(reactContext, "uniqueId: " + uniqueId, Toast.LENGTH_SHORT).show();
html = "HTML5 Boilerplate" + html + "";
// oast.makeText(reactContext, "html: " + html, Toast.LENGTH_SHORT).show();
html += "\n";
html += "localStorage.setItem('" + messageId + "', '" + html + "');\n"; // This line breaks the code and does not render anything
html += "$(document).ready(function() {\n";
html += " javascript:" + uniqueId + ".ResizeWebView($(document).height());\n";
html += "});\n";
html += "\n";
layout.setWebviewHtml(html, uniqueId);
}
}
Код: Выделить всё
public void setWebviewHtml(String html, String uniqueId) {
// Toast.makeText(context, "html2: " + html, Toast.LENGTH_SHORT).show();
webView.loadData(html, "text/html", "UTF-8");
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new JSInterface(webView, context, this), uniqueId);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowFileAccess(true);
// webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
}
Код: Выделить всё
html += "localStorage.setItem('" + messageId + "', '" + html + "');\n";
Подробнее здесь: https://stackoverflow.com/questions/790 ... id-webview