Is there an XWalkView web client?

I am trying to use XWalkView as a replacement for a web browser in an Android app. I noticed that there is no method setWebViewClientfor an XWalkView object . The thing is, I want to check when the page is finished ( onPageFinished) and when the resource is loaded ( onLoadResource). How to do it with XWalkView ?

I am embedding XWalkView with this tutorial

embed a pedestrian crossing in android studio

+6
source share
3 answers

API Cross Walk . WebView XWalkView, WebViewClient XWalkResourceClient WebChromeClient - XWalkUIClient. , setWebViewClient setResourceClient XWalkResourceClient. , onLoadFinished. API Cross Walk API.

+17

WebViewClient:

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            //Do stuff
        }
    });

, XWalkView:

xWalkView.setResourceClient(new XWalkResourceClient(xWalkView){
        @Override
        public void onLoadFinished(XWalkView view, String url) {
            super.onLoadFinished(view, url);
            //Do Stuff
        }
    });
+5

ResourceClient.

class ResourceClient extends XWalkResourceClient {
    public ResourceClient(XWalkView xwalkView) {
        super(xwalkView);
    }

    public void onLoadStarted(XWalkView view, String url) {
        mProgress = (ProgressBar) findViewById(R.id.progressBar);
        mProgress.setVisibility(View.VISIBLE);
        super.onLoadStarted(view, url);
        Log.d("INFO", "Load Started:" + url);
    }

    public void onLoadFinished(XWalkView view, String url) {
        super.onLoadFinished(view, url);
        Log.d("INFO", "Load Finished:" + url);
        bottomBar = (BottomBar) findViewById(R.id.bottomBar);
        mProgress = (ProgressBar) findViewById(R.id.progressBar);
        mProgress.setVisibility(View.GONE);
    }

    public void onProgressChanged(XWalkView view, int progressInPercent) {
        super.onProgressChanged(view, progressInPercent);
        Log.d("INFO", "Loading Progress:" + progressInPercent);
        mProgress = (ProgressBar) findViewById(R.id.progressBar);
        mProgress.setProgress(progressInPercent);
    }
+2

Source: https://habr.com/ru/post/1612348/


All Articles