use of forpdateam.ru.forpda.common.webview.CustomWebChromeClient in project ForPDA by RadiationX.
the class QmsChatFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
webView.setJsLifeCycleListener(this);
webView.addJavascriptInterface(this, JS_INTERFACE);
registerForContextMenu(webView);
webView.setWebViewClient(new CustomWebViewClient());
webView.setWebChromeClient(new CustomWebChromeClient());
loadBaseWebContainer();
viewsReady();
attachmentsPopup.setAddOnClickListener(v -> tryPickFile());
attachmentsPopup.setDeleteOnClickListener(v -> {
attachmentsPopup.preDeleteFiles();
List<AttachmentItem> selectedFiles = attachmentsPopup.getSelected();
for (AttachmentItem item : selectedFiles) {
item.setStatus(AttachmentItem.STATUS_REMOVED);
}
attachmentsPopup.onDeleteFiles(selectedFiles);
});
attachmentsPopup.setInsertAttachmentListener(item -> String.format(Locale.getDefault(), "\n[url=%s]Файл: %s, Размер: %s, Thumb: %s[/url]\n", item.getUrl(), item.getName(), item.getWeight(), item.getImageUrl()));
messagePanel.addSendOnClickListener(v -> {
if (currentChat.getThemeId() == QmsChatModel.NOT_CREATED) {
themeCreator.sendNewTheme();
} else {
sendMessage();
}
});
messagePanel.setHeightChangeListener(newHeight -> {
webView.setPaddingBottom(newHeight);
});
App.get().addPreferenceChangeObserver(chatPreferenceObserver);
tryShowAvatar();
if (currentChat.getNick() != null) {
setSubtitle(currentChat.getNick());
}
if (currentChat.getTitle() != null) {
setTitle(currentChat.getTitle());
setTabTitle(String.format(getString(R.string.fragment_tab_title_chat), currentChat.getTitle(), currentChat.getNick()));
}
if (currentChat.getThemeId() == QmsChatModel.NOT_CREATED) {
themeCreator = new ChatThemeCreator(this);
}
}
use of forpdateam.ru.forpda.common.webview.CustomWebChromeClient in project ForPDA by RadiationX.
the class AnnounceFragment method onViewCreated.
@SuppressLint("JavascriptInterface")
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewsReady();
webView.addJavascriptInterface(this, JS_INTERFACE);
webView.setWebViewClient(new CustomWebViewClient());
webView.setWebChromeClient(new CustomWebChromeClient());
webView.setJsLifeCycleListener(new ExtendedWebView.JsLifeCycleListener() {
@Override
public void onDomContentComplete(ArrayList<String> actions) {
setRefreshing(false);
}
@Override
public void onPageComplete(ArrayList<String> actions) {
}
});
}
use of forpdateam.ru.forpda.common.webview.CustomWebChromeClient in project ForPDA by RadiationX.
the class SearchFragment method onLoadData.
private void onLoadData(SearchResult searchResult) {
setRefreshing(false);
recyclerView.scrollToPosition(0);
hidePopupWindows();
data = searchResult;
Log.d("SUKA", "SEARCH SIZE " + searchResult.getItems().size());
if (data.getItems().isEmpty()) {
if (!contentController.contains(ContentController.TAG_NO_DATA)) {
FunnyContent funnyContent = new FunnyContent(getContext()).setImage(R.drawable.ic_search).setTitle(R.string.funny_search_nodata_title).setDesc(R.string.funny_search_nodata_desc);
contentController.addContent(funnyContent, ContentController.TAG_NO_DATA);
}
contentController.showContent(ContentController.TAG_NO_DATA);
} else {
contentController.hideContent(ContentController.TAG_NO_DATA);
}
Log.d("SUKA", "" + data.getSettings().getResult() + " : " + data.getSettings().getResourceType());
if (data.getSettings().getResult().equals(SearchSettings.RESULT_POSTS.first) && data.getSettings().getResourceType().equals(SearchSettings.RESOURCE_FORUM.first)) {
for (int i = 0; i < refreshLayout.getChildCount(); i++) {
if (refreshLayout.getChildAt(i) instanceof RecyclerView) {
refreshLayout.removeViewAt(i);
fixTargetView();
break;
}
}
if (refreshLayout.getChildCount() <= 1) {
if (scrollButtonEnable) {
fab.setVisibility(View.VISIBLE);
}
refreshLayout.addView(webView);
Log.d(LOG_TAG, "add webview");
}
if (webViewClient == null) {
webViewClient = new CustomWebViewClient();
webView.setWebViewClient(webViewClient);
webView.setWebChromeClient(new CustomWebChromeClient());
}
Log.d("SUKA", "SEARCH SHOW WEBVIEW");
webView.loadDataWithBaseURL("https://4pda.ru/forum/", data.getHtml(), "text/html", "utf-8", null);
} else {
for (int i = 0; i < refreshLayout.getChildCount(); i++) {
if (refreshLayout.getChildAt(i) instanceof ExtendedWebView) {
refreshLayout.removeViewAt(i);
fixTargetView();
}
}
if (refreshLayout.getChildCount() <= 1) {
fab.setVisibility(View.GONE);
refreshLayout.addView(recyclerView);
Log.d(LOG_TAG, "add recyclerview");
}
Log.d("SUKA", "SEARCH SHOW RECYCLERVIEW");
adapter.clear();
adapter.addAll(data.getItems());
}
paginationHelper.updatePagination(data.getPagination());
setSubtitle(paginationHelper.getTitle());
}
use of forpdateam.ru.forpda.common.webview.CustomWebChromeClient in project ForPDA by RadiationX.
the class ForumRulesFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewsReady();
webView.addJavascriptInterface(this, JS_INTERFACE);
webView.setWebViewClient(new CustomWebViewClient());
webView.setWebChromeClient(new CustomWebChromeClient());
webView.setJsLifeCycleListener(new ExtendedWebView.JsLifeCycleListener() {
@Override
public void onDomContentComplete(ArrayList<String> actions) {
setRefreshing(false);
}
@Override
public void onPageComplete(ArrayList<String> actions) {
}
});
}
use of forpdateam.ru.forpda.common.webview.CustomWebChromeClient in project ForPDA by RadiationX.
the class ArticleContentFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
webView = ((MainActivity) getActivity()).getWebViewsProvider().pull(getContext());
registerForContextMenu(webView);
webView.setWebViewClient(new CustomWebViewClient());
webView.setWebChromeClient(new CustomWebChromeClient());
webView.addJavascriptInterface(this, JS_INTERFACE);
loadHtml();
return webView;
}
Aggregations