This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hey guys!
I'm working on a simple app where I want to wrap a web client. So far everything is going amazing, but I have one little issue. I end up using webView.evaluateJavascript(), and for overall better architecture design I made separate class for two types of evaluateJavascripts.
One without callback:
public static void send(WebView webView, String eventScript) {
webView.evaluateJavascript(eventScript, null);
Logger.withTag(TAG).log(" Event send to client " eventScript);
}
And one with callback:
public static void sendAsync(WebView webView, String eventID) {
webView.evaluateJavascript(eventID, new ValueCallback<String>() {
@Override
public void onReceiveValue(String result) {
// Do what you want with the return value
Log.d(result, " Received");
}
});
}
So my problem here is that I need to pass the WebView as parameter. Is there a way to avoid that.
First thing came to my mind is to make WebView global, but the IDE warns me for memory leaks.
So yeah...kinda small problem but still I would like to make this better. Maybe I should try some design pattern?
Subreddit
Post Details
- Posted
- 6 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/androiddev/...