Back to project page jockeyjs.
The source code is released under:
// // Copyright (c) 2013, Tim Coulter // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"),...
If you think the Android project jockeyjs listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jockeyjs; /*from w ww .j a va 2 s. c o m*/ import android.webkit.WebView; import com.google.gson.Gson; public class DefaultJockeyImpl extends JockeyImpl { private int messageCount = 0; private Gson gson = new Gson(); @Override public void send(String type, WebView toWebView, Object withPayload, JockeyCallback complete) { int messageId = messageCount; if (complete != null) { add(messageId, complete); } if (withPayload != null) { withPayload = gson.toJson(withPayload); } String url = String.format("javascript:Jockey.trigger(\"%s\", %d, %s)", type, messageId, withPayload); toWebView.loadUrl(url); ++messageCount; } @Override public void triggerCallbackOnWebView(WebView webView, int messageId) { String url = String.format("javascript:Jockey.triggerCallback(\"%d\")", messageId); webView.loadUrl(url); } }