示例#1
0
  private String processForNativeView(String _url) {
    StringBuilder s = new StringBuilder("processForNativeView : [");
    s.append(_url);
    s.append("]");
    Utils.platformLog(TAG, s.toString());

    String url = _url;
    String callback_prefix = "call_stay_native";

    // find protocol:navto pairs

    int last = -1;
    int cur = url.indexOf(":", last + 1);
    while (cur > 0) {
      String protocol = url.substring(last + 1, cur);
      String navto = url.substring(cur + 1, url.length());

      if (callback_prefix.equals(protocol)) {
        // navigate but still in native view
        String cleared_url = url.substring(callback_prefix.length() + 1, url.length());
        return cleared_url;
      }
      // check protocol for nativeView
      RhoNativeViewManager.RhoNativeView nvf = RhoNativeViewManager.getNativeViewByteType(protocol);
      if (nvf != null) {
        // we should switch to NativeView
        // restoreWebView();
        if (mNativeView != null) {
          if (!protocol.equals(mNativeView.getViewType())) {
            setNativeView(nvf);
          }
        } else {
          setNativeView(nvf);
        }
        if (mNativeView != null) {
          mNativeView.navigate(navto);
          return "";
        }
      }
      last = cur;
      int c1 = url.indexOf(":", last + 1);
      int c2 = url.indexOf("/", last + 1);
      if ((c1 < c2)) {
        if (c1 <= 0) {
          cur = c2;
        } else {
          cur = c1;
        }
      } else {
        if (c2 <= 0) {
          cur = c1;
        } else {
          cur = c2;
        }
      }
    }
    restoreWebView();
    return url;
  }
示例#2
0
  public void restoreWebView() {
    if (mNativeView != null) {
      view.removeView(mNativeViewView);
      mNativeViewView = null;
      // int view_index = 0;
      // if (navBar != null) {
      // view_index = 1;
      // }

      if (navBar != null) {
        view.removeView(navBar);
      }
      if (toolBar != null) {
        view.removeView(toolBar);
      }

      int index = 0;
      if (navBar != null) {
        view.addView(navBar, index);
        index++;
      }
      view.addView(webView, index, new LinearLayout.LayoutParams(FILL_PARENT, 0, 1));
      index++;
      if (toolBar != null) {
        view.addView(toolBar, index);
      }

      // view.bringChildToFront(webView);

      mNativeView.destroyView();
      mNativeView = null;
      // view.requestLayout();
    }
  }
示例#3
0
  public void setNativeView(RhoNativeViewManager.RhoNativeView nview) {
    restoreWebView();
    mNativeView = nview;
    mNativeViewView = mNativeView.getView();
    if (mNativeViewView != null) {
      view.removeView(webView);
      // int view_index = 0;
      // if (navBar != null) {
      // view_index = 1;
      // }
      if (navBar != null) {
        view.removeView(navBar);
      }
      if (toolBar != null) {
        view.removeView(toolBar);
      }
      int index = 0;
      if (navBar != null) {
        view.addView(navBar, index);
        index++;
      }
      view.addView(mNativeViewView, index, new LinearLayout.LayoutParams(FILL_PARENT, 0, 1));
      index++;
      if (toolBar != null) {
        view.addView(toolBar, index);
      }

      // view.bringChildToFront(mNativeViewView);
      // view.requestLayout();
    } else {
      mNativeView = null;
      mNativeViewView = null;
    }
  }