use of net.iGap.module.structs.StructWebView in project iGap-Android by KianIranian-STDG.
the class FragmentChat method getUrlWebView.
private StructWebView getUrlWebView(String additionalData) {
Gson gson = new Gson();
StructWebView item = new StructWebView();
try {
item = gson.fromJson(additionalData, StructWebView.class);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (JsonSyntaxException e1) {
e1.printStackTrace();
}
return item;
}
use of net.iGap.module.structs.StructWebView in project iGap-Android by KianIranian-STDG.
the class FragmentChat method openWebViewForSpecialUrlChat.
private void openWebViewForSpecialUrlChat(String mUrl) {
try {
setDownBtnGone();
} catch (NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
if (botInit != null)
botInit.close();
/* StructWebView urlWebView = getUrlWebView(mUrl);
if (urlWebView == null) {
return;
} else {
urlWebViewForSpecialUrlChat = urlWebView.getUrl();
}
*/
urlWebViewForSpecialUrlChat = mUrl;
if (rootWebView == null)
rootWebView = rootView.findViewById(R.id.rootWebView);
if (progressWebView == null)
progressWebView = rootView.findViewById(R.id.progressWebView);
if (webViewChatPage == null) {
try {
webViewChatPage = new WebView(getContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
rootWebView.addView(webViewChatPage, params);
// webViewChatPage = rootView.findViewById(R.id.webViewChatPage);
} catch (Exception e) {
return;
}
}
recyclerView.setVisibility(View.GONE);
viewAttachFile.setVisibility(View.GONE);
rootWebView.setVisibility(View.VISIBLE);
webViewChatPage.getSettings().setLoadsImagesAutomatically(true);
webViewChatPage.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webViewChatPage.clearCache(true);
webViewChatPage.clearHistory();
webViewChatPage.clearView();
webViewChatPage.clearFormData();
webViewChatPage.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webViewChatPage.getSettings().setJavaScriptEnabled(true);
webViewChatPage.getSettings().setDomStorageEnabled(true);
progressWebView.setVisibility(View.VISIBLE);
webViewChatPage.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
if (progress == 100) {
progressWebView.setVisibility(View.GONE);
} else {
progressWebView.setVisibility(View.VISIBLE);
}
}
});
webViewChatPage.setWebViewClient(new MyWebViewClient() {
@Override
protected void onReceivedError(WebView webView, String url, int errorCode, String description) {
}
@Override
protected boolean handleUri(WebView webView, Uri uri) {
final String host = uri.getHost();
final String scheme = uri.getScheme();
// startActivity(intent);
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
if (url.toLowerCase().equals("igap://close")) {
makeWebViewGone();
}
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
});
webViewChatPage.loadUrl(urlWebViewForSpecialUrlChat);
}
Aggregations