Android Open Source - jockeyjs Default Jockey Impl






From Project

Back to project page jockeyjs.

License

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.

Java Source Code

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);
  }

}




Java Source Code List

com.example.jockeytestapp.MainActivity.java
com.jockeyjs.CompositeJockeyHandler.java
com.jockeyjs.DefaultJockeyImpl.java
com.jockeyjs.HostValidationException.java
com.jockeyjs.JockeyAsyncHandler.java
com.jockeyjs.JockeyCallback.java
com.jockeyjs.JockeyHandler.java
com.jockeyjs.JockeyImpl.java
com.jockeyjs.JockeyService.java
com.jockeyjs.JockeyWebViewClient.java
com.jockeyjs.JockeyWebViewPayload.java
com.jockeyjs.Jockey.java
com.jockeyjs.NativeOS.java
com.jockeyjs.util.BackgroundExecutor.java
com.jockeyjs.util.ForwardingWebViewClient.java