Need to disable the cache on WebViews inflated through Proteus.
Are there any attributes on the
WebViewwhich can be used to disable it?
We could find the view normally would if it was inflated using precompiled XML layouts using findViewById(R.id.something) and call the following methods on it.
WebView wv = parent.findViewById(R.id.webview);
WebSettings ws = wv.getSettings();
ws.setAppCacheEnabled(false);
ws.setCacheMode(WebSettings.LOAD_NO_CACHE)
But since proteus inflates layouts using
JSONfrom the server I cannot find the view like this and the solution would not scale for multipleWeViews.
You can register a custom attribute handler say
disableCachefor the WebView and solve your problem.Use
layoutInflaterto inflate your layout and then in your layout set the attribute totrueorfalseas you please.You can register the custom attribute handler with your instance of
Proteusand it will start working. The benefit is that you can toggle the flag based on your requirements and avoid hard coding cache disabled for all web views inflated through proteus.