Esempio n. 1
0
  /**
   * Notify the host application that a page has started loading. This method is called once for
   * each main frame load so a page with iframes or framesets will call onPageStarted one time for
   * the main frame.
   *
   * <p>In Crosswalk, this method is called for iframe navigations where the scheme is something
   * other than http or https, which includes assets with the Cordova project, so we have to test
   * for that, and not reset plugins in that case.
   *
   * @param view The webview initiating the callback.
   * @param url The url of the page.
   */
  @Override
  public void onPageStarted(XWalkView view, String url) {

    // Only proceed if this is a top-level navigation
    if (view.getUrl() != null && view.getUrl().equals(url)) {
      // Flush stale messages.
      appView.onPageReset();
      // Broadcast message that page has loaded
      appView.getPluginManager().postMessage("onPageStarted", url);
    }
  }
Esempio n. 2
0
  /**
   * Notify the host application that a page has finished loading. This method is called only for
   * main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
   *
   * @param view The webview initiating the callback.
   * @param url The url of the page.
   */
  @Override
  public void onPageFinished(XWalkView view, String url) {
    super.onPageFinished(view, url);
    LOG.d(XWalkCordovaResourceClient.TAG, "onPageFinished(" + url + ")");
    // Clear timeout flag
    appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    appView.getPluginManager().postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized
    // correctly
    if (appView.getView().getVisibility() == View.INVISIBLE) {
      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  try {
                    Thread.sleep(2000);
                    appView
                        .cordova
                        .getActivity()
                        .runOnUiThread(
                            new Runnable() {
                              public void run() {
                                appView.getPluginManager().postMessage("spinner", "stop");
                              }
                            });
                  } catch (InterruptedException e) {
                  }
                }
              });
      t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
      appView.getPluginManager().postMessage("exit", null);
    }
  }
Esempio n. 3
0
 public XWalkCordovaClient(XWalkCordovaWebView webView) {
   super(webView.getView());
   appView = webView;
   helper = new CordovaUriHelper(appView.cordova, appView);
 }