Ejemplo n.º 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;
  }