Search in sources :

Example 1 with ExtendedWebView

use of forpdateam.ru.forpda.ui.views.ExtendedWebView in project ForPDA by RadiationX.

the class WebViewsProvider method pull.

public ExtendedWebView pull(Context context) {
    ExtendedWebView webView;
    if (!availableWebViews.isEmpty()) {
        webView = availableWebViews.poll();
    } else {
        webView = new ExtendedWebView(context);
        webView.setTag("WebView_tag ".concat(Long.toString(System.currentTimeMillis())));
    }
    Log.d("WebViewsProvider", "Pull " + webView);
    return webView;
}
Also used : ExtendedWebView(forpdateam.ru.forpda.ui.views.ExtendedWebView)

Example 2 with ExtendedWebView

use of forpdateam.ru.forpda.ui.views.ExtendedWebView in project ForPDA by RadiationX.

the class WebViewsProvider method destroy.

public void destroy() {
    webViewCleaner.cancel();
    webViewCleaner.purge();
    for (ExtendedWebView webView : availableWebViews) {
        webView.destroy();
    }
    availableWebViews.clear();
}
Also used : ExtendedWebView(forpdateam.ru.forpda.ui.views.ExtendedWebView)

Example 3 with ExtendedWebView

use of forpdateam.ru.forpda.ui.views.ExtendedWebView 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());
}
Also used : FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent) RecyclerView(android.support.v7.widget.RecyclerView) CustomWebViewClient(forpdateam.ru.forpda.common.webview.CustomWebViewClient) CustomWebChromeClient(forpdateam.ru.forpda.common.webview.CustomWebChromeClient) SuppressLint(android.annotation.SuppressLint) ExtendedWebView(forpdateam.ru.forpda.ui.views.ExtendedWebView)

Aggregations

ExtendedWebView (forpdateam.ru.forpda.ui.views.ExtendedWebView)3 SuppressLint (android.annotation.SuppressLint)1 RecyclerView (android.support.v7.widget.RecyclerView)1 CustomWebChromeClient (forpdateam.ru.forpda.common.webview.CustomWebChromeClient)1 CustomWebViewClient (forpdateam.ru.forpda.common.webview.CustomWebViewClient)1 FunnyContent (forpdateam.ru.forpda.ui.views.FunnyContent)1