コード例 #1
0
ファイル: nativeview.cpp プロジェクト: stinie/rhodes
RHO_GLOBAL jobject JNICALL Java_com_rhomobile_rhodes_nativeview_RhoNativeViewManager_getViewByHandle
(JNIEnv *env, jclass, jlong handle) {
	NativeView* p = (NativeView*)handle;
	if (p == NULL) {
		return NULL;
	}
	return (jobject)(p->getView());
}
コード例 #2
0
ファイル: nativeview.cpp プロジェクト: stinie/rhodes
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_nativeview_RhoNativeViewManager_navigateByHandle
(JNIEnv *env, jclass, jlong handle, jstring url) {
    	if (logging_enable) RAWLOG_INFO("navigateByHandle() START");

	NativeView* p = (NativeView*)handle;
	if (p != NULL) {
    		if (logging_enable) RAWLOG_INFO("navigateByHandle() handle not NULL");
		p->navigate(rho_cast<std::string>(url).c_str());
	}
    	if (logging_enable) RAWLOG_INFO("navigateByHandle() FINISH");
}
コード例 #3
0
ファイル: MainWindow.cpp プロジェクト: Aerodynamic/rhodes
// return true if NativeView was created
String CMainWindow::processForNativeView(String _url) {

	String url = _url.c_str();
	String callback_prefix = "call_stay_native";

	// find protocol:navto pairs

	int last = -1;
	int cur = url.find_first_of(':', last+1);
	while (cur > 0) {
		String protocol = url.substr(last+1, cur - last - 1);
		String navto = url.substr(cur+1, url.size() - cur);
		
		if (callback_prefix.compare(protocol) == 0) {
			// navigate but still in native view
			String cleared_url = url.substr(callback_prefix.size()+1, url.size() - callback_prefix.size());
			return cleared_url;
		}
		// check protocol for nativeView
		NativeViewFactory* nvf = RhoNativeViewManagerWM::getFactoryByViewType(protocol.c_str());
		if (nvf != NULL) {
			// we should switch to NativeView
			if (mNativeView != NULL) {
				if (protocol.compare(mNativeViewType) == 0) {
					mNativeView->navigate(navto.c_str());
					return "";
				}
			}

			restoreWebView();
			NativeView* nv = nvf->getNativeView(protocol.c_str());
			if (nv != NULL) {

				openNativeView(nvf, nv, protocol);

				nv->navigate(navto.c_str());

				mIsOpenedByURL = true;

				return "";
			}
			restoreWebView();
			return url;
		}
		last = cur;
		int c1 = url.find_first_of(':', last+1);
		int c2 = url.find_first_of('/', last+1);
		if ((c1 < c2)) {
			if (c1 <= 0) {
				cur = c2;
			}
			else {
				cur = c1;
			}
		}
		else {
			if (c2 <= 0) {
				cur = c1;
			}
			else {
				cur = c2;
			}
		}
	}
	if (mIsOpenedByURL) {
		restoreWebView();
	}
	return url;
}