@Override public WebViewBridge loadWebViewBridge(Fragment fragment, View inflatedView) { Class<?> clazz = fragment.getClass(); LayoutConfig config = createLayoutConfig(clazz); WebViewBridge webViewBridge = (WebViewBridge) inflatedView.findViewById(config.getWebViewBridgeId()); webViewBridge.setDomainConfig(createDomainConfig(clazz)); webViewBridge.setNoPause(hasNoPause(clazz)); return webViewBridge; }
@Override public WebViewBridge loadWebViewBridge(Activity activity) { Class<?> clazz = activity.getClass(); LayoutConfig config = createLayoutConfig(clazz); activity.setContentView(config.getLayoutId()); WebViewBridge webViewBridge = (WebViewBridge) activity.findViewById(config.getWebViewBridgeId()); webViewBridge.setDomainConfig(createDomainConfig(clazz)); webViewBridge.setNoPause(hasNoPause(clazz)); return webViewBridge; }
@SuppressLint("SetJavaScriptEnabled") public void configureSetting(WebViewBridge webViewBridge) { WebSettings settings = webViewBridge.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setGeolocationEnabled(true); settings.setDomStorageEnabled(true); File databasePath = new File(mContext.getCacheDir(), "webstorage"); settings.setDatabasePath(databasePath.toString()); settings.setAppCacheEnabled(true); settings.setAppCacheMaxSize(1024 * 1024 * 4); }
@Override public void registerBridge(WebViewBridge webViewBridge, Object bridgeObject) { bridgeObject = mInjectorHelper.inject(mContext, bridgeObject); Class<?> clazz = bridgeObject.getClass(); BridgeObjectConfig config = mConfigCache.getBridgeObjectConfig(clazz); if (config == null) { Log.d(TAG, "Miss cache bridge config"); config = createBridgeConfig(bridgeObject); mConfigCache.putBridgeObjectConfig(clazz, config); } else Log.d(TAG, "Bridge config from cache"); webViewBridge.addBridgeObjectConfig(bridgeObject, config); }